Module:Lang/tag from name explained

local lang_data = mw.loadData ('Module:Lang/data'); -- language name override and transliteration tool-tip tableslocal lang_name_table = lang_data.lang_name_table; -- language codes, names, regions, scripts, suppressed scripts

local lang_table = lang_name_table.lang; -- language codes, nameslocal lang_dep_table = lang_name_table.lang_dep; -- deprecated language codes, nameslocal override_table = lang_data.override;

local rev_lang_table = ; -- same as lang_table reversed so language name is key and language tag is valuelocal rev_lang_dep_table = ; -- same as lang_dep_table reversed so language name is key and language tag is valuelocal rev_override_table = ; -- same as override_table except reversedlocal dedabbed_names_list = ; -- holds a list of dedabbed name and tags

----------------------------< R E V _ L I S T _ A D D >------------------------------------------------------

local function to add (key) and (value) pair to

/ pairs where is ISO 639-1, overwrite all other / pairs. When creating overrides,take care that the is properly disambiguated to avoid improper masking

local function rev_list_add (rev_list, name, tag) if rev_list[name] then -- if already in if 2

tag:len then -- is this is a 2-characater code? rev_list[name] = tag; -- yes, overwrite 3-characater language and pair in end else -- here when not yet in rev_list[name] = tag; -- add language and (value) pair to endend

----------------------------< D E D A B B E D _ N A M E S _ L I S T _ A D D >--------------------------------

adds / pairs to the dedabbed_names_list when not already present. When is present inthe list, unsets the listed to empty string; cannot have different / pairs where the tablekey () is shared with another / pair.

local function dedabbed_names_list_add (dab, name, tag) if 0 ~= dab then -- if dab was removed if dedabbed_names_list[name] then -- if this dedabbed name is in the table then there are more than one name with different dabs dedabbed_names_list[name] = ; -- unset but not too unset else dedabbed_names_list[name] = tag; -- add name / tag pair in case this the only dedabbed name end endend

----------------------------< D E D A B B E D _ T O _ R E V _ L I S T _ A D D >------------------------------

adds / pairs to specified when is not empty string

local function dedabbed_to_rev_list_add (rev_list, name, tag) for name, tag in pairs (dedabbed_names_list) do -- add dedabbed / pairs to the reversed table if ~= tag then -- when / has not been unset because of multiple dabs rev_list_add (rev_list, name, tag); -- add end endend

--

for tag, name_table in pairs (lang_table) do if not override_table[tag] then -- only add names/tags from name_table when tag not present in override table local name_raw = name_table:lower; local name, dab = name_raw:gsub ('%s+%b', ); -- remove parenthetical disambiguators or qualifiers from names that have them; non-zero when disambiguation removed rev_list_add (rev_lang_table, name_raw, tag); -- add no-dab-names and names-with-dab here dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbed endend

dedabbed_to_rev_list_add (rev_lang_table, name, tag); -- add dedabbed name/tag pairs to the reversed table

dedabbed_names_list = ; -- reset list of dedabbed names

for tag, name_table in pairs (lang_dep_table) do if not override_table[tag] then -- only add names/tags from name_table when tag not present in override table local name_raw = name_table:lower; local name, dab = name_raw:gsub ('%s+%b', ); -- remove parenthetical disambiguators or qualifiers from names that have them; non-zero when disambiguation removed rev_list_add (rev_lang_dep_table, name_raw, tag); -- add no-dab-names and names-with-dab here dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbed endend

dedabbed_to_rev_list_add (rev_lang_dep_table, name, tag); -- add dedabbed name/tag pairs to the reversed table

dedabbed_names_list = ; -- reset list of dedabbed names

for tag, name_table in pairs (override_table) do local name_raw = name_table:lower; local name, dab = name_raw:gsub ('%s+%b', ); -- remove parenthetical disambiguators or qualifiers from names that have them

rev_list_add (rev_override_table, name_raw, tag); dedabbed_names_list_add (dab, name, tag); -- add to dedabbed_names_list if dabbedend

dedabbed_to_rev_list_add (rev_override_table, name, tag); -- add dedabbed name/tag pairs to the reversed table

dedabbed_names_list = ; -- reset list

----------------------------< E X P O R T E D T A B L E S >------------------------------------------------

return