[0.18.22] rendering.draw_text cannot access Scenario's locale when savefile loaded
Posted: Thu May 07, 2020 9:44 pm
Hi,
I wanted to include localized rendered text in my scenario. This looks like very easy thing to do and it was, as rendering.draw_text supports localized strings. So I included my own locale file into the scenario and added the localized message.
This works fine when spawning the renders, but when you save the game and load it again, all scenario-localized rendering texts change to Unknown key error messages. Localized texts using vanilla locales load fine. Creating new renderings with same locale keys also work fine, until one saves the game and loads it again. Localization is loading properly for chat messages and gui and everything.
I created absolutely tiny scenario to demonstrate this (attachments). Steps to reproduce are then :
1) start a scenario that uses own locale files
2) use draw_text that use localized string from the scenario's locale
3) save the game, exit, and load the game again. Scenario's locales will be broken.
When game opened first time and scenario creates cars with added render texts bound to them, the top left one has while the other has which takes the entry from scenario added locale:
When I save the game, exit and load again, this same stuff turns into this:
Is there a way to fix this behaviour? I am not really a fan of tracking all rendertexts into global table and re-drawing them whenever player joins (as rendering class is unaccessible from on_load() event). Static texts also aren't really viable as some people just don't understand all the languages.
I wanted to include localized rendered text in my scenario. This looks like very easy thing to do and it was, as rendering.draw_text supports localized strings. So I included my own locale file into the scenario and added the localized message.
This works fine when spawning the renders, but when you save the game and load it again, all scenario-localized rendering texts change to Unknown key error messages. Localized texts using vanilla locales load fine. Creating new renderings with same locale keys also work fine, until one saves the game and loads it again. Localization is loading properly for chat messages and gui and everything.
I created absolutely tiny scenario to demonstrate this (attachments). Steps to reproduce are then :
1) start a scenario that uses own locale files
2) use draw_text that use localized string from the scenario's locale
3) save the game, exit, and load the game again. Scenario's locales will be broken.
When game opened first time and scenario creates cars with added render texts bound to them, the top left one has
Code: Select all
text = {"entity-name.car"}
Code: Select all
text = {"my_locale.car"}