Module:Lang: Difference between revisions

promote code to ISO 639-1 if synonymous;
(use code for categories, not args.code;)
(promote code to ISO 639-1 if synonymous;)
Line 10:
local getArgs = require ('Module:Arguments').getArgs;
local lang_name_table = mw.loadData ('Module:Language/name/data');
 
local synonym_table = mw.loadData ('Module:Lang/ISO 639 synonyms'); -- ISO 639-2/639-2T code translation to 639-1 code
 
local lang_data = mw.loadData ('Module:Lang/data'); -- language name override and transliteration tool-tip tables
 
local namespace = mw.title.getCurrentTitle().namespace; -- used for categorization
 
local maint_cats = {}; -- maintenance categories go here
 
 
Line 185 ⟶ 189:
if not (lang_data.override[code] or lang_name_table.lang[code]) then
return nil, nil, nil, nil, table.concat {'unrecognized language code: ', code}; -- invalid language code, don't know about the others (don't care?)
end
if synonym_table[code] then -- if 639-2/639-2T code has a 639-1 synonym
table.insert (maint_cats, {'Lang or lang-xx code promoted to ISO 639-1', code});
code = synonym_table[code][1]; -- use the synonym
end
 
Line 559 ⟶ 568:
table.insert (out, make_text_span (args.code, args.text, args.rtl, args.italic, args.size));
table.insert (out, make_category (code, language_name, args.nocat));
if 0 < #maint_cats then
for _, cat_tbl in ipairs (maint_cats) do
table.insert (out, table.concat ({'[[Category:', cat_tbl[1], '|', cat_tbl[2], ']]'}));
end
end
return table.concat (out); -- put it all together and done
end
Anonymous user