Module:LangInfo

local data = mw.loadData('Module:LangInfo/data')

-- manually set Wikipedia link to a language's local " language" article; in case that differs from the language's endonym local wplinks = { ["bg"] = "Български език", ["zh"] = "汉语", ["da"] = "Dansk (sprog)", ["fi"] = "Suomen kieli", ["de"] = "Deutsche Sprache", ["hu"] = "Magyar nyelv", ["it"] = "Lingua italiana", ["lv"] = "Latviešu valoda", ["lt"] = "Lietuvių kalba", ["pl"] = "Język polski", ["pt"] = "Língua portuguesa", ["ru"] = "Русский язык", ["sk"] = "Slovenčina", ["es"] = "Idioma español", ["th"] = "ภาษาไทย", ["uk"] = "Українська мова", }

local trim = mw.text.trim local args_table

local getArg = function(key) local value = args_table[key] if not value then return nil end value = trim(value) if value == '' then return nil end return value end

- -- main return object return { go = function(frame, args) -- init cache args_table = args or frame.args

local _arg1 = getArg(1) or '' local _arg2 = getArg(2) or '' if _arg2 == 'name' then if data[_arg1]['shortname'] ~= '' then return data[_arg1]['shortname'] else return data[_arg1]['fullname'] end elseif _arg2 == 'wplink' and wplinks[_arg1] ~= nil then return wplinks[_arg1] elseif _arg2 == 'lname' or _arg2 == 'wplink' then return ( string.gsub(data[_arg1]['lname'], "(.-),.+", "%1") ) --only get first part of a comma-separated list elseif data[_arg1][_arg2] ~= '' then return data[_arg1][_arg2] else return '' end end

}