Modul:Firestone/I18n
Die Dokumentation für dieses Modul kann unter Modul:Firestone/I18n/Doku erstellt werden
-- Modul:Firestone/I18n
-- sammelt alle I18n-Teile ein und merged sie zu EINER Tabelle
local M = {}
local cached
-- Reihenfolge ist wichtig: späteres überschreibt früheres
local PARTS = {
'Modul:Firestone/I18n/Core',
'Modul:Firestone/I18n/Events',
'Modul:Firestone/I18n/Events/Mini',
'Modul:Firestone/I18n/Events/Special',
'Modul:Firestone/I18n/Heroes',
'Modul:Firestone/I18n/Guardians',
'Modul:Firestone/I18n/WM',
}
local function loadPart(name)
local ok, data = pcall(mw.loadData, name)
if ok and type(data) == 'table' then
return data
end
ok, data = pcall(require, name)
if ok and type(data) == 'table' then
return data
end
return {}
end
-- rekursiv mergen: Tabellen werden zusammengeführt,
-- Skalare werden überschrieben
local function deepMerge(dst, src)
for k,v in pairs(src) do
if type(v) == 'table' then
if type(dst[k]) ~= 'table' then
dst[k] = {}
end
deepMerge(dst[k], v)
else
dst[k] = v
end
end
end
function M.get()
if cached then
return cached
end
-- Basis-Struktur wie früher
local root = {
i18n = {},
events = {
names = {},
sections = { default = {} },
phrases = {},
links = {},
unlocks = {},
group_labels = {},
infobox = {},
notice = {},
},
numbers = {},
items = {},
ui = {},
aw_desc = {},
}
for _,modname in ipairs(PARTS) do
local part = loadPart(modname)
deepMerge(root, part)
end
cached = root
return cached
end
return M