Localization changes in 0.11

Place to get help with not working mods / modding interface.
JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Localization changes in 0.11

Post 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.
User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: Localization changes in 0.11

Post by cube »

should be {"", {"item-name.iron-axe"}, " test"}, iirc.Empty key means concatenation of the following localized strings.
User avatar
Xecutor
Filter Inserter
Filter Inserter
Posts: 260
Joined: Mon Jun 23, 2014 10:15 am
Contact:

Re: Localization changes in 0.11

Post 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?
User avatar
cube
Former Staff
Former Staff
Posts: 1111
Joined: Tue Mar 05, 2013 8:14 pm
Contact:

Re: Localization changes in 0.11

Post 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
User avatar
Xecutor
Filter Inserter
Filter Inserter
Posts: 260
Joined: Mon Jun 23, 2014 10:15 am
Contact:

Re: Localization changes in 0.11

Post by Xecutor »

Oh. Cool. Thanks.
JamesOFarrell
Filter Inserter
Filter Inserter
Posts: 402
Joined: Fri May 23, 2014 8:54 am
Contact:

Re: Localization changes in 0.11

Post 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
Post Reply

Return to “Modding help”