Added locale number formatting to locale files

This commit is contained in:
TheSumm 2015-01-20 16:18:04 +01:00
parent b5cea41f87
commit 596717bf32
7 changed files with 34 additions and 6 deletions

View File

@ -4,6 +4,10 @@ locale = {
charset = "cp1252", charset = "cp1252",
languageName = "Deutsch", languageName = "Deutsch",
formatNumbers = true,
decimalSeperator = ',',
thousandsSeperator = ' ',
translation = { translation = {
["1a) Offensive Name"] = false, ["1a) Offensive Name"] = false,
["1b) Invalid Name Format"] = false, ["1b) Invalid Name Format"] = false,

View File

@ -3,6 +3,10 @@ locale = {
charset = "cp1252", charset = "cp1252",
languageName = "English", languageName = "English",
formatNumbers = true,
decimalSeperator = '.',
thousandsSeperator = ',',
-- translations are not needed because everything is already in english -- translations are not needed because everything is already in english
translation = {} translation = {}
} }

View File

@ -7,6 +7,10 @@ locale = {
charset = "cp1252", charset = "cp1252",
languageName = "Español", languageName = "Español",
formatNumbers = true,
decimalSeperator = ',',
thousandsSeperator = '.',
translation = { translation = {
["1a) Offensive Name"] = "1a) Nombre ofensivo", ["1a) Offensive Name"] = "1a) Nombre ofensivo",
["1b) Invalid Name Format"] = "1b) Formato invalido para nombre", ["1b) Invalid Name Format"] = "1b) Formato invalido para nombre",

View File

@ -2,6 +2,10 @@ locale = {
name = "pl", name = "pl",
languageName = "Polski", languageName = "Polski",
formatNumbers = true,
decimalSeperator = '.',
thousandsSeperator = ' ',
translation = { translation = {
["1a) Offensive Name"] = "1a) Obrazliwe Imie", ["1a) Offensive Name"] = "1a) Obrazliwe Imie",
["1b) Invalid Name Format"] = "1b) Niepoprawny Format Imienia", ["1b) Invalid Name Format"] = "1b) Niepoprawny Format Imienia",

View File

@ -3,6 +3,10 @@ locale = {
charset = "cp1252", charset = "cp1252",
languageName = "Português", languageName = "Português",
formatNumbers = true,
decimalSeperator = ',',
thousandsSeperator = '.',
-- As traduções devem vir sempre em ordem alfabética. -- As traduções devem vir sempre em ordem alfabética.
translation = { translation = {
["%d of experience per hour"] = "%d de experiência por hora", ["%d of experience per hour"] = "%d de experiência por hora",

View File

@ -5,6 +5,10 @@ locale = {
charset = "cp1252", charset = "cp1252",
languageName = "Svenska", languageName = "Svenska",
formatNumbers = true,
decimalSeperator = ',',
thousandsSeperator = ' ',
translation = { translation = {
["1a) Offensive Name"] = "1a) Offensivt Namn", ["1a) Offensive Name"] = "1a) Offensivt Namn",
["1b) Invalid Name Format"] = "1b) Ogiltigt Namnformat", ["1b) Invalid Name Format"] = "1b) Ogiltigt Namnformat",

View File

@ -166,16 +166,20 @@ end
-- global function used to translate texts -- global function used to translate texts
function _G.tr(text, ...) function _G.tr(text, ...)
if currentLocale then if currentLocale then
if tonumber(text) then if tonumber(text) and currentLocale.formatNumbers then
-- todo: use locale information to calculate this. also detect floating numbers local number = tostring(text):split('.')
local out = '' local out = ''
local number = tostring(text):reverse() local reverseNumber = number[1]:reverse()
for i=1,#number do for i=1,#reverseNumber do
out = out .. number:sub(i, i) out = out .. reverseNumber:sub(i, i)
if i % 3 == 0 and i ~= #number then if i % 3 == 0 and i ~= #number then
out = out .. ',' out = out .. currentLocale.thousandsSeperator
end end
end end
if number[2] then
out = number[2] .. currentLocale.decimalSeperator .. out
end
return out:reverse() return out:reverse()
elseif tostring(text) then elseif tostring(text) then
local translation = currentLocale.translation[text] local translation = currentLocale.translation[text]