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
Names of the European Union | |
---|---|
[undefined] <span style="color: | 1|
}} |
Italian: | it|Unione europea}} |
French: | fr|Union européenne}} |
Estonian: | et|Euroopa Liit}} |
Swedish: | sv|Europeiska unionen}} |
Spanish: | es|Unión Europea}} |
German: | de|Europäische Union}} |
Portuguese: | pt|União Europeia}} |
Irish: | ga|An tAontas Eorpach}} |
Latvian: | lv|Eiropas Savienība}} |
Bulgarian: | bg|Европейски съюз}} |
Danish: | da|Den Europæiske Union}} |
Romanian: | ro|Uniunea Europeană}} |
Slovene: | sl|Evropska unija}} |
Maltese: | mt|Unjoni Ewropea}} |
Lithuanian: | lt|Europos Sąjunga}} |
Slovak: | sk|Európska únia}} |
Polish: | pl|Unia Europejska}} |
Hungarian: | hu|Európai Unió}} |
[50%] <span style="color: | width|50%}} |
[88%] <span style="color: | font_size|88%}} |
Greek: | el|Ευρωπαϊκή Ένωση}} |
[Names of the European Union] <span style="color: | name|Names of the European Union}} |
Finnish: | fi|Euroopan unioni}} |
English: | en|European Union}} |
Croatian: | hr|Europska unija}} |
Czech: | cs|Evropská unie}} |
Dutch: | nl|Europese Unie}} |
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 str_split(inputstr, sep)
local t = {}
if sep == nil then sep = "%s" end
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end
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(lang_code, lang_text)
local lang_link_wikitext = str_split(
lang.lang_xx_inherit(
{
code=lang_code,
text=lang_text
}),':')[1]..':'
return "! style=\"padding-left:0.5em\" | "..lang_link_wikitext..
"\n| {{lang|"..lang_code..'|'..lang_text..'}}'
end
function p.main(frame)
local output = ''
output = output .. make_table_start(
frame.args.width,
frame.args.font_size,
frame.args.name) .. SEPARATOR
frame.args.width = nil
frame.args.font_size = nil
frame.args.name = nil
for k,v in pairs(frame.args) do
output = output .. make_language_row(k,v) .. '\n' .. SEPARATOR
end
output = output .. '|}'
return output
end
return p