Module:I18n
- English
- español
- 日本語
- Deutsch
- français
- 中文
- italiano
- português
- Nederlands
- العربية
- аԥсшәа
- Afrikaans
- Alemannisch
- الدارجة
- مصرى
- অসমীয়া
- asturianu
- Kotava
- تۆرکجه
- Basa Bali
- Bajau Sama
- беларуская (тарашкевіца)
- भोजपुरी
- ပအိုဝ်ႏဘာႏသာႏ
- বাংলা
- བོད་ཡིག
- bosanski
- буряад
- 閩東語 / Mìng-dĕ̤ng-ngṳ̄
- Cebuano
- کوردی
- corsu
- Cymraeg
- dagbanli
- dolnoserbski
- डोटेली
- ދިވެހިބަސް
- Ελληνικά
- Esperanto
- فارسی
- suomi
- Na Vosa Vakaviti
- Gaeilge
- galego
- ગુજરાતી
- Hausa
- 客家語 / Hak-kâ-ngî
- Hawaiʻi
- हिन्दी
- hrvatski
- hornjoserbsce
- magyar
- հայերեն
- interlingua
- Bahasa Indonesia
- Jawa
- ქართული
- Kumoring
- қазақша
- ಕನ್ನಡ
- 한국어
- kurdî
- Ladino
- Lëtzebuergesch
- Ligure
- Ladin
- lietuvių
- मैथिली
- Minangkabau
- македонски
- മലയാളം
- монгол
- ဘာသာမန်
- मराठी
- Bahasa Melayu
- Malti
- မြန်မာဘာသာ
- नेपाली
- norsk nynorsk
- Oromoo
- ଓଡ଼ିଆ
- ਪੰਜਾਬੀ
- Papiamentu
- پنجابی
- پښتو
- ikirundi
- română
- русиньскый
- Ikinyarwanda
- संस्कृतम्
- Scots
- سنڌي
- srpskohrvatski / српскохрватски
- တႆး
- සිංහල
- Simple English
- slovenščina
- anarâškielâ
- chiShona
- shqip
- српски / srpski
- svenska
- Sakizaya
- தமிழ்
- ತುಳು
- తెలుగు
- тоҷикӣ
- ไทย
- ትግርኛ
- Tagalog
- Türkçe
- татарча / tatarça
- українська
- اردو
- vèneto
- Tiếng Việt
- Winaray
- 吴语
- Yorùbá
- Vahcuengh
- 閩南語 / Bân-lâm-gí
- 粵語
List of subpagesList of subpages
- CommonsCoordinates
- CommonsCoordinates/doc
- complex date
- complex date/doc
- constraints
- constraints/doc
- datatype
- datatype/doc
- date
- date/doc
- doc
- itemdisplay
- itemdisplay/doc
- linguistic
- linguistic/doc
- or
- or/doc
- ordinal
- ordinal/doc
- property documentation
- property documentation/doc
- property proposal
- property proposal/doc
- taxobox
- taxobox/doc
- unknown
- unknown/doc
- wikidata
- wikidata/doc
Code
local p = {}
-- Credit to http://stackoverflow.com/a/1283608/2644759
-- cc-by-sa 3.0
local function tableMerge(t1, t2, overwrite)
for k,v in pairs(t2) do
if type(v) == "table" and type(t1[k]) == "table" then
-- since type(t1[k]) == type(v) == "table", so t1[k] and v is true
tableMerge(t1[k], v, overwrite) -- t2[k] == v
else
if overwrite or t1[k] == nil then t1[k] = v end
end
end
return t1
end
function p.loadI18n(name, i18n_arg)
local exist, res = pcall(require, name)
if exist and next(res) ~= nil then
if i18n_arg then
tableMerge(i18n_arg, res.i18n, true)
elseif type(i18n) == "table" then
-- merge to global i18n
tableMerge(i18n, res.i18n, true)
end
end
end
function p.loadI18nFrame(frame, i18n_arg)
p.loadI18n(frame:getTitle().."/i18n", i18n_arg)
end
local function missinginpage(page, lang)
if type(page) == 'string' then
page = require(page)
end
local list = {}
for i, j in pairs(page) do
if i ~= 'keys' and (not j[lang]) and not (j.default) and (not j.message) and (not j.item) then
table.insert(list, i)
end
end
if #list == 0 then
return "No translation missing for " .. lang .. '! '
else
return #list .. " translations missing in " .. lang .. ':\n* ' .. table.concat(list, '\n* ')
end
end
function p.pagedoc(frame)
local page = mw.title.getCurrentTitle().fullText
page = mw.text.split(page , '/')[1] .. '/' .. mw.text.split(page , '/')[2]
local lang = frame:preprocess("{{int:lang}}")
return missinginpage(page, lang)
end
return p