Mòideal:Lang/name to tag
Coltas
(deasbaireachd⧼tpt-languages-separator⧽ ⧼tpt-languages-separator⧽eachdraidh⧼tpt-languages-separator⧽ceanglaichean⧼tpt-languages-separator⧽doc⧼tpt-languages-separator⧽bogsa-gainmhich⧼tpt-languages-separator⧽cùisean deuchainn)
This module is currently protected from editing. See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected. |
This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module creates language name (key) to language tag (value) support tables used by Mòideal:Lang:
rev_lang_name_table
– data from Mòideal:Language/name/data particularly thelang
table which is assembled from data in Mòideal:Language/data/wp languages, Mòideal:Language/data/ISO 639-3, and Mòideal:Language/data/iana languages.rev_lang_data
– data from Mòideal:Lang/data particularly theoverride
table.
These reversed data tables are loaded and used by _tag_from_name()
.
--[[--------------------------< N A M E - T O - T A G D A T A >----------------------------------------------
Creates name-to-tag 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 tags from the same names as the {{lang}} templates get from those tags.
]]
local rev_lang_name_table = {}; -- same as Module:Language/name/data except reversed so language name is key and language tag is value
local rev_lang_data = {}; -- same as Module:Lang/data except reversed
local raw_data = mw.loadData ('Module:Language/name/data') -- load the data from the standard source module
for tag, name_table in pairs (raw_data.lang) do
local name = name_table[1]; -- there can be multiple names, always take the first name
name = name:gsub ('%s+%b()', ''):lower(); -- remove parenthetical disambiguators or qualifiers from names that have them
rev_lang_name_table[name] = tag; -- add language name (key) and tag (value) pair to the output table
end
raw_data = mw.loadData ('Module:Lang/data') -- load the data from the override source module
for tag, name_table in pairs (raw_data.override) do
local name = name_table[1]; -- there can be multiple names, always take the first name
name = name:gsub ('%s+%b()', ''):lower(); -- remove parenthetical disambiguators or qualifiers from names that have them
rev_lang_data[name] = tag; -- add language name (key) and tag (value) pair to the output table
end
raw_date = {}; -- init back to an empty table?
--[[--------------------------< 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,
}