Modul:Multilingual: Unterschied zwischen den Versionen

K
43 Versionen von wikivoyage:Modul:Multilingual importiert
w>PerfektesChaos
(2019-12-07)
K (43 Versionen von wikivoyage:Modul:Multilingual importiert)
 
(6 dazwischenliegende Versionen von 4 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
local Multilingual = { suite  = "Multilingual",
local Multilingual = { suite  = "Multilingual",
                       serial  = "2019-12-07",
                       serial  = "2020-12-10",
                       item    = 47541920,
                       item    = 47541920,
                       globals = { ISO15924 = 71584769,
                       globals = { ISO15924 = 71584769,
Zeile 40: Zeile 40:
Multilingual.exotic = { simple = true,
Multilingual.exotic = { simple = true,
                         no    = true }
                         no    = true }
Multilingual.prefer = { de = true,
Multilingual.prefer = { cs = true,
                        de = true,
                         en = true,
                         en = true,
                         es = true,
                         es = true,
Zeile 47: Zeile 48:
                         nl = true,
                         nl = true,
                         pt = true,
                         pt = true,
                         ru = true }
                         ru = true,
                        sv = true }




Zeile 61: Zeile 63:
     -- Postcondition:
     -- Postcondition:
     --    Returns whatever, probably table
     --    Returns whatever, probably table
     -- 2019-10-29
     -- 2020-01-01
     local storage = access
     local storage = access
     local finer = function ()
     local finer = function ()
Zeile 96: Zeile 98:
         end
         end
         if not lucky and alert then
         if not lucky and alert then
             error( "Missing or invalid page: " .. storage, 0 )
             error( "Missing or invalid page: " .. storage )
         end
         end
     end
     end
Zeile 113: Zeile 115:
     local r
     local r
     if type( storage ) == "string" then
     if type( storage ) == "string" then
        local s
         storage = mw.text.trim( storage )
         storage = mw.text.trim( storage )
         s = storage:lower()
         s = storage:lower()
Zeile 1.172: Zeile 1.175:




Multilingual.tabData = function ( access, alert, alt, frame )
Multilingual.tabData = function ( access, at, alt, frame )
     -- Retrieve translated keyword from commons:Data:****.tab
     -- Retrieve translated keyword from commons:Data:****.tab
     -- Precondition:
     -- Precondition:
     --    access  -- string, with page identification on Commons
     --    access  -- string, with page identification on Commons
     --    alert  -- string, with error keyword
     --    at      -- string, with keyword
     --    alt    -- string|nil|false, with fallback text
     --    alt    -- string|nil|false, with fallback text
     --    frame  -- frame, if available
     --    frame  -- frame, if available
     --    Returns
     --    Returns
     --        1. string|nil|false, with selected message
     --        1. string|nil|false, with selected message
     --        2. string|nil|false, with language code, or "error"
     --        2. language code, or "error"
     local data = fetchData( access )
     local data = fetchData( access )
     local r1, r2
     local r1, r2
     if  type( data ) == "table" then
     if  type( data ) == "table" then
         if type( alert ) == "string" then
         if type( at ) == "string" then
             local seek = mw.text.trim( alert )
             local seek = mw.text.trim( at )
             if seek == "" then
             if seek == "" then
                 r1 = "EMPTY Multilingual.tabData key"
                 r1 = "EMPTY Multilingual.tabData key"
Zeile 1.223: Zeile 1.226:
     elseif data then
     elseif data then
         r1, r2 = Multilingual.i18n( data, alt, frame )
         r1, r2 = Multilingual.i18n( data, alt, frame )
        r2 = r2 or "error"
     end
     end
     return r1, r2
     return r1, r2
Zeile 1.349: Zeile 1.353:
     -- Retrieve versioning and check for compliance
     -- Retrieve versioning and check for compliance
     -- Precondition:
     -- Precondition:
     --    atleast  -- string, with required version or "wikidata" or "~"
     --    atleast  -- string, with required version
     --                 or false
     --                         or wikidata|item|~|@ or false
     -- Postcondition:
     -- Postcondition:
     --    Returns  string  -- with queried version, also if problem
     --    Returns  string  -- with queried version/item, also if problem
     --              false  -- if appropriate
     --              false  -- if appropriate
     -- 2019-10-15
     -- 2020-08-17
    local last  = ( atleast == "~" )
     local since = atleast
     local since = atleast
    local last    = ( since == "~" )
    local linked  = ( since == "@" )
    local link    = ( since == "item" )
     local r
     local r
     if last  or  since == "wikidata" then
     if last or  link  or  linked or  since == "wikidata" then
         local item = Failsafe.item
         local item = Failsafe.item
         since = false
         since = false
         if type( item ) == "number"  and  item > 0 then
         if type( item ) == "number"  and  item > 0 then
             local entity = mw.wikibase.getEntity( string.format( "Q%d",
             local suited = string.format( "Q%d", item )
                                                                item ) )
            if link then
            if type( entity ) == "table" then
                r = suited
                local seek = Failsafe.serialProperty or "P348"
            else
                local vsn  = entity:formatPropertyValues( seek )
                local entity = mw.wikibase.getEntity( suited )
                if type( vsn ) == "table"  and
                if type( entity ) == "table" then
                  type( vsn.value ) == "string"  and
                    local seek = Failsafe.serialProperty or "P348"
                  vsn.value ~= "" then
                    local vsn  = entity:formatPropertyValues( seek )
                    if last  and  vsn.value == Failsafe.serial then
                    if type( vsn ) == "table"  and
                         r = false
                      type( vsn.value ) == "string"  and
                    else
                      vsn.value ~= "" then
                         r = vsn.value
                        if last  and  vsn.value == Failsafe.serial then
                            r = false
                         elseif linked then
                            if mw.title.getCurrentTitle().prefixedText
                              ==  mw.wikibase.getSitelink( suited ) then
                                r = false
                            else
                                r = suited
                            end
                         else
                            r = vsn.value
                        end
                     end
                     end
                 end
                 end
Zeile 1.610: Zeile 1.627:
     local seek  = frame.args[ 2 ]
     local seek  = frame.args[ 2 ]
     local salt  = frame.args.alt
     local salt  = frame.args.alt
     return Multilingual.tabData( suite, seek, salt, frame )
     local r    = Multilingual.tabData( suite, seek, salt, frame )
    return r
end -- p.tabData
end -- p.tabData