Module:ChartFieldTitles
Lua
Documentation for this module may be created at Module:ChartFieldTitles/doc
Code
-- Module:ChartFieldTitles (name it whatever fits your conventions)
local TabUtils = require('Module:TabUtils')
-- Field-name → extra title translations. Only fills in languages
-- that aren't already set on the .tab file, so nothing gets overwritten.
local fieldTitles = {
populatie = {
eu = 'Biztanleria',
es = 'Población',
fr = 'Population',
en = 'Population',
it = 'Popolazione',
de = 'Bevölkerung',
pt = 'População',
ca = 'Població',
gl = 'Poboación',
nl = 'Bevolking',
pl = 'Ludność',
cs = 'Obyvatelstvo',
sv = 'Befolkning',
da = 'Befolkning',
nb = 'Befolkning',
fi = 'Väestö',
hu = 'Népesség',
el = 'Πληθυσμός',
ru = 'Население',
ja = '人口',
zh = '人口',
ro = 'Populație', -- native language of this dataset, kept as a fallback
},
an = {
eu = 'Urtea',
es = 'Año',
fr = 'Année',
en = 'Year',
it = 'Anno',
de = 'Jahr',
pt = 'Ano',
ca = 'Any',
gl = 'Ano',
nl = 'Jaar',
pl = 'Rok',
cs = 'Rok',
sv = 'År',
da = 'År',
nb = 'År',
fi = 'Vuosi',
hu = 'Év',
el = 'Έτος',
ru = 'Год',
ja = '年',
zh = '年',
ro = 'An',
},
}
local p = {}
function p.select(tab, args)
tab = TabUtils.select(tab, args)
for _, field in ipairs(tab.schema.fields) do
local extra = fieldTitles[field.name]
if extra then
field.title = field.title or {}
for lang, label in pairs(extra) do
if not field.title[lang] then
field.title[lang] = label
end
end
end
end
return tab
end
return p