Page 1 of 1

Localization changes in 0.11

Posted: Sun Nov 02, 2014 1:05 am
by JamesOFarrell
I'm having issues with the new changes to the way localization works in 0.11. I can use localized text in game but I can't treat it like a string. For instance, if i want to concatenate a localized item name with another string I get an error. To see this in action run:

Code: Select all

game.player.print(game.getlocaliseditemname("iron-axe") .. " test")
You will get an "Unable to concatenate a table" error. if you do:

Code: Select all

game.player.print(game.getlocaliseditemname("iron-axe")[1]  .. " test")
You get "item-name.iron-axe test". This is the same as if you use {"some-name"} in your lua code. Thoughts? Tips? Does any one know what i am missing or doing wrong?

Edit: I am going to add here this is not possible because it will break determinism. If you concatenate a string on 2 different machine with different languages you will get different results, causing desync.

Re: Localization changes in 0.11

Posted: Mon Nov 10, 2014 3:16 pm
by cube
should be {"", {"item-name.iron-axe"}, " test"}, iirc.Empty key means concatenation of the following localized strings.

Re: Localization changes in 0.11

Posted: Mon Nov 10, 2014 3:42 pm
by Xecutor
Hm. Previously, with game.gettext, you could have placeholders in your localized texts (in script-locale),
and replace them with localized names of items.
How this can be achieved now?

Re: Localization changes in 0.11

Posted: Mon Nov 10, 2014 4:44 pm
by cube
If there is a locale string

[abc]
def=ghi __1__ jkl

you can do

{"abc.def", "non translated string"} or {"abc.def", {"translated.string"}}

If that is what you mean

Re: Localization changes in 0.11

Posted: Tue Nov 11, 2014 8:52 am
by Xecutor
Oh. Cool. Thanks.

Re: Localization changes in 0.11

Posted: Tue Nov 11, 2014 10:04 am
by JamesOFarrell
cube wrote:should be {"", {"item-name.iron-axe"}, " test"}, iirc.Empty key means concatenation of the following localized strings.
Thanks for that, should make life easier