وحدة:translations
يمكن إنشاء صفحة توثيق الوحدة في وحدة:translations/شرح
local m_links = require("Module:links")
local export = {}
local interwiki_langs = {
["nds-de"] = "nds",
["nds-nl"] = "nds",
["pdt"] = "nds",
}
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local interwiki = frame.args["interwiki"]
local params = {
[1] = {required = true, default = "und"},
[2] = {},
[3] = {list = true},
["alt"] = {},
["sc"] = {},
["tr"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local lang = args[1]
local term = args[2] or (mw.title.getCurrentTitle().nsText == "Template" and "term") or nil
local genders = args[3]
local alt = args["alt"]
local tr = args["tr"]
lang = require("Module:languages").getByCode(lang) or error("The language code \"" .. lang .. "\" is not valid.")
sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
-- Don't show the interwiki link if there is nothing to link to.
if term then
local wmlangs = {}
if interwiki_langs[lang:getCode()] then
wmlangs = {require("Module:wikimedia languages").getByCode(interwiki_langs[lang:getCode()])}
else
wmlangs = lang:getWikimediaLanguages()
end
-- Don't show the interwiki link if the language is not recognised by Wikimedia
-- or if the term contains links (for SOP translations)
if term:find("[[", nil, true) or #wmlangs == 0 then
interwiki = false
end
if interwiki then
interwiki = "<span class=\"" .. interwiki .. "\"> [[:"
.. wmlangs[1]:getCode() .. ":"
.. lang:makeEntryName(term)
.. "|(" .. wmlangs[1]:getCode() .. ")]]</span>"
end
end
if lang and lang:getCode()=='yue' and tr then
tr = mw.ustring.gsub(tr,'([1-9])','<sup>%1</sup>')
tr = mw.ustring.gsub(tr,'[-*]','⁻')
end
return m_links.full_link(term, alt, lang, sc, nil, nil, {interwiki = interwiki, tr = tr, genders = genders}, true)
end
return export