Module:Name in various languages
Appearance
![]() | This module is rated as alpha. It is ready for third-party input, and may be used on a few pages to see if problems arise, but should be watched. Suggestions for new features or changes in their input and output mechanisms are welcome. |
Usage
{{#invoke:Name in various languages|main}}
This is a Lua-based replacement for {{Name in official languages}}.
Example
Lua error in Module:Lang at line 395: attempt to index local 'source' (a number value).
local lang = require ('Module:Lang');
local p = {}
local SEPARATOR = '|- style="border-bottom:1px solid #aaa"\n'
local STYLE = "border-bottom:1px solid #aaa"
local function make_table_start(width, font_size, name)
return '{| class="mw-collapsible mw-collapsed" style="width:'..width..';'..
'font-size:' .. font_size .. '; text-align:left; border-collapse:collapse;'..'\n'..
'! colspan=2 style="text-align:center; border-top: 0px;" | '..name..'\n'
end
local function make_language_row(frame, lang_code, lang_text)
local lang_link_wikilink = lang._name_from_tag({lang_code, ['link'] = 'yes'})
return "! style=\"padding-left:0.5em\" | "..lang_link_wikilink..
"\n| "..frame:expandTemplate{title='lang',args={lang_code, lang_text}}
end
local function lang_exists(lang_code)
local s = lang._name_from_tag({lang_code})
if string.match(s, "Error: unrecognized language tag") then
return false
end
return true
end
function p.main(frame)
local output = ''
output = output .. make_table_start(
frame.args.width,
frame.args.font_size,
frame.args.name) .. SEPARATOR
for k,v in pairs(frame.args) do
if lang_exists(k) then
output = output .. make_language_row(frame,k,v) .. '\n' .. SEPARATOR
end
end
output = output .. '|}'
return output
end
return p