Jump to content

Module:translations

ئورنى Wiktionary

Documentation for this module may be created at Module:translations/doc

--local m_languages = mw.loadData("Module:langua")
--local m_scriptutils = require("Module:script utilities")
--local m_utilities = require("Module:utilities")
--local m_links = require("Module:links")
 
local export = {}

local interwiki_langs = {
    ["nan"] = "zh-min-nan",
    ["yue"] = "zh-yue",
    ["cmn"] = "zh",
    ["nb"] = "no",
    ["rup"] = "roa-rup",
    ["kmr"] = "ku",
    ["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 args = frame:getParent().args
    local interwiki = frame.args["interwiki"]

    NAMESPACE = mw.title.getCurrentTitle().nsText
    local categories = {}
    
    local lang = args[1] or (NAMESPACE == "Template" and "und") or error("Language code has not been specified. Please pass parameter 1 to the template.")
    local langinfo= {	names = {"Uyghur", "Uigur", "Uighur", "Uygur"},	type = "regular",	scripts = {"ug-Arab", "Latn", "Cyrl"},	family = "trk",	translit_module = "ug-translit"}
    local sc = args["sc"] or ""; if sc == "" then sc = nil end
    
    local term = args[2] or (NAMESPACE == "Template" and "term") or error("Term has not been specified. Please pass parameter 2 to the template.")
    local alt = args["alt"]; if alt == "" then alt = nil end
    
    local tr = args["tr"]; if tr == "" then tr = nil end
    
    -- Gender and number
    -- Iterate over all numbered parameters starting from 3, until one is empty.
    local genders = {}
    local i = 3
    local g = args[i] or ""
    
    while g ~= "" do
        table.insert(genders, g)
        i = i + 1
        g = args[i] or ""
    end
    
    -- Don't show the interwiki link if the language is not recognised by MediaWiki
    -- or if the term contains links (for SOP translations)
    if term:find("[[", nil, true) or not mw.language.isKnownLanguageTag(interwiki_langs[lang] or lang) then
        interwiki = false
    end
    
    if interwiki then
        interwiki = "<span class=\"" .. interwiki .. "\">&nbsp;[[:"
        .. (interwiki_langs[lang] or lang) .. ":"
        .. m_links.remove_diacritics(term, lang)
        .. "|(" .. (interwiki_langs[lang] or lang) .. ")]]</span>"
    end
    
    return m_links.full_link(term, alt, lang, sc, nil, nil, {interwiki = interwiki, tr = tr, genders = genders})
end

return export