Modul:Multilingual: Unterschied zwischen den Versionen

2017-11-25
w>PerfektesChaos
(2017-11-24)
w>PerfektesChaos
(2017-11-25)
Zeile 1: Zeile 1:
local Multilingual = { suite  = "Multilingual",
local Multilingual = { suite  = "Multilingual",
                       serial = "2017-11-24" }
                       serial = "2017-11-25" }
 
 
 
-- local globals
local Frame




Zeile 232: Zeile 227:
                             if cnf  and
                             if cnf  and
                               type( cnf.getLink ) == "function" then
                               type( cnf.getLink ) == "function" then
                                 if not frame then
                                 if not Multilingual.frame then
                                     if not Frame then
                                     if frame then
                                         Frame = mw.getCurrentFrame()
                                         Multilingual.frame = frame
                                    else
                                        Multilingual.frame
                                                  = mw.getCurrentFrame()
                                     end
                                     end
                                    frame = Frame
                                 end
                                 end
                                 slot = cnf.getLink( slang, frame )
                                 slot = cnf.getLink( slang,
                                                    Multilingual.frame )
                                 if slot then
                                 if slot then
                                     local wlink = fetch( "WLink" )
                                     local wlink = fetch( "WLink" )
Zeile 264: Zeile 262:
                         .. mw.ustring.sub( r, 2 )
                         .. mw.ustring.sub( r, 2 )
                 elseif alter == "d" then
                 elseif alter == "d" then
                     if Multilingual.isMinusculable( slang or "" ) then
                     if Multilingual.isMinusculable( slang, r ) then
                         r = mw.ustring.lower( r )
                         r = mw.ustring.lower( r )
                     end
                     end
                 elseif alter == "m" then
                 elseif alter == "m" then
                     if Multilingual.isMinusculable( slang or "" ) then
                     if Multilingual.isMinusculable( slang, r ) then
                         r = mw.ustring.lower( mw.ustring.sub( r, 1, 1 ) )
                         r = mw.ustring.lower( mw.ustring.sub( r, 1, 1 ) )
                             .. mw.ustring.sub( r, 2 )
                             .. mw.ustring.sub( r, 2 )
Zeile 467: Zeile 465:
     -- Postcondition:
     -- Postcondition:
     --    Returns boolean
     --    Returns boolean
    local s = Multilingual.getBase( ask )
     local r
     local r
    local s = Multilingual.getBase( ask )
     if s then
     if s then
         r = mw.language.isKnownLanguageTag( s )
         r = mw.language.isKnownLanguageTag( s )
Zeile 497: Zeile 495:




Multilingual.isMinusculable = function ( ask )
Multilingual.isMinusculable = function ( ask, assigned )
     -- Could this language name become downcased?
     -- Could this language name become downcased?
     -- Precondition:
     -- Precondition:
     --    ask  -- language name
     --    ask       -- language code, or nil
    --    assigned -- language name, or nil
     -- Postcondition:
     -- Postcondition:
     --    Returns boolean
     --    Returns boolean
     local cnf = fetch( "Multilingual/config", true )
     local r  = true
    local r = true
    if ask then
    if cnf then
        local cnf = fetch( "Multilingual/config", true )
        local s = string.format( " %s ", ask:lower() )
        if cnf then
        if type( cnf.stopMinusculization ) == "string"
            local s = string.format( " %s ", ask:lower() )
          and  cnf.stopMinusculization:find( s, 1, true ) then
            if type( cnf.stopMinusculization ) == "string"
            r = false
              and  cnf.stopMinusculization:find( s, 1, true ) then
        end
        if r  and  type( cnf.seekMinusculization ) == "string"
          and  cnf.seekMinusculization:find( s, 1, true )
          and  type( cnf.scanMinusculization ) == "string" then
            local scan = ask:gsub( "[%(%)]", " " ) .. " "
            if not cnf.scanMinusculization:find( scan ) then
                 r = false
                 r = false
            end
            if r  and  assigned
              and  type( cnf.seekMinusculization ) == "string"
              and  cnf.seekMinusculization:find( s, 1, true )
              and  type( cnf.scanMinusculization ) == "string" then
                local scan = assigned:gsub( "[%(%)]", " " ) .. " "
                if not cnf.scanMinusculization:find( scan ) then
                    r = false
                end
             end
             end
         end
         end
Zeile 531: Zeile 533:
     -- Postcondition:
     -- Postcondition:
     --    Returns boolean
     --    Returns boolean
    local s = Multilingual.getBase( ask )
     local r
     local r
    local s = Multilingual.getBase( ask )
     if s then
     if s then
         local support = [=[ de als bar dsb frr gsw hsb ksh |
         local support = [=[ de als bar dsb frr gsw hsb ksh |
Zeile 558: Zeile 560:
     --    Returns string with appropriate code
     --    Returns string with appropriate code
     local r, slang, support
     local r, slang, support
     if not frame then
     if not Multilingual.frame then
         if not Frame then
         if frame then
             Frame = mw.getCurrentFrame()
             Multilingual.frame = frame
         end
        else
        frame = Frame
            Multilingual.frame = mw.getCurrentFrame()
         end      
     end
     end
     slang = frame:callParserFunction( "int", "lang" ):lower()
     slang = Multilingual.frame:callParserFunction( "int",
                                                  "lang" ):lower()
     if type( accept ) == "string" then
     if type( accept ) == "string" then
         support = accept:lower() .. " "
         support = accept:lower() .. " "
Anonymer Benutzer