mirror of
https://github.com/edubart/otclient.git
synced 2025-10-16 12:34:55 +02:00
more locales changes
This commit is contained in:
@@ -5,20 +5,11 @@ local defaultLocaleName = 'en-us'
|
||||
local installedLocales
|
||||
local currentLocale
|
||||
|
||||
-- hooked functions
|
||||
function UIWidget:onTextChange(text, oldText)
|
||||
local translation = tr(text)
|
||||
if translation ~= text then
|
||||
self:setText(translation)
|
||||
end
|
||||
end
|
||||
|
||||
-- public functions
|
||||
function Locales.init()
|
||||
installedLocales = {}
|
||||
|
||||
dofile('en-us')
|
||||
dofile('pt-br')
|
||||
Locales.installLocales('locales')
|
||||
|
||||
local userLocaleName = Settings.get('locale')
|
||||
if not userLocaleName or not Locales.setLocale(userLocaleName) then
|
||||
@@ -30,7 +21,7 @@ function Locales.init()
|
||||
Settings.set('locale', defaultLocaleName)
|
||||
end
|
||||
|
||||
-- create combobox
|
||||
-- add event for creating combobox
|
||||
--for key,value in pairs(installedLocales) do
|
||||
-- add elements
|
||||
--end
|
||||
@@ -52,7 +43,21 @@ function Locales.installLocale(locale)
|
||||
return false
|
||||
end
|
||||
|
||||
installedLocales[locale.name] = locale
|
||||
local installedLocale = installedLocales[locale.name]
|
||||
if installedLocale then
|
||||
-- combine translations replacing with new if already exists
|
||||
for word,translation in pairs(locale.translation) do
|
||||
installedLocale.translation[word] = translation
|
||||
end
|
||||
else
|
||||
installedLocales[locale.name] = locale
|
||||
|
||||
-- update combobox
|
||||
end
|
||||
end
|
||||
|
||||
function Locales.installLocales(directory)
|
||||
dofiles(directory)
|
||||
end
|
||||
|
||||
function Locales.setLocale(name)
|
||||
@@ -69,11 +74,22 @@ end
|
||||
function tr(text, ...)
|
||||
if currentLocale then
|
||||
if tonumber(text) then
|
||||
-- todo: add some dots etc
|
||||
-- todo: use locale information to calculate this. also detect floating numbers
|
||||
local out = ''
|
||||
local number = tostring(text):reverse()
|
||||
for i=1,#number do
|
||||
out = out .. number:sub(i, i)
|
||||
if i % 3 == 0 and i ~= #number then
|
||||
out = out .. ','
|
||||
end
|
||||
end
|
||||
return out:reverse()
|
||||
elseif tostring(text) then
|
||||
local translation = currentLocale.translation[text]
|
||||
if translation then
|
||||
return string.format(translation, ...)
|
||||
elseif currentLocale.name ~= defaultLocaleName then
|
||||
print('WARNING: \"' .. text .. '\" could not be translated.')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
26
modules/client_locales/locales/pt-br.lua
Normal file
26
modules/client_locales/locales/pt-br.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
locale = {
|
||||
name = 'pt-br',
|
||||
|
||||
-- As tradu<64><75>es devem vir sempre em ordem alfab<61>tica.
|
||||
translation = {
|
||||
['Account name'] = 'Nome da conta',
|
||||
['Account Status:\nFree Account'] = 'Estado da Conta:\nGr<EFBFBD>tis',
|
||||
['Auto login'] = 'Entrar automaticamente',
|
||||
['Cancel'] = 'Cancelar',
|
||||
['Character List'] = 'Lista de Personagens',
|
||||
['Enter Game'] = 'Entrar no Jogo',
|
||||
['Make sure that your client uses\nthe correct game protocol version'] = 'Tenha certeza de que o cliente usa\na vers<72>o correta do protocolo do jogo',
|
||||
['Ok'] = 'Ok',
|
||||
['Open charlist automatically when starting otclient'] = 'Abrir a lista de personagens automaticamente ao iniciar o otclient',
|
||||
['Options'] = 'Op<EFBFBD><EFBFBD>es',
|
||||
['Password'] = 'Senha',
|
||||
['Port'] = 'Porta',
|
||||
['Remember account and password when starts otclient'] = 'Lembrar conta e senha ao iniciar o otclient',
|
||||
['Remember password'] = 'Lembrar senha',
|
||||
['Server'] = 'Servidor'
|
||||
}
|
||||
|
||||
-- Adicionar informa<6D><61>es de n<>meros. 1.000 100,00 1.000,00 etc.
|
||||
}
|
||||
|
||||
Locales.installLocale(locale)
|
@@ -1,20 +0,0 @@
|
||||
locale = {
|
||||
name = 'pt-br',
|
||||
|
||||
-- As tradu<64><75>es devem vir sempre em ordem alfab<61>tica.
|
||||
translation = {
|
||||
['Account name'] = 'Nome da conta',
|
||||
['Auto login'] = 'Entrar automaticamente',
|
||||
['Cancel'] = 'Cancelar',
|
||||
['Enter Game'] = 'Entrar no Jogo',
|
||||
['Options'] = 'Op<EFBFBD><EFBFBD>es',
|
||||
['Password'] = 'Senha',
|
||||
['Port'] = 'Porta',
|
||||
['Remember password'] = 'Lembrar senha',
|
||||
['Server'] = 'Servidor'
|
||||
}
|
||||
|
||||
-- Adicionar informa<6D><61>es de n<>meros. 1.000 100,00 1.000,00 etc.
|
||||
}
|
||||
|
||||
Locales.installLocale(locale)
|
Reference in New Issue
Block a user