ATTENTION! The process of updating WiKi to version Eco 10.x has begun. Those wishing to participate can find out more Information on our ECO Contribution Wiki Discord.
From April 26 to May 12, errors may occur in the Wiki, as we will be carrying out a major update to the information processing modules.

Module:Localization: Difference between revisions

From Eco - English Wiki
[checked revision][unchecked revision]
(Created page with "return { words = { ['Tag'] = 'Tag' }, phrases = {} }")
 
No edit summary
Line 1: Line 1:
return {
local p = {}
   words = {
local Utils = require('Module:Utils')
     ['Tag'] = 'Tag'
 
   },
 
   phrases = {}
function p.t(msg, count)
}
   if count == nil then
     count=1
  end
 
  l = mw.loadData('Module:Localization/data')
 
  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)
  return t(args.msg, args.count)
end
 
 
return p

Revision as of 18:06, 28 February 2021

Documentation for this module may be created at Module:Localization/doc

local p = {}
local Utils = require('Module:Utils')


function p.t(msg, count)
  if count == nil then
    count=1
  end

  l = mw.loadData('Module:Localization/data')

  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)
  return t(args.msg, args.count)
end


return p