more locales changes

master
Henrique Santiago 12 years ago
parent fae2cc6481
commit ca0e1bd38b

@ -10,7 +10,7 @@ CharacterListLabel < Label
MainWindow
id: charactersWindow
text: Character List
!text: tr('Character List')
size: 250 248
@onEnter: CharacterList.doLogin()
@onEscape: CharacterList.destroy()
@ -34,9 +34,7 @@ MainWindow
Label
id: accountStatusLabel
text: |-
Account Status:
Free Account
!text: tr('Account Status:\nFree Account')
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: separator.top
@ -52,7 +50,7 @@ MainWindow
//CheckBox
// id: charAutoLoginBox
// text: Auto login
// !text: tr('Auto login')
// tooltip: Auto login selected character on next charlist load
// anchors.left: parent.left
// anchors.right: parent.right
@ -63,7 +61,7 @@ MainWindow
Button
id: buttonOk
text: Ok
!text: tr('Ok')
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
@ -72,7 +70,7 @@ MainWindow
Button
id: buttonCancel
text: Cancel
!text: tr('Cancel')
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom

@ -1,12 +1,12 @@
MainWindow
id: enterGame
text: Enter Game
!text: tr('Enter Game')
size: 236 240
@onEnter: EnterGame.doLogin()
@onEscape: EnterGame.hide()
Label
text: Account name
!text: tr('Account name')
anchors.left: parent.left
anchors.top: parent.top
text-auto-resize: true
@ -19,7 +19,7 @@ MainWindow
margin-top: 2
Label
text: Password
!text: tr('Password')
anchors.left: prev.left
anchors.top: prev.bottom
margin-top: 8
@ -34,7 +34,7 @@ MainWindow
Label
id: serverLabel
text: Server
!text: tr('Server')
anchors.left: prev.left
anchors.top: prev.bottom
margin-top: 8
@ -42,9 +42,7 @@ MainWindow
TextEdit
id: serverHostTextEdit
tooltip: |-
Make sure that your client uses
the correct game protocol version
!tooltip: tr('Make sure that your client uses\nthe correct game protocol version')
anchors.left: serverLabel.left
anchors.top: serverLabel.bottom
margin-top: 2
@ -52,7 +50,7 @@ MainWindow
Label
id: portLabel
text: Port
!text: tr('Port')
anchors.left: serverHostTextEdit.right
anchors.top: serverLabel.top
margin-left: 10
@ -68,8 +66,8 @@ MainWindow
CheckBox
id: rememberPasswordBox
text: Remember password
tooltip: Remember account and password when starts otclient
!text: tr('Remember password')
!tooltip: tr('Remember account and password when starts otclient')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
@ -79,15 +77,15 @@ MainWindow
CheckBox
id: autoLoginBox
enabled: false
text: Auto login
tooltip: Open charlist automatically when starting otclient
!text: tr('Auto login')
!tooltip: tr('Open charlist automatically when starting otclient')
anchors.left: parent.left
anchors.right: parent.right
anchors.top: prev.bottom
margin-top: 2
Button
text: Ok
!text: tr('Ok')
width: 64
anchors.right: next.left
anchors.bottom: parent.bottom
@ -95,7 +93,7 @@ MainWindow
@onClick: EnterGame.doLogin()
Button
text: Cancel
!text: tr('Cancel')
width: 64
anchors.right: parent.right
anchors.bottom: parent.bottom

@ -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

@ -0,0 +1,26 @@
locale = {
name = 'pt-br',
-- As traduções devem vir sempre em ordem alfabética.
translation = {
['Account name'] = 'Nome da conta',
['Account Status:\nFree Account'] = 'Estado da Conta:\nGrá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ã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çõ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çõ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ções devem vir sempre em ordem alfabética.
translation = {
['Account name'] = 'Nome da conta',
['Auto login'] = 'Entrar automaticamente',
['Cancel'] = 'Cancelar',
['Enter Game'] = 'Entrar no Jogo',
['Options'] = 'Opções',
['Password'] = 'Senha',
['Port'] = 'Porta',
['Remember password'] = 'Lembrar senha',
['Server'] = 'Servidor'
}
-- Adicionar informações de números. 1.000 100,00 1.000,00 etc.
}
Locales.installLocale(locale)

@ -5,19 +5,6 @@ local skillsWindow
local skillsButton
-- private functions
local function getNumberString(number)
local out = ''
number = tostring(number):reverse()
for i=1,#number do
out = out .. number:sub(i, i)
if i % 3 == 0 and i ~= #number then
out = out .. ','
end
end
out = out:reverse()
return out
end
local function setSkillValue(id, value)
local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('value')
@ -94,20 +81,20 @@ end
-- hooked events
function Skills.onExperienceChange(localPlayer, value)
setSkillValue('experience', getNumberString(value))
setSkillValue('experience', tr(value))
end
function Skills.onLevelChange(localPlayer, value, percent)
setSkillValue('level', getNumberString(value))
setSkillValue('level', tr(value))
setSkillPercent('level', percent, 'You have ' .. (100 - percent) .. ' percent to go')
end
function Skills.onHealthChange(localPlayer, health, maxHealth)
setSkillValue('health', getNumberString(health))
setSkillValue('health', tr(health))
end
function Skills.onManaChange(localPlayer, mana, maxMana)
setSkillValue('mana', getNumberString(mana))
setSkillValue('mana', tr(mana))
end
function Skills.onSoulChange(localPlayer, soul)

Loading…
Cancel
Save