Nicht angemeldeter Benutzer - Bearbeiten von Seiten ist nur als angemeldeter Benutzer möglich.
Änderungen
Zur Navigation springen
Zur Suche springen
Zeile 1:
Zeile 1:
− +
Zeile 6:
Zeile 6:
−
−
−
− function fair( ask )
− -- Format language code according to BCP 47 / RFC 4646
− -- Precondition:
− -- ask -- language name, downcased
− -- Postcondition:
− -- nil, or string
− local r
− if ask:find( "-", 3, true ) then
− local parts = mw.text.split( ask, "-" )
− if parts[ 1 ]:match( "^%l%l%l?$" ) then
− local script = parts[ 2 ]
− r = parts[ 1 ]
− if script then
− local subA2 = parts[ 3 ]
− if script:match( "^%l%l%l%l$" ) then
− r = string.format( "%s-%s%s",
− r,
− script:sub( 1, 1 ):upper(),
− script:sub( 2 ) )
− else
− subA2 = script
− end
− if subA2 and subA2:match( "^%l%l$" ) then
− r = string.format( "%s-%s",
− r,
− subA2:upper() )
− end
− end
− end
− elseif ask:match( "^%l%l%l?$" ) then
− r = ask
− end
− return r
− end -- fair()
Zeile 110:
Zeile 73:
− +
Zeile 128:
Zeile 91:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 146:
Zeile 145:
− +
Zeile 311:
Zeile 310:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Zeile 331:
Zeile 410:
− +
− +
− +
+
Zeile 368:
Zeile 448:
− +
Zeile 525:
Zeile 605:
+
+
+
+
+
+
+
+
Zeile 640:
Zeile 728:
− +
Modul:Multilingual (Quelltext anzeigen)
Version vom 19. Oktober 2016, 11:36 Uhr
, 11:36, 19. Okt. 20162016-10-18
local Multilingual = { suite = "Multilingual",
local Multilingual = { suite = "Multilingual",
serial = "2016-06-18" }
serial = "2016-10-18" }
-- local globals
-- local globals
local Frame
local Frame
end -- for k, v
end -- for k, v
if not r then
if not r then
r = fair( ask )
r = Multilingual.fair( ask )
end
end
return r
return r
return supported:find( seek, 1, true )
return supported:find( seek, 1, true )
end -- isSupported()
end -- isSupported()
Multilingual.fair = function ( ask )
-- Format language specification according to RFC 5646 etc.
-- Precondition:
-- ask -- string or table, as created by .getLang()
-- Postcondition:
-- Returns string, or false
local s = type( ask )
local q, r
if s == "table" then
q = ask
elseif s == "string" then
q = Multilingual.getLang( ask )
end
if q and
q.legal and
mw.language.isKnownLanguageTag( q.base ) then
r = q.base
if q.n > 1 then
local order = { "extlang",
"region",
"script",
"other",
"extension" }
for i = 1, #order do
s = q[ order[ i ] ]
if s then
r = string.format( "%s-%s", r, s )
end
end -- for i
end
end
return r or false
end -- Multilingual.fair()
seek = mw.ustring.lower( seek )
seek = mw.ustring.lower( seek )
if Multilingual.isLang( seek ) then
if Multilingual.isLang( seek ) then
r = fair( seek )
r = Multilingual.fair( seek )
else
else
local slang = favorite()
local slang = favorite()
return r
return r
end -- Multilingual.getBase()
end -- Multilingual.getBase()
Multilingual.getLang = function ( ask )
-- Retrieve components of a RFC 5646 language code
-- Precondition:
-- ask -- language code with subtags
-- Postcondition:
-- Returns table with formatted subtags
-- .base
-- .region
-- .script
-- .year
-- .extension
-- .other
-- .n
local tags = mw.text.split( ask, "-" )
local s = tags[ 1 ]
local r
if s:match( "^%a%a%a?$" ) then
r = { base = s:lower(),
legal = true,
n = #tags }
for i = 2, r.n do
s = tags[ i ]
if #s == 2 then
if r.region or not s:match( "%a%a" ) then
r.legal = false
else
r.region = s:upper()
end
elseif #s == 4 then
if s:match( "%a%a%a%a" ) then
r.legal = ( not r.script )
r.script = s:sub( 1, 1 ):upper() ..
s:sub( 2 ):lower()
elseif s:match( "20%d%d" ) or
s:match( "1%d%d%d" ) then
r.legal = ( not r.year )
r.year = s
else
r.legal = false
end
elseif #s == 3 then
if r.extlang or not s:match( "%a%a%a" ) then
r.legal = false
else
r.extlang = s:lower()
end
elseif #s == 1 then
s = s:lower()
if s:match( "[tux]" ) then
r.extension = s
for k = i + 1, q.n do
s = tags[ k ]
if s:match( "^%w+$" ) then
r.extension = string.format( "%s-%s",
r.extension, s )
else
r.legal = false
end
end -- for k
else
r.legal = false
end
break -- for i
else
r.legal = ( not r.other ) and
s:match( "%a%a%a" )
r.other = s:lower()
end
if not r.legal then
break -- for i
end
end -- for i
else
r = { legal = false }
end
return r
end -- Multilingual.getLang()
if slang then
if slang then
if slang == "*" then
if slang == "*" then
slang = fair( ask )
slang = Multilingual.fair( ask )
elseif slang == "!" then
elseif slang == "!" then
slang = favorite()
slang = favorite()
else
else
slang = fair( slang )
slang = Multilingual.fair( slang )
end
end
else
else
slang = fair( ask )
slang = Multilingual.fair( ask )
end
end
if not slang then
if not slang then
slang = ask or "?????"
slang = ask or "?????"
end
end
slang = slang:lower()
tLang = fetch( support, true )
tLang = fetch( support, true )
if tLang then
if tLang then
end
end
if not r then
if not r then
r = mw.language.fetchLanguageName( ask, slang )
r = mw.language.fetchLanguageName( ask:lower(), slang )
if r == "" then
if r == "" then
r = false
r = false
-- Export
-- Export
local p = { }
local p = { }
p.fair = function ( frame )
-- Format language code
-- 1 -- language code
return Multilingual.fair( frame.args[ 1 ] ) or ""
end -- p.fair
end
end
end
end
return Multilingual.failsafe( since ) or ""
return Multilingual.failsafe( since ) or ""
end
end