Módulo:Otros idiomas
De Inkipedia
La documentación para este módulo puede ser creada en Módulo:Otros idiomas/doc
local p = {} local gameShortenedModule = require("Module:Acortar juego") local flagModule = require("Module:Bandera") local function getGameShortened(game, default) return gameShortenedModule.getGame(game, default) end local function getFlag(country) return flagModule.getFlag(country, "20x20") end -- Function to handle a single language entry in the table -- t: the table to append -- args: the frame args which includes the Meaning and Romanized values if applicable -- languageTitle: the Title Case description of the language -- wikiParameter: the base wiki parameter (without M and R) for the language we are handling -- flagParameter: the two letter lower-case code for this language -- htmlLanguageCode: the language code used in HTML for this language. Reference: [https://www.w3schools.com/tags/ref_language_codes.asp] local function handleLanguage(t, args, languageTitle, wikiParameter, flagParameter, htmlLanguageCode) if args[wikiParameter] and args[wikiParameter] ~= '' then local flag = getFlag(flagParameter) if not flag then flag = "[[File:Flag.svg|link=]]" end local htmlLang = htmlLanguageCode or wikiParameter or "" local name = args[wikiParameter] or "Unnamed language (" .. wikiParameter .. ")" local romanized = "" if args[wikiParameter .. "R"] and args[wikiParameter .. "R"] ~= "" then romanized = "<br/>''" .. args[wikiParameter .. "R"] .. "''" end local meaning = "" if args[wikiParameter .. "M"] and args[wikiParameter .. "M"] ~= "" then meaning = args[wikiParameter .. "M"] end table.insert(t, "|-") table.insert(t, "|" .. flag .. " " .. languageTitle .. "|||<span lang=\"" .. htmlLang .. "\">" .. name .. "</span>" .. romanized .. "|||" .. meaning) end end function p.main(frame) local args = frame:getParent().args return p.localizedName(args) end function p.localizedName(args) local colorClass = "generic" if args["color"] and args["color"] ~= '' then colorClass = mw.ustring.lower(getGameShortened(args["color"], "generic")) or "generic" end local t = {} mw.logObject(colorClass) table.insert(t, '{| class="wikitable sitecolor-' .. colorClass .. '" style="min-width: 25%;') if args["title"] then table.insert(t, "|+" .. args.title) end table.insert(t, "!" .. (args["columna-1"] or "Idioma")) table.insert(t, "!" .. (args["columna-2"] or "Nombre")) table.insert(t, "!" .. (args["columna-3"] or "Significado")) -- Handle each language handleLanguage(t, args, "Japonés", "Jap", "jp", "ja") handleLanguage(t, args, "Inglés", "Eng", "us", "en-en") handleLanguage(t, args, "Holandés", "Dut", "nl", "nl") handleLanguage(t, args, "Francés", "Fra", "cafr", "fr") handleLanguage(t, args, "Francés (NOA)", "FraA", "ca", "fr-ca") handleLanguage(t, args, "Francés (NOE)", "FraE", "fr", "fr-fr") handleLanguage(t, args, "Francés", "Fre", "cafr", "fr") handleLanguage(t, args, "Francés (NOA)", "FreA", "ca", "fr-ca") handleLanguage(t, args, "Francés (NOE)", "FreE", "fr", "fr-fr") handleLanguage(t, args, "Alemán", "Ger", "de", "de") handleLanguage(t, args, "Italiano", "Ita", "it", "it") handleLanguage(t, args, "Ruso", "Rus", "ru", "ru") handleLanguage(t, args, "Chino", "Chi", "cn", "zh") handleLanguage(t, args, "Chino (Simplificado)", "ChiS", "cn", "zh-Hans") handleLanguage(t, args, "Chino (Tradicional)", "ChiT", "hk", "zh-Hant") handleLanguage(t, args, "Checo", "Cze", "cz", "cs") handleLanguage(t, args, "Danés", "Dan", "da", "da") handleLanguage(t, args, "Finlandés", "Fin", "fi", "fi") handleLanguage(t, args, "Húngaro", "Hun", "hu", "hu") handleLanguage(t, args, "Coreano", "Kor", "kr", "ko") handleLanguage(t, args, "Noruego", "Nor", "no", "no") handleLanguage(t, args, "Polaco", "Pol", "pl", "pl") handleLanguage(t, args, "Portugués", "Por", "pt", "pt") handleLanguage(t, args, "Portugués (NOA)", "PorA", "br", "pt-br") handleLanguage(t, args, "Portugués (NOE)", "PorE", "pt", "pt-pt") handleLanguage(t, args, "Sueco", "Swe", "se", "sv") -- Internal is a bit different because there's no code or flag if args["Internal"] and args["Internal"] ~= '' then table.insert(t, "|-") table.insert(t, "|[[File:Translate logo.svg|border|20px|link=]] Internal|||<span lang=\"\">" .. args["Internal"] .. "</span>|||" .. (args["InternalM"] or "")) end return table.concat(t, "\n") .. "\n|}" end return p