Modul:P
Vzhled
Dokumentaci tohoto modulu lze vytvořit na stránce Nápověda:Modul:P
-- @brief
-- Backend for {{P}}.
--
-- @details
-- Generates the translation item.
--
-- @author
-- [[meta:User:Danny B.]]
local _module = {}
----------------------------------------
local Error = require( "Module:Error" )
local Language = require( "Module:Language" )
-- @brief
-- Write the translation item.
--
-- @param
-- frame The current frame object
--
-- @return
-- Preprocessed wikitext
function _module.print( frame )
local output = ""
local parentFrame = frame:getParent()
local templateArgs = parentFrame.args
local errorData = { template = "P" }
local langTag = mw.text.trim( templateArgs[1] or "" )
local entry = mw.text.trim( templateArgs[2] or "" )
local genus = mw.text.trim( templateArgs[3] or "" )
local iw = templateArgs[4] and mw.text.trim( templateArgs[4] )
local langName = Language:getName( langTag )
local langDir = Language:getDirection( langTag )
if langTag == "" then
errorData.missingValue = { paramName = 1, paramDesc = "kód jazyka" }
output = output .. Error.getText( errorData )
elseif not langName then
errorData.unknownValue = { paramName = 1, paramDesc = "kód jazyka" }
output = output .. Error.getText( errorData )
end
if entry == "" then
errorData.missingValue = { paramName = 2, paramDesc = "překlad hesla" }
output = output .. Error.getText( errorData )
end
if output == "" then
if genus ~= "" then
genus = mw.ustring.gsub( genus, "(.)", " {{%1}}" )
end
local translationItem = mw.html.create( "span" )
translationItem
:attr({
["lang"] = langTag,
["dir"] = langDir,
["class"] = "translation-item",
["data-iw"] = iw
})
:wikitext(
"[[",
entry,
"#",
langName,
"|",
entry,
"]]"
)
:allDone()
output = tostring( translationItem ) .. genus
if langTag == "he" and not mw.ustring.find( entry, "[ְֱֲֳִֵֶַָֹֻּׁׂ]" ) then
output = output .. "[[Kategorie:Monitoring:Nevokalizovaný hebrejský překlad]]"
end
end
output = frame:preprocess( output )
return output
end
----------------------------------------
return _module