Module:Lang: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 132:
 
return translit <span>...</span> else return empty string
 
The value |script= is not used in {{transl}} for this purpose; instead it uses |code. Because language scripts
are listed in the {{transl}} switches they are included in the data tables. The script parameter is introduced
at {{Language with name and transliteration}}. If |script= is set, this function uses it in preference to code.
 
]]
Line 138 ⟶ 142:
local title;
local tout = {};
local title_table = mw.loadData ('Module:Lang/data') -- table of transliteration standards and the language codes and scripts that apply to those standards
table.insert (tout, "''<span title=\"");
if not is_set (std) and not is_set (script) then -- when neither standard nor script specified
table.insert (tout, language_name); -- write a generic tool tip
table.insert (tout, ' transliteration');
elseif is_set (std) and is_set (script) then -- when both are specified
if title_table.std.script then -- and legitimate
table.insert (tout, title_table.std.script); -- add the appropriate text to the tool tip
else
return ''; -- one or both invalid, set up for an error message
return '';
end
elseif is_set (std) then -- script not set, use language code
if not title_table.std then return ''; end -- invalid standard, setupt for error message
if title_table.std.code then
table.insert (tout, title_table.std.code);
else -- code doesn't match
else
table.insert (tout, title_table.std['default']); -- so use the standard's default
end
else -- here if script set but std not set
if title_table['NO_STD'].script then
table.insert (tout, title_table['NO_STD'].script); -- use script if set
elseif title_table['NO_STD'].code then
table.insert (tout, title_table['NO_STD'].code); -- use language code
else
table.insert (tout, language_name); -- write a generic tool tip
table.insert (tout, ' transliteration');
end
Anonymous user