Changing language does not update text from script

More
8 years 6 months ago #1075 by whipexx
Greetings,

I've found out that when changing my language on-runtime the text that gets setted from script does not change.

Is there any "easy" fix for this issue? (I could create methods for all translations and notify them when language is changed, but since I've got about half a thousand texts setted from script across about two hundred files I don't really like this solution.)

Another solution would be to reload the scene, I would do this but it takes a few seconds for it to load; I don't like it to freeze each time it changes language.


Cheers

Please Log in or Create an account to join the conversation.

More
8 years 6 months ago #1080 by Frank
There is no built-in approach to relocalize any text you are managing by code. At then end, to make it work, that code has to run again.

The easiest way I see, it's by adding your methods to the global LocalizationManager.OnLocalizeEvent. That way they get called whenever a language is changed.

However, the best solution its to add Localize components to each of those texts. Then instead of modifying the text directly from your code, call localize.SetTerm instead.

That way, you will still have control in your scripts over the translations, but given that the Localize component knows the term you are localizing, then anytime the language changes, it will automatically change the text to the correct language.

If you need to have control of the translations in code because you are adding numbers and other parameters, then you could change the code to use Translation Callbacks for modifying the translation. That will still keep everything managed by the Localize component.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

Time to create page: 0.134 seconds
Template by JoomlaShine