Module:Lang: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
No edit summary |
No edit summary |
||
Line 299: | Line 299: | ||
at {{Language with name and transliteration}}. If |script= is set, this function uses it in preference to code. |
at {{Language with name and transliteration}}. If |script= is set, this function uses it in preference to code. |
||
To avoid confusion, in this module and the templates that use it, the transliteration script parameter is renamed |
|||
to be |transl-script= (in this function, tscript) |
|||
]] |
]] |
||
local function make_translit (code, language_name, translit, std, |
local function make_translit (code, language_name, translit, std, tscript) |
||
local title; |
local title; |
||
local tout = {}; |
local tout = {}; |
||
Line 308: | Line 310: | ||
table.insert (tout, "''<span title=\""); |
table.insert (tout, "''<span title=\""); |
||
if not is_set (std) and not is_set ( |
if not is_set (std) and not is_set (tscript) then -- when neither standard nor script specified |
||
table.insert (tout, language_name); -- write a generic tool tip |
table.insert (tout, language_name); -- write a generic tool tip |
||
table.insert (tout, ' transliteration'); |
table.insert (tout, ' transliteration'); |
||
elseif is_set (std) and is_set ( |
elseif is_set (std) and is_set (tscript) then -- when both are specified |
||
if title_table[std][ |
if title_table[std][tscript] then -- and legitimate |
||
table.insert (tout, title_table[std][ |
table.insert (tout, title_table[std][tscript]); -- add the appropriate text to the tool tip |
||
else |
else |
||
return ''; -- one or both invalid, set up for an error message |
return ''; -- one or both invalid, set up for an error message |
||
end |
end |
||
elseif is_set (std) then -- script not set, use language code |
elseif is_set (std) then -- transl-script not set, use language code |
||
if not title_table[std] then return ''; end -- invalid standard, setupt for error message |
if not title_table[std] then return ''; end -- invalid standard, setupt for error message |
||
Line 325: | Line 327: | ||
table.insert (tout, title_table[std]['default']); -- so use the standard's default |
table.insert (tout, title_table[std]['default']); -- so use the standard's default |
||
end |
end |
||
else -- here if script set but std not set |
else -- here if transl-script set but std not set |
||
if title_table['NO_STD'][ |
if title_table['NO_STD'][tscript] then |
||
table.insert (tout, title_table['NO_STD'][ |
table.insert (tout, title_table['NO_STD'][tscript]); -- use transl-script if set |
||
elseif title_table['NO_STD'][code] then |
elseif title_table['NO_STD'][code] then |
||
table.insert (tout, title_table['NO_STD'][code]); -- use language code |
table.insert (tout, title_table['NO_STD'][code]); -- use language code |
||
Line 428: | Line 430: | ||
--[[--------------------------< L A N G _ X X >---------------------------------------------------------------- |
--[[--------------------------< L A N G _ X X >---------------------------------------------------------------- |
||
<includeonly>{{#invoke:lang|lang_xx|code=<code>|text={{{1|}}}|link={{{links|{{{link}}}}}}|rtl={{{rtl|}}}|nocat={{{nocat|}}}|italic={{{italic|}}}|lit={{{lit|}}}|translit={{{translit|}}}|script={{{script|}}}|std={{{std|}}}}}</includeonly> |
<includeonly>{{#invoke:lang|lang_xx|code=<code>|text={{{1|}}}|link={{{links|{{{link}}}}}}|rtl={{{rtl|}}}|nocat={{{nocat|}}}|italic={{{italic|}}}|lit={{{lit|}}}|translit={{{translit|}}}|transl-script={{{transl-script|}}}|std={{{std|}}}}}</includeonly> |
||
|code = the BCP47 language code |
|code = the BCP47 language code |
||
Line 441: | Line 443: | ||
|translit = text that is a transliteration of text |
|translit = text that is a transliteration of text |
||
|std = the standard that applies to the transliteration |
|std = the standard that applies to the transliteration |
||
|script = ISO 15924 script name; falls back to code |
|transl-script = ISO 15924 script name; falls back to code |
||
]] |
]] |
||
Line 479: | Line 481: | ||
end |
end |
||
translit_script = args |
translit_script = args['transl-script'] or language_name; -- for translit prefer |trans-script= over language |
||
if 'no' == args.link then |
if 'no' == args.link then |
||
Line 499: | Line 501: | ||
end |
end |
||
table.insert (out, ' </small>'); |
table.insert (out, ' </small>'); |
||
translit = make_translit (args.code, language_name, args.translit, args.std, args |
translit = make_translit (args.code, language_name, args.translit, args.std, args['transl-script']) |
||
if is_set (translit) then |
if is_set (translit) then |
||
table.insert (out, translit); |
table.insert (out, translit); |
||
else |
else |
||
return make_error_msg (table.concat ({'{{lang-xx}}: invalid translit std: \'', args.std or 'missing', '\' or script: \'', args |
return make_error_msg (table.concat ({'{{lang-xx}}: invalid translit std: \'', args.std or 'missing', '\' or script: \'', args['transl-script'] or 'missing', '\''}), args.nocat); |
||
end |
end |
||
end |
end |