Modul:Multilingual: Unterschied zwischen den Versionen
2018-12-25
w>PerfektesChaos (2018-12-22) |
w>PerfektesChaos (2018-12-25) |
||
| Zeile 1: | Zeile 1: | ||
local Multilingual = { suite = "Multilingual", | local Multilingual = { suite = "Multilingual", | ||
serial = "2018-12- | serial = "2018-12-25", | ||
item = 47541920 } | item = 47541920 } | ||
local User = { sniffer = "publishchanges" } | local User = { sniffer = "publishchanges" } | ||
| Zeile 58: | Zeile 58: | ||
local fetch = function ( access, allow ) | local fetch = function ( access, allow, ahead ) | ||
-- Attach config or library module | -- Attach config or library module | ||
-- Precondition: | -- Precondition: | ||
-- access -- module title | -- access -- module title | ||
-- allow -- permit non-existence | -- allow -- permit non-existence | ||
-- ahead -- name of startup procedure, if not access | |||
-- Postcondition: | -- Postcondition: | ||
-- Returns table or false, with library | -- Returns table or false, with library | ||
| Zeile 72: | Zeile 73: | ||
elseif not Multilingual.ext[ access ] then | elseif not Multilingual.ext[ access ] then | ||
local lucky, got = pcall( require, "Module:" .. access ) | local lucky, got = pcall( require, "Module:" .. access ) | ||
Multilingual.ext[ access ] = false | |||
if type( got ) == "table" then | |||
local startup = ahead or access | |||
Multilingual.ext[ access ] = got | |||
if type( got[ startup ] ) == "function" then | |||
Multilingual.ext[ access ] = got[ startup ]() | |||
end | end | ||
end | end | ||
if type( Multilingual.ext[ access ] ) ~= "table" | if type( Multilingual.ext[ access ] ) ~= "table" and | ||
not allow then | |||
got = string.format( "Module:%s invalid", access ) | |||
error( got, 0 ) | |||
end | end | ||
end | end | ||
| Zeile 581: | Zeile 579: | ||
return r | return r | ||
end -- Multilingual.getName() | end -- Multilingual.getName() | ||
Multilingual.getScriptName = function ( assigned, alien, add ) | |||
-- Retrieve script name, hopefully linked | |||
-- assigned -- string, with ISO 15924 script code | |||
-- alien -- string, with ISO language code, or not | |||
-- add -- arbitrary additional information | |||
-- Returns string | |||
local r = assigned | |||
local src = "Multilingual/scripting" | |||
if not Multilingual[ src ] then | |||
Multilingual[ src ] = fetch( src, true, "MultiScript" ) | |||
end | |||
if Multilingual[ src ] then | |||
r = Multilingual[ src ].Text.scriptName( assigned, alien, add ) | |||
end | |||
return r | |||
end -- Multilingual.getScriptName() | |||
| Zeile 891: | Zeile 908: | ||
return r or "" | return r or "" | ||
end -- p.getName | end -- p.getName | ||
p.getScriptName = function ( frame ) | |||
-- Retrieve script name from ISO 15924 script code, hopefully linked | |||
-- 1 -- code | |||
-- 2 -- optional additional key | |||
return Multilingual.getScriptName( frame.args[ 1 ] or "????", | |||
false, | |||
frame.args[ 2 ] ) | |||
end -- p.getScriptName | |||