Modul:P
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 lang = mw.text.trim( templateArgs["1"] or "" )
local entry = mw.text.trim( templateArgs["2"] or "" )
local genus = mw.text.trim( templateArgs["3"] or "" )
local fentry = mw.text.trim( templateArgs["4"] or "" )
local langName = Language.getName( lang )
local langDir = Language.getDirection( lang )
if lang == "" 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
output = "<span lang=\"" .. lang .. "\" dir=\"" .. langDir .. "\" class=\"translation-item\" data-" .. lang .. "WictLink=\"" .. fentry .."\">[[" .. entry .. "#" .. langName .. "|" .. entry .. "]]</span>" .. genus
end
output = frame:preprocess( output )
return output
end
----------------------------------------
return _module