Module:Lang/tag from name

--[[--< N A M E - T O - C O D E  D A T A >

Creates name-to-code tables from the data in Module:Language/name/data (from Module:Language/data/iana languages, Module:Language/data/ISO 639-3, Module:Language/data/wp languages) and Module:Lang/data so that templates can get language codes from the same names as the templates get from those codes.

]]

local rev_lang_name_table = {};													-- same as Module:Language/name/data except reversed so language name is key and language code is value local rev_lang_data = {};														-- same as Module:Lang/data except reversed

local list = {																	-- list of modules to process {'Module:Language/name/data', rev_lang_name_table},							-- associate source modules with output tables {'Module:Lang/data', rev_lang_data}, }

for i, list_table in ipairs (list) do											-- spin through the list of modules local raw_data = mw.loadData (list_table[1])								-- load the data from the source module for code, name_table in pairs (raw_data) do									-- spin through the code-to-name source data local name = name_table[1];												-- there can be multiple names, always take the first name name = name:gsub ('%s+%b', '');										-- remove parenthetical disambiguators or qualifiers from names that have them list_table[2][name] = code;												-- add language name (key) and code (value) pair to the output table end end

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

return { rev_lang_name_table = rev_lang_name_table, rev_lang_data = rev_lang_data, }