Module:Localization: Difference between revisions
From Eco - English Wiki
[checked revision] | [checked revision] |
No edit summary |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
end | end | ||
l = mw.loadData('Module: | l = mw.loadData('Module:LocalizationData') | ||
local msgs = l.msgs[msg] | local msgs = l.msgs[msg] | ||
Line 24: | Line 24: | ||
return lang:plural(count, msgs) | return lang:plural(count, msgs) | ||
end | end | ||
end | end | ||
Latest revision as of 10:55, 27 June 2024
local p = {}
local Utils = require('Module:Utils')
function p.t(msg, count)
if count == nil then
count=1
end
l = mw.loadData('Module:LocalizationData')
local msgs = l.msgs[msg]
if msgs == nil then
mw.log('WARNING: Word not translated: ' .. msg)
return msg
end
if count==1 or Utils.tableLen(msgs) == 1 then
return msgs[1]
else
-- Pluralise
local lang = mw.getContentLanguage()
return lang:plural(count, msgs)
end
end
function p.translate(frame)
local args = Utils.normaliseArgs(frame)
local msg = args.msg or args[1]
local count = tonumber(args.count or args[2])
return p.t(msg, count)
end
return p