Modul:Multilingual: Unterschied zwischen den Versionen
2019-01-01
w>PerfektesChaos (2018-12-27) |
w>PerfektesChaos (2019-01-01) |
||
| Zeile 1: | Zeile 1: | ||
local Multilingual = { suite = "Multilingual", | local Multilingual = { suite = "Multilingual", | ||
serial = " | serial = "2019-01-01", | ||
item = 47541920 } | item = 47541920 } | ||
local User = { sniffer = "publishchanges" } | local User = { sniffer = "publishchanges" } | ||
| Zeile 20: | Zeile 20: | ||
jp = "ja", | jp = "ja", | ||
lat = "la", | lat = "la", | ||
se = "sv" | se = "sv", | ||
tj = "tg" | |||
} | } | ||
Multilingual.exotic = { simple = true, | Multilingual.exotic = { simple = true, | ||
| Zeile 96: | Zeile 97: | ||
return Multilingual.ext[ access ] | return Multilingual.ext[ access ] | ||
end -- fetch() | end -- fetch() | ||
local function fill( access, alien, frame ) | |||
-- Expand language name template | |||
-- access -- string, with language code | |||
-- alien -- language code for which to be generated | |||
-- frame -- frame, if available | |||
-- Returns string | |||
local template = Multilingual.tmplLang | |||
local r | |||
if type( template ) ~= "table" then | |||
local cnf = fetch( "Multilingual/config", true ) | |||
if type( cnf ) == "table" then | |||
template = cnf.tmplLang | |||
end | |||
end | |||
if type( template ) == "table" then | |||
local source = template.title | |||
local f, lucky, s | |||
Multilingual.tmplLang = template | |||
if type( source ) ~= "string" then | |||
if type( template.namePat ) == "string" and | |||
template.namePat:find( "%s", 1, true ) then | |||
source = string.format( template.namePat, access ) | |||
end | |||
end | |||
if type( source ) == "string" then | |||
if not Multilingual.frame then | |||
if frame then | |||
Multilingual.frame = frame | |||
else | |||
Multilingual.frame = mw.getCurrentFrame() | |||
end | |||
end | |||
f = function ( a ) | |||
return Multilingual.frame:expandTemplate{ title = a } | |||
end | |||
lucky, s = pcall( f, source ) | |||
if lucky then | |||
r = s | |||
end | |||
end | |||
end | |||
return r | |||
end -- fill() | |||
| Zeile 340: | Zeile 387: | ||
r = Multilingual.getName( slang, alien ) | r = Multilingual.getName( slang, alien ) | ||
if active then | if active then | ||
slot = fill( slang, false, frame ) | |||
if slot then | |||
local wlink = fetch( "WLink" ) | |||
slot = wlink.getTarget( slot ) | |||
else | |||
lapsus = alert | |||
end | end | ||
end | end | ||
| Zeile 947: | Zeile 980: | ||
local slang = frame.args[ 2 ] | local slang = frame.args[ 2 ] | ||
local r | local r | ||
Multilingual.frame = frame | |||
if slang then | if slang then | ||
slang = mw.text.trim( slang ) | slang = mw.text.trim( slang ) | ||