Modul:tarjimalar

Vikilug‘atdan olingan

Bu modul uchun Modul:tarjimalar/doc nomli hujjat sahifasini yaratishingiz mumkin

local m_links = require("Module:links")
 
local export = {}
 
local interwiki_tillar = {
    ["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 tili = args[1] or (NAMESPACE == "Andoza" and "und") or error("Til kodi belgilangan olinmagan. Andoza parametrni 1 oʻtishi qiling.")
    local sc = args["sc"] or ""; if sc == "" then sc = nil end
    tili = require("Module:tili").getByCode(tili) or error("The language code \"" .. tili .. "\" is not valid.")
    sc = (sc and (require("Module:scripts").getByCode(sc) or error("The script code \"" .. sc .. "\" is not valid.")) or nil)
 
    local term = args[2] or (NAMESPACE == "Templat" and "term" or ""); if term == "" then term = nil end
    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 there is nothing to link to.
    if term then
    	local wmlangs = {}
 
    	if interwiki_tillar[tili:getCode()] then
    		wmlangs = {require("Module:wikimedia languages").getByCode(interwiki_tillar[tili:getCode()])}
    	else
    		wmlangs = tili: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 .. "\">&nbsp;[[:"
        	.. wmlangs[1]:getCode() .. ":"
        	.. tili:makeEntryName(term)
        	.. "|(" .. wmlangs[1]:getCode() .. ")]]</span>"
    	end
    end
 
    return m_links.full_link(term, alt, tili, sc, nil, nil, {interwiki = interwiki, tr = tr, genders = genders}, true)
end
 
return export