Difference between revisions of "Module:Translated"
Jump to navigation
Jump to search
(Created page with "-- This module is created as a proposal to partially replace the existing Template:Translated -- List of languages to check localized pages for local langlist = { de = "...") |
(avoid unnecessary newline) |
||
Line 19: | Line 19: | ||
|- | |- | ||
| '''Other languagues''' || | | '''Other languagues''' || | ||
− | [[%s|🇬🇧 English]] | + | [[%s|🇬🇧 English]]]=], pagename) |
− | ]=], pagename) | ||
local stringlist = {basestr} | local stringlist = {basestr} | ||
for lang, icon in pairs(langlist) do | for lang, icon in pairs(langlist) do |
Revision as of 18:29, 30 May 2021
-- This module is created as a proposal to partially replace the existing Template:Translated
-- List of languages to check localized pages for
local langlist = {
de = "🇩🇪",
ru = "🇷🇺",
fr = "🇫🇷",
es = "🇪🇸",
-- I did not add the flags for zh-hans and zh-hant mainly for political reasons
["zh-hans"] = "",
["zh-hant"] = "",
}
local function main(frame)
-- It is common for modules to have wrapper functions. In this case it can be (for example) {{#invoke:Translated|main|{{{pagename|{{NAMESPACE}}:{{BASEPAGENAME}}}}}}}, which should work in most cases.
local pagename = frame.args.pagename or error("No page name supplied")
local basestr = string.format([=[
{| class="wikitable"
|-
| '''Other languagues''' ||
[[%s|🇬🇧 English]]]=], pagename)
local stringlist = {basestr}
for lang, icon in pairs(langlist) do
local title = mw.title.new(pagename .. "/" .. lang)
if title.exists then -- WARNING: EXPENSIVE OPERATION
stringlist[#stringlist+1] = string.format(" - [[%s/%s|%s %s]]", pagename, lang, icon, mw.language.fetchLanguageName(lang))
end
end
stringlist[#stringlist+1] = "\n|}"
return table.concat(stringlist)
end
return {main = main}