Page 1 of 1
[1.1.34] on_string_translated handles empty localised string incorrectly
Posted: Thu Jun 03, 2021 12:29 pm
by eradicator
Code:
Code: Select all
/c
script.on_event(defines.events.on_string_translated, function(e) game.print(serpent.line(e.localised_string)) end)
game.player.request_translation( {'',{''},{''},{''},{''}} )
Result:
As you can see the event data localised string is missing the subtables. This breaks association between the request and the result.
Re: [1.1.34] on_string_translated handles empty localised string incorrectly
Posted: Fri Jun 04, 2021 9:17 am
by boskid
This LocalisedString has to go through the input actions so at some point it has to be converted from lua table to internally used LocalisedString. This issue you have is because internally there are 3 states for LocalisedString: Translation, Literal and Empty. In this case you have Literal with 4 parameters which are themselves Literals (they have no key) but they have no parameters so they are converted into Empty. That step drops the inner brackets. If you would have a translation (which means non empty key) or literal with parameters (which means at least one parameter) those inner tables would be preserved.
Fixing this issue could easily become a breaking change which will not happen in the middle of a stable and there is a relatively easy workaround for this (do not use literal with no parameters) so i am moving this to "wont fix"
Re: [1.1.34] on_string_translated handles empty localised string incorrectly
Posted: Fri Jun 04, 2021 12:24 pm
by eradicator
Thank you for the detailed answer.
boskid wrote: Fri Jun 04, 2021 9:17 am
easy workaround for this (do not use literal with no parameters)
Regrettably this only works if I create the localised strings myself. If other people throw these at
my remote interface and you won't fix it then I have to re-implement that behavior in lua.
So far I'm only dealing with runtime LuaSomethingPrototype.localised_name and description. Do you know if that "transformation" of {""} to "" also happens during prototype loading?