Modul:Multilingual: Unterschied zwischen den Versionen

2018-11-10
w>PerfektesChaos
(2018-04-16)
w>PerfektesChaos
(2018-11-10)
Zeile 1: Zeile 1:
local Multilingual = { suite  = "Multilingual",
local Multilingual = { suite  = "Multilingual",
                       serial = "2018-04-16",
                       serial = "2018-11-10",
                       item  = 47541920 }
                       item  = 47541920 }
local User = { sniffer = "publishchanges" }
local User = { sniffer = "publishchanges" }
Zeile 6: Zeile 6:




Multilingual.correct = { -- Frequently mistaken language code
      aze      = "az",
      cz        = "cs",
      dk        = "da",
      ["en-UK"] = "en-GB",
      ["en-uk"] = "en-GB",
      eng      = "en",
      ger      = "de",
      gr        = "el",
      ["in"]    = "id",
      iw        = "he",
      jp        = "ja",
      lat      = "la",
      se        = "sv"
    }
Multilingual.exotic = { simple = true,
Multilingual.exotic = { simple = true,
                         no    = true }
                         no    = true }
Zeile 236: Zeile 251:
     return r
     return r
end -- Multilingual.findCode()
end -- Multilingual.findCode()
Multilingual.fix = function ( attempt )
    -- Fix frequently mistaken language code
    -- Precondition:
    --    attempt  -- string, with presumable language code
    -- Postcondition:
    --    Returns string with corrction, or false if no problem known
    return Multilingual.correct[ attempt:lower() ]  or  false
end -- Multilingual.fix()




Zeile 583: Zeile 609:
     if s then
     if s then
         r = mw.language.isKnownLanguageTag( s )
         r = mw.language.isKnownLanguageTag( s )
         if not r  and  additional then
         if r then
            r = not Multilingual.fix( s )
        elseif additional then
             r = Multilingual.exotic[ s ] or false
             r = Multilingual.exotic[ s ] or false
         end
         end
Zeile 733: Zeile 761:
                 local vsn = entity:formatPropertyValues( "P348" )
                 local vsn = entity:formatPropertyValues( "P348" )
                 if type( vsn ) == "table"  and
                 if type( vsn ) == "table"  and
                   type( vsn.value) == "string" and
                   type( vsn.value ) == "string" and
                   vsn.value ~= "" then
                   vsn.value ~= "" then
                     r = vsn.value
                     r = vsn.value
Zeile 780: Zeile 808:
     return Multilingual.findCode( frame.args[ 1 ] )  or  ""
     return Multilingual.findCode( frame.args[ 1 ] )  or  ""
end -- p.findCode
end -- p.findCode
p.fix = function ( frame )
    local r = frame.args[ 1 ]
    if r then
        r = Multilingual.fix( mw.text.trim( r ) )
    end
    return r or ""
end -- p.fix




Anonymer Benutzer