<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.chaosvermittlung.de/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultilingual_description</id>
	<title>Module:Multilingual description - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.chaosvermittlung.de/index.php?action=history&amp;feed=atom&amp;title=Module%3AMultilingual_description"/>
	<link rel="alternate" type="text/html" href="https://wiki.chaosvermittlung.de/index.php?title=Module:Multilingual_description&amp;action=history"/>
	<updated>2026-04-14T22:09:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.chaosvermittlung.de/index.php?title=Module:Multilingual_description&amp;diff=764&amp;oldid=prev</id>
		<title>PhilmacFLy: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.chaosvermittlung.de/index.php?title=Module:Multilingual_description&amp;diff=764&amp;oldid=prev"/>
		<updated>2017-01-15T15:30:32Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local p = {}&lt;br /&gt;
&lt;br /&gt;
--[==[&lt;br /&gt;
  Remap some &amp;quot;valid&amp;quot; language codes that are still unknown, but are known by another code&lt;br /&gt;
  in order to get a visible language name (and if possible, BCP47 conformance)!&lt;br /&gt;
--]==]&lt;br /&gt;
local remappedLanguages = {&lt;br /&gt;
    [&amp;#039;als&amp;#039;] = &amp;#039;gsw&amp;#039;, -- legacy broken codes (but known) to changed new code (also known, but conforming to BCP47)&lt;br /&gt;
    [&amp;#039;bat-smg&amp;#039;] = &amp;#039;sgs&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;be-x-old&amp;#039;] = &amp;#039;be-tarask&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;bh&amp;#039;] = &amp;#039;bho&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;bu&amp;#039;] = &amp;#039;my&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;fiu-vro&amp;#039;] = &amp;#039;vro&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;nrm&amp;#039;] = &amp;#039;nrf&amp;#039;, -- same remark (usage of &amp;#039;nrm&amp;#039; on Wikimedia for Norman conflicts with the standard &amp;#039;nrm&amp;#039; which actually refers to an unrelated language)&lt;br /&gt;
    [&amp;#039;simple&amp;#039;] = &amp;#039;en&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;zh-classical&amp;#039;] = &amp;#039;lzh&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;zh-min-nan&amp;#039;] = &amp;#039;nan&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;zh-wuu&amp;#039;] = &amp;#039;wuu&amp;#039;, -- same remark&lt;br /&gt;
    [&amp;#039;zh-yue&amp;#039;] = &amp;#039;yue&amp;#039;, -- same remark&lt;br /&gt;
&lt;br /&gt;
    [&amp;#039;en-us&amp;#039;] = &amp;#039;en&amp;#039;, -- both codes are conforming and supported, only the second one is known&lt;br /&gt;
    [&amp;#039;fa-af&amp;#039;] = &amp;#039;fa&amp;#039;, -- both codes are conforming and supported, only the second one is known, actually means &amp;quot;Eastern Dari&amp;quot;&lt;br /&gt;
    [&amp;#039;fr-x-galo&amp;#039;] = &amp;#039;fr&amp;#039;, -- both codes are conforming and supported, only the second one is known&lt;br /&gt;
    [&amp;#039;ha-latn&amp;#039;] = &amp;#039;ha&amp;#039;, -- both codes are conforming and supported, only the second one is known, the Latin script is the default since the 1950&amp;#039;s.&lt;br /&gt;
    [&amp;#039;ha-arab&amp;#039;] = &amp;#039;ha&amp;#039;, -- both codes are conforming and supported, only the second one is known, the Arabic script is historic, without clear orthography&lt;br /&gt;
    [&amp;#039;ko-kr&amp;#039;] = &amp;#039;ko&amp;#039;, -- both codes are conforming and supported, only the second one is known&lt;br /&gt;
    [&amp;#039;ku-latn&amp;#039;] = &amp;#039;ku&amp;#039;, -- both codes are conforming and supported, only the second one is known, the Latin script is the default since the 1950&amp;#039;s.&lt;br /&gt;
    [&amp;#039;ku-cyrl&amp;#039;] = &amp;#039;ku&amp;#039;, -- both codes are conforming and supported, only the second one is known, the Cyrillic script is still used&lt;br /&gt;
    [&amp;#039;no&amp;#039;] = &amp;#039;nb&amp;#039;, -- both codes are conforming and supported, but the 1st one is now used only for meaning the second one in MediaWiki&lt;br /&gt;
    [&amp;#039;prd&amp;#039;] = &amp;#039;fa&amp;#039;, -- both codes are conforming and supported, only the second one is known, prd is &amp;quot;Parsi-Dari&amp;quot;&lt;br /&gt;
    [&amp;#039;tgl&amp;#039;] = &amp;#039;tl&amp;#039;, -- both codes are conforming and supported, only the second one is known&lt;br /&gt;
&lt;br /&gt;
    [&amp;#039;sr-cyrl&amp;#039;] = &amp;#039;sr-ec&amp;#039;, -- this alternate known code is non-standard and in fact not supported, but has a correct native name&lt;br /&gt;
    [&amp;#039;sr-latn&amp;#039;] = &amp;#039;sr-el&amp;#039;, -- same remark&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- kind is either &amp;#039;deprecated&amp;#039; or &amp;#039;unsupported&amp;#039;&lt;br /&gt;
local function addTracking(descriptions, kind)&lt;br /&gt;
    local categorize&lt;br /&gt;
    if kind == &amp;#039;deprecated&amp;#039; then&lt;br /&gt;
        categorize = &amp;#039; using deprecated language codes&amp;#039;&lt;br /&gt;
    else&lt;br /&gt;
        categorize = &amp;#039; using unsupported language codes&amp;#039;&lt;br /&gt;
    end&lt;br /&gt;
    table.insert(descriptions, &amp;#039;[[Category:Multilingual descriptions&amp;#039; .. categorize .. &amp;#039;]]&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local sortedKnownLanguageTags = require(&amp;#039;Module:Multilingual description/sort&amp;#039;)&lt;br /&gt;
local dir = require(&amp;#039;Module:Dir&amp;#039;).select&lt;br /&gt;
local function addDescription(descriptions, lang, description, update)&lt;br /&gt;
    if type(description) == &amp;#039;string&amp;#039; then&lt;br /&gt;
        description = mw.text.trim(description)&lt;br /&gt;
        if description:len() &amp;gt; 0 then&lt;br /&gt;
            table.insert(descriptions, mw.getCurrentFrame():expandTemplate{&lt;br /&gt;
                title = &amp;#039;Ls&amp;#039;,&lt;br /&gt;
                args = {&lt;br /&gt;
                    lang,&lt;br /&gt;
                    description,&lt;br /&gt;
                    dir = dir(lang, &amp;#039;rtl&amp;#039;, &amp;#039;ltr&amp;#039;),&lt;br /&gt;
                    classes = &amp;#039;description&amp;#039;,&lt;br /&gt;
                    update = update&lt;br /&gt;
                }&lt;br /&gt;
            })&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function _mld(args)&lt;br /&gt;
    -- Shallow copy of arguments (because keys in args cannot be unset if args is hollow, in a parent frame outside Lua)&lt;br /&gt;
    -- DO NOT copy the metatable that exposes only a *read-only* interface with accessors to PHP arrays (mw.clone does NOT work)!&lt;br /&gt;
    local descriptions = {}&lt;br /&gt;
    for lang, description in pairs(args) do&lt;br /&gt;
        if type(lang) == &amp;#039;string&amp;#039; and type(description) == &amp;#039;string&amp;#039; then&lt;br /&gt;
            -- MediaWiki trims the names of named argument and their values, but does not remove HTML comments in these names&lt;br /&gt;
            -- (some Mld contain parameters like &amp;quot;| sk &amp;lt;!--Slovensko--&amp;gt; = ...&amp;quot;)&lt;br /&gt;
            lang = lang:gsub(&amp;#039;&amp;lt;!%-%-.-%-%-&amp;gt;&amp;#039;, &amp;#039;&amp;#039;):gsub(&amp;#039;^%s*(.-)%s*$&amp;#039;,&amp;#039;%1&amp;#039;)&lt;br /&gt;
            descriptions[lang] = description&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    args = descriptions&lt;br /&gt;
    descriptions = {}&lt;br /&gt;
    local remapped = false&lt;br /&gt;
    for cur, alt in pairs(remappedLanguages) do&lt;br /&gt;
        if args[cur] and not(mw.language.isSupportedLanguage(cur) and mw.language.isKnownLanguageTag(cur))&lt;br /&gt;
                and (mw.language.isSupportedLanguage(alt) and mw.language.isKnownLanguageTag(alt)) then&lt;br /&gt;
            remapped = true&lt;br /&gt;
            if args[alt] == nil then -- only if this does not conflict&lt;br /&gt;
                args[alt] = args[cur] -- set key for alternate known language&lt;br /&gt;
            end&lt;br /&gt;
            args[cur] = nil -- unset the standard unknown key&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- First all known languages in order if they have description&lt;br /&gt;
    for _, lang in ipairs(sortedKnownLanguageTags) do&lt;br /&gt;
        if args[lang] ~= nil then&lt;br /&gt;
            addDescription(descriptions, lang, args[lang], nil)&lt;br /&gt;
            args[lang] = nil&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    -- Append other unknown languages, but only if they are supported&lt;br /&gt;
    local unsupported = false&lt;br /&gt;
    for lang, description in pairs(args) do&lt;br /&gt;
        if mw.language.isSupportedLanguage(lang) then&lt;br /&gt;
            addDescription(descriptions, lang, description, nil)&lt;br /&gt;
        else&lt;br /&gt;
            addDescription(descriptions, lang, description, lang)&lt;br /&gt;
            unsupported = true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    if remapped then&lt;br /&gt;
        addTracking(descriptions, &amp;#039;deprecated&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
    if unsupported then&lt;br /&gt;
        addTracking(descriptions, &amp;#039;unsupported&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
--mw.logObject(descriptions)&lt;br /&gt;
    return table.concat(descriptions)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.mld(frame)&lt;br /&gt;
    local args = (frame:getParent() or {}).args or {}&lt;br /&gt;
    return _mld(args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
setmetatable(p, {quickTests = function()&lt;br /&gt;
    local input = {&lt;br /&gt;
        [1] = &amp;#039;One?&amp;#039;, -- discarded&lt;br /&gt;
        unsupported = &amp;#039;What?&amp;#039;, -- unsupported&lt;br /&gt;
        en = &amp;#039; &amp;#039;, -- empty description after trimming (discarded)&lt;br /&gt;
        als = &amp;#039;GSW&amp;#039;, -- will be remapped&lt;br /&gt;
        [&amp;#039;en-gb&amp;#039;] = &amp;#039;EN-GB &amp;#039;, -- trimming at end&lt;br /&gt;
        [&amp;#039;en-ca&amp;#039;] = &amp;#039;EN-CA &amp;lt;nowiki/&amp;gt;&amp;#039;,&lt;br /&gt;
        de = &amp;#039; DE&amp;#039;, -- trimming at start&lt;br /&gt;
        fr = &amp;#039; FR &amp;#039;, -- trimming both ends&lt;br /&gt;
        rue = &amp;#039;RUE&amp;#039;,&lt;br /&gt;
        ru = &amp;#039;RU&amp;#039;,&lt;br /&gt;
        ko = &amp;#039;KO&amp;#039;,&lt;br /&gt;
        ja = &amp;#039;JA&amp;#039;,&lt;br /&gt;
        zh = &amp;#039;ZH&amp;#039;,&lt;br /&gt;
        he = &amp;#039;HE&amp;#039;,&lt;br /&gt;
        ur = &amp;#039;UR&amp;#039;,&lt;br /&gt;
        ar = &amp;#039;AR&amp;#039;,&lt;br /&gt;
        ro = &amp;#039;RO&amp;#039;,&lt;br /&gt;
        [&amp;#039;be-tarask&amp;#039;] = &amp;#039;BE-TARASK&amp;#039;,&lt;br /&gt;
        dv = &amp;#039;DV&amp;#039;,&lt;br /&gt;
    }&lt;br /&gt;
    local expect = {}&lt;br /&gt;
    --[=[&lt;br /&gt;
    This is the exact order to expect according to native language names,&lt;br /&gt;
    and after discarding empty descriptions or unsupported language codes.&lt;br /&gt;
    --]=]&lt;br /&gt;
    addDescription(expect, &amp;#039;gsw&amp;#039;, &amp;#039;GSW&amp;#039;) --[[Alemannisch]] -- remapped&lt;br /&gt;
    addDescription(expect, &amp;#039;en-gb&amp;#039;, &amp;#039;EN-GB&amp;#039;) --[[British English]]&lt;br /&gt;
    addDescription(expect, &amp;#039;en-ca&amp;#039;, &amp;#039;EN-CA &amp;lt;nowiki/&amp;gt;&amp;#039;) --[[Canadian English]]&lt;br /&gt;
    addDescription(expect, &amp;#039;de&amp;#039;, &amp;#039;DE&amp;#039;) --[[Deutsch]]&lt;br /&gt;
    addDescription(expect, &amp;#039;fr&amp;#039;, &amp;#039;FR&amp;#039;) --[[français]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ro&amp;#039;, &amp;#039;RO&amp;#039;) --[[română]]&lt;br /&gt;
    addDescription(expect, &amp;#039;be-tarask&amp;#039;, &amp;#039;BE-TARASK&amp;#039;) --[[беларуская (тарашкевіца)]]&lt;br /&gt;
    addDescription(expect, &amp;#039;rue&amp;#039;, &amp;#039;RUE&amp;#039;) --[[русиньскый]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ru&amp;#039;, &amp;#039;RU&amp;#039;) --[[русский]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ko&amp;#039;, &amp;#039;KO&amp;#039;) --[[한국어]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ja&amp;#039;, &amp;#039;JA&amp;#039;) --[[日本語]]&lt;br /&gt;
    addDescription(expect, &amp;#039;zh&amp;#039;, &amp;#039;ZH&amp;#039;) --[[中文]]&lt;br /&gt;
    addDescription(expect, &amp;#039;he&amp;#039;, &amp;#039;HE&amp;#039;) --[[עברית]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ur&amp;#039;, &amp;#039;UR&amp;#039;) --[[اردو]]&lt;br /&gt;
    addDescription(expect, &amp;#039;ar&amp;#039;, &amp;#039;AR&amp;#039;) --[[العربية]]&lt;br /&gt;
    addDescription(expect, &amp;#039;dv&amp;#039;, &amp;#039;DV&amp;#039;) --[[ދިވެހިބަސް]]&lt;br /&gt;
    addDescription(expect, &amp;#039;unsupported&amp;#039;, &amp;#039;What?&amp;#039;, &amp;#039;unsupported&amp;#039;)&lt;br /&gt;
    addTracking(expect, &amp;#039;deprecated&amp;#039;)&lt;br /&gt;
    addTracking(expect, &amp;#039;unsupported&amp;#039;)&lt;br /&gt;
    expect = table.concat(expect)&lt;br /&gt;
    local actual = _mld(input)&lt;br /&gt;
    if (actual ~= expect) then&lt;br /&gt;
        mw.log(&amp;#039;expect:\n&amp;#039; .. expect)&lt;br /&gt;
        mw.log(&amp;#039;actual:\n&amp;#039; .. actual)&lt;br /&gt;
        return false&lt;br /&gt;
    end&lt;br /&gt;
    return true&lt;br /&gt;
end})&lt;br /&gt;
--[==[ Type this to run tests in the Lua console:&lt;br /&gt;
=getmetatable(p).quickTests() -- should return true&lt;br /&gt;
--]==]&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>PhilmacFLy</name></author>
	</entry>
</feed>