Module:User:Erutuon/04
Appearance
- The following documentation is located at Module:User:Erutuon/04/documentation. [edit]
- Useful links: root page • root page’s subpages • links • transclusions • testcases • sandbox
{
[1] = {
["code"] = "en",
["name"] = "English",
},
[2] = {
["code"] = "fr",
["name"] = "French",
},
[3] = {
["code"] = "de",
["name"] = "German",
},
[4] = {
["code"] = "ka",
["name"] = "Georgian",
},
[5] = {
["code"] = "ru",
["name"] = "Russian",
},
[6] = {
["code"] = "be",
["name"] = "Belarusian",
},
}
{
[1] = {
["code"] = "aa",
["name"] = "Afar",
},
[2] = {
["code"] = "ab",
["name"] = "Abkhaz",
},
[3] = {
["code"] = "ae",
["name"] = "Avestan",
},
[4] = {
["code"] = "af",
["name"] = "Afrikaans",
},
[5] = {
["code"] = "ak",
["name"] = "Akan",
},
[6] = {
["code"] = "am",
["name"] = "Amharic",
},
[7] = {
["code"] = "an",
["name"] = "Aragonese",
},
[8] = {
["code"] = "ar",
["name"] = "Arabic",
},
[9] = {
["code"] = "as",
["name"] = "Assamese",
},
[10] = {
["code"] = "av",
["name"] = "Avar",
},
[11] = {
["code"] = "ay",
["name"] = "Aymara",
},
[12] = {
["code"] = "az",
["name"] = "Azeri",
},
[13] = {
["code"] = "ba",
["name"] = "Bashkir",
},
[14] = {
["code"] = "be",
["name"] = "Belarusian",
},
[15] = {
["code"] = "bg",
["name"] = "Bulgarian",
},
[16] = {
["code"] = "bh",
["name"] = "Bihari",
},
[17] = {
["code"] = "bi",
["name"] = "Bislama",
},
[18] = {
["code"] = "bm",
["name"] = "Bambara",
},
[19] = {
["code"] = "bn",
["name"] = "Bengali",
},
[20] = {
["code"] = "bo",
["name"] = "Tibetan",
},
[21] = {
["code"] = "br",
["name"] = "Breton",
},
[22] = {
["code"] = "ca",
["name"] = "Catalan",
},
[23] = {
["code"] = "ce",
["name"] = "Chechen",
},
[24] = {
["code"] = "ch",
["name"] = "Chamorro",
},
[25] = {
["code"] = "co",
["name"] = "Corsican",
},
[26] = {
["code"] = "cr",
["name"] = "Cree",
},
[27] = {
["code"] = "cs",
["name"] = "Czech",
},
[28] = {
["code"] = "cu",
["name"] = "Old Church Slavonic",
},
[29] = {
["code"] = "cv",
["name"] = "Chuvash",
},
[30] = {
["code"] = "cy",
["name"] = "Welsh",
},
[31] = {
["code"] = "da",
["name"] = "Danish",
},
[32] = {
["code"] = "de",
["name"] = "German",
},
[33] = {
["code"] = "dv",
["name"] = "Dhivehi",
},
[34] = {
["code"] = "dz",
["name"] = "Dzongkha",
},
[35] = {
["code"] = "ee",
["name"] = "Ewe",
},
[36] = {
["code"] = "el",
["name"] = "Greek",
},
[37] = {
["code"] = "en",
["name"] = "English",
},
[38] = {
["code"] = "eo",
["name"] = "Esperanto",
},
[39] = {
["code"] = "es",
["name"] = "Spanish",
},
[40] = {
["code"] = "et",
["name"] = "Estonian",
},
[41] = {
["code"] = "eu",
["name"] = "Basque",
},
[42] = {
["code"] = "fa",
["name"] = "Persian",
},
[43] = {
["code"] = "ff",
["name"] = "Fula",
},
[44] = {
["code"] = "fi",
["name"] = "Finnish",
},
[45] = {
["code"] = "fj",
["name"] = "Fijian",
},
[46] = {
["code"] = "fo",
["name"] = "Faroese",
},
[47] = {
["code"] = "fr",
["name"] = "French",
},
[48] = {
["code"] = "fy",
["name"] = "West Frisian",
},
[49] = {
["code"] = "ga",
["name"] = "Irish",
},
[50] = {
["code"] = "gd",
["name"] = "Scottish Gaelic",
},
[51] = {
["code"] = "gl",
["name"] = "Galician",
},
[52] = {
["code"] = "gn",
["name"] = "Guaraní",
},
[53] = {
["code"] = "gu",
["name"] = "Gujarati",
},
[54] = {
["code"] = "gv",
["name"] = "Manx",
},
[55] = {
["code"] = "ha",
["name"] = "Hausa",
},
[56] = {
["code"] = "he",
["name"] = "Hebrew",
},
[57] = {
["code"] = "hi",
["name"] = "Hindi",
},
[58] = {
["code"] = "ho",
["name"] = "Hiri Motu",
},
[59] = {
["code"] = "ht",
["name"] = "Haitian Creole",
},
[60] = {
["code"] = "hu",
["name"] = "Hungarian",
},
[61] = {
["code"] = "hy",
["name"] = "Armenian",
},
[62] = {
["code"] = "hz",
["name"] = "Herero",
},
[63] = {
["code"] = "ia",
["name"] = "Interlingua",
},
[64] = {
["code"] = "id",
["name"] = "Indonesian",
},
[65] = {
["code"] = "ie",
["name"] = "Interlingue",
},
[66] = {
["code"] = "ig",
["name"] = "Igbo",
},
[67] = {
["code"] = "ii",
["name"] = "Sichuan Yi",
},
[68] = {
["code"] = "ik",
["name"] = "Inupiak",
},
[69] = {
["code"] = "io",
["name"] = "Ido",
},
[70] = {
["code"] = "is",
["name"] = "Icelandic",
},
[71] = {
["code"] = "it",
["name"] = "Italian",
},
[72] = {
["code"] = "iu",
["name"] = "Inuktitut",
},
[73] = {
["code"] = "ja",
["name"] = "Japanese",
},
[74] = {
["code"] = "jv",
["name"] = "Javanese",
},
[75] = {
["code"] = "ka",
["name"] = "Georgian",
},
[76] = {
["code"] = "kg",
["name"] = "Kongo",
},
[77] = {
["code"] = "ki",
["name"] = "Kikuyu",
},
[78] = {
["code"] = "kj",
["name"] = "Kwanyama",
},
[79] = {
["code"] = "kk",
["name"] = "Kazakh",
},
[80] = {
["code"] = "kl",
["name"] = "Greenlandic",
},
[81] = {
["code"] = "km",
["name"] = "Khmer",
},
[82] = {
["code"] = "kn",
["name"] = "Kannada",
},
[83] = {
["code"] = "ko",
["name"] = "Korean",
},
[84] = {
["code"] = "kr",
["name"] = "Kanuri",
},
[85] = {
["code"] = "ks",
["name"] = "Kashmiri",
},
[86] = {
["code"] = "ku",
["name"] = "Kurdish",
},
[87] = {
["code"] = "kw",
["name"] = "Cornish",
},
[88] = {
["code"] = "ky",
["name"] = "Kyrgyz",
},
[89] = {
["code"] = "la",
["name"] = "Latin",
},
[90] = {
["code"] = "lb",
["name"] = "Luxembourgish",
},
[91] = {
["code"] = "lg",
["name"] = "Luganda",
},
[92] = {
["code"] = "li",
["name"] = "Limburgish",
},
[93] = {
["code"] = "ln",
["name"] = "Lingala",
},
[94] = {
["code"] = "lo",
["name"] = "Lao",
},
[95] = {
["code"] = "lt",
["name"] = "Lithuanian",
},
[96] = {
["code"] = "lu",
["name"] = "Luba-Katanga",
},
[97] = {
["code"] = "lv",
["name"] = "Latvian",
},
[98] = {
["code"] = "mg",
["name"] = "Malagasy",
},
[99] = {
["code"] = "mh",
["name"] = "Marshallese",
},
[100] = {
["code"] = "mi",
["name"] = "Maori",
},
[101] = {
["code"] = "mk",
["name"] = "Macedonian",
},
[102] = {
["code"] = "ml",
["name"] = "Malayalam",
},
[103] = {
["code"] = "mn",
["name"] = "Mongolian",
},
[104] = {
["code"] = "mr",
["name"] = "Marathi",
},
[105] = {
["code"] = "ms",
["name"] = "Malay",
},
[106] = {
["code"] = "mt",
["name"] = "Maltese",
},
[107] = {
["code"] = "my",
["name"] = "Burmese",
},
[108] = {
["code"] = "na",
["name"] = "Nauruan",
},
[109] = {
["code"] = "nb",
["name"] = "Norwegian Bokmål",
},
[110] = {
["code"] = "nd",
["name"] = "Northern Ndebele",
},
[111] = {
["code"] = "ne",
["name"] = "Nepali",
},
[112] = {
["code"] = "ng",
["name"] = "Ndonga",
},
[113] = {
["code"] = "nl",
["name"] = "Dutch",
},
[114] = {
["code"] = "nn",
["name"] = "Norwegian Nynorsk",
},
[115] = {
["code"] = "no",
["name"] = "Norwegian",
},
[116] = {
["code"] = "nr",
["name"] = "Southern Ndebele",
},
[117] = {
["code"] = "nv",
["name"] = "Navajo",
},
[118] = {
["code"] = "ny",
["name"] = "Chichewa",
},
[119] = {
["code"] = "oc",
["name"] = "Occitan",
},
[120] = {
["code"] = "oj",
["name"] = "Ojibwe",
},
[121] = {
["code"] = "om",
["name"] = "Oromo",
},
[122] = {
["code"] = "or",
["name"] = "Odia",
},
[123] = {
["code"] = "os",
["name"] = "Ossetian",
},
[124] = {
["code"] = "pa",
["name"] = "Punjabi",
},
[125] = {
["code"] = "pi",
["name"] = "Pali",
},
[126] = {
["code"] = "pl",
["name"] = "Polish",
},
[127] = {
["code"] = "ps",
["name"] = "Pashto",
},
[128] = {
["code"] = "pt",
["name"] = "Portuguese",
},
[129] = {
["code"] = "qu",
["name"] = "Quechua",
},
[130] = {
["code"] = "rm",
["name"] = "Romansch",
},
[131] = {
["code"] = "ro",
["name"] = "Romanian",
},
[132] = {
["code"] = "ru",
["name"] = "Russian",
},
[133] = {
["code"] = "rw",
["name"] = "Rwanda-Rundi",
},
[134] = {
["code"] = "sa",
["name"] = "Sanskrit",
},
[135] = {
["code"] = "sc",
["name"] = "Sardinian",
},
[136] = {
["code"] = "sd",
["name"] = "Sindhi",
},
[137] = {
["code"] = "se",
["name"] = "Northern Sami",
},
[138] = {
["code"] = "sg",
["name"] = "Sango",
},
[139] = {
["code"] = "sh",
["name"] = "Serbo-Croatian",
},
[140] = {
["code"] = "si",
["name"] = "Sinhalese",
},
[141] = {
["code"] = "sk",
["name"] = "Slovak",
},
[142] = {
["code"] = "sl",
["name"] = "Slovene",
},
[143] = {
["code"] = "sm",
["name"] = "Samoan",
},
[144] = {
["code"] = "sn",
["name"] = "Shona",
},
[145] = {
["code"] = "so",
["name"] = "Somali",
},
[146] = {
["code"] = "sq",
["name"] = "Albanian",
},
[147] = {
["code"] = "ss",
["name"] = "Swazi",
},
[148] = {
["code"] = "st",
["name"] = "Sotho",
},
[149] = {
["code"] = "su",
["name"] = "Sundanese",
},
[150] = {
["code"] = "sv",
["name"] = "Swedish",
},
[151] = {
["code"] = "sw",
["name"] = "Swahili",
},
[152] = {
["code"] = "ta",
["name"] = "Tamil",
},
[153] = {
["code"] = "te",
["name"] = "Telugu",
},
[154] = {
["code"] = "tg",
["name"] = "Tajik",
},
[155] = {
["code"] = "th",
["name"] = "Thai",
},
[156] = {
["code"] = "ti",
["name"] = "Tigrinya",
},
[157] = {
["code"] = "tk",
["name"] = "Turkmen",
},
[158] = {
["code"] = "tl",
["name"] = "Tagalog",
},
[159] = {
["code"] = "tn",
["name"] = "Tswana",
},
[160] = {
["code"] = "to",
["name"] = "Tongan",
},
[161] = {
["code"] = "tr",
["name"] = "Turkish",
},
[162] = {
["code"] = "ts",
["name"] = "Tsonga",
},
[163] = {
["code"] = "tt",
["name"] = "Tatar",
},
[164] = {
["code"] = "ty",
["name"] = "Tahitian",
},
[165] = {
["code"] = "ug",
["name"] = "Uyghur",
},
[166] = {
["code"] = "uk",
["name"] = "Ukrainian",
},
[167] = {
["code"] = "ur",
["name"] = "Urdu",
},
[168] = {
["code"] = "uz",
["name"] = "Uzbek",
},
[169] = {
["code"] = "ve",
["name"] = "Venda",
},
[170] = {
["code"] = "vi",
["name"] = "Vietnamese",
},
[171] = {
["code"] = "vo",
["name"] = "Volapük",
},
[172] = {
["code"] = "wa",
["name"] = "Walloon",
},
[173] = {
["code"] = "wo",
["name"] = "Wolof",
},
[174] = {
["code"] = "xh",
["name"] = "Xhosa",
},
[175] = {
["code"] = "yi",
["name"] = "Yiddish",
},
[176] = {
["code"] = "yo",
["name"] = "Yoruba",
},
[177] = {
["code"] = "za",
["name"] = "Zhuang",
},
[178] = {
["code"] = "zh",
["name"] = "Chinese",
},
[179] = {
["code"] = "zu",
["name"] = "Zulu",
},
}
local export = {}
local dump = require("Module:debug").highlight_dump
local languageData = require("Module:User:Erutuon/04/data")
local function dumbSearch(t, item, func)
local useFunc = type(func) == "function"
for i, val in ipairs(t) do
if useFunc and func(val) == item or val == item then
return i
end
end
return nil
end
--[[]
Does a binary search in a table.
The table of functions can contain three functions:
-- getCompVal, which is applied to the table entry to get the value to be
compared against the value that is being searched for;
-- comp, which returns true when the value being searched for is less than
(that is, will be found at a lower index in the table than) the table
value currently being looked at;
-- equals, which returns true when the value being searched for is equal to
the current table value being looked at (and hence should be returned by
the search function).
]]
function export.binarySearch(t, value, functions)
if functions == nil then
functions = {}
end
-- Initialize functions.
-- Function that returns value used to compare.
local getCompVal = functions.getCompVal or function(x) return x end
-- Function that compares the two values.
local comp = functions.comp or function(x, y) return x < y end
-- Function that returns true when correct index is found.
local equals = functions.equals or function(x, y) return x == y end
-- Initialize numbers.
local iStart, iMid = 1, 0
local iEnd = next(t) and #t or require("Module:table").size(t)
if iEnd == 0 then
return nil
end
local iterations = 0
-- Do search.
while iStart <= iEnd do
iterations = iterations + 1
-- Calculate middle.
iMid = math.floor((iStart + iEnd) / 2)
-- Get compare value.
local value2 = getCompVal(t[iMid])
-- Return matching index. Assumes there are no duplicates.
if equals(value, value2) then
return iMid, iterations
-- Keep searching.
elseif comp(value, value2) then
iEnd = iMid - 1
else
iStart = iMid + 1
end
end
return nil, iterations
end
local function comp(item1, item2)
local type1, type2 = type(item1), type(item2)
if type1 ~= type2 then
return type1 < type2
else
return item1 < item2
end
end
local function getCode(val)
if type(val) == "table" then
return val.code
else
return val
end
end
local function getLanguageData(code)
local i = export.binarySearch(
languageData,
code,
{ getCompVal = getCode, comp = comp }
)
if i then
return languageData[i]
else
error("No data for code " .. code .. ".")
end
end
local function forEach(t, func)
for i, val in ipairs(t) do
func(val)
end
end
function export.show(frame)
local codes = setmetatable({ "en", "fr", "de", "ka", "ru", "be" }, { __index = { forEach = forEach } })
local found = {}
codes:forEach(
function(item)
table.insert(found, getLanguageData(item))
end
)
return dump(found) .. dump(languageData)
end
return export