Executing Localize script via script
9 years 10 months ago #97
by Jos
Executing Localize script via script was created by Jos
While i can use the GetTermTranslation() method (or the handy ScriptTranslation class) to get run-time content, i can't as simply do the multi-term stuff which Localize gives me. Specifically changing the font & text at the same time on a GUIText (or TextMesh).
We have a dialog system where i can pretty easily add keys for each line of dialog, but that dialog uses a single GUIText (for example). I'd like to be able to reset the "Term" and "SecondaryTerm" of the Localization script component and "rerun" it, so it updates all the items properly.
I'm not sure if simply making RegisterTargets(), EventFindTarget() and OnLocalize() public would do it (OnLocalize() is already public, but it is using cached data).
Any suggestions?
Thanks!
Jos
We have a dialog system where i can pretty easily add keys for each line of dialog, but that dialog uses a single GUIText (for example). I'd like to be able to reset the "Term" and "SecondaryTerm" of the Localization script component and "rerun" it, so it updates all the items properly.
I'm not sure if simply making RegisterTargets(), EventFindTarget() and OnLocalize() public would do it (OnLocalize() is already public, but it is using cached data).
Any suggestions?
Thanks!
Jos
Please Log in or Create an account to join the conversation.
9 years 10 months ago #98
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Executing Localize script via script
If you have a GUIText object with a Localize component. You could change the Term and SecondaryTerm and then call OnLocalize to update the translation based on the new Terms.
The localize component does cache some of the data it uses, but not the actual Terms and translation. Given that I2 Localization can handle several object types, the RegisterTargets is called initially to detect what object is meant to be localized (i.e. if its Label or a Sprite, or a sound, etc).
You don't need to call RegisterTargets again unless you are actually destroying the GUIText component and creating a new one. But if you are only changing the term or text in the GUIText, then the cached values will be ok as only the reference to the GUIText component is cached as well as the functions that do the translation for that type of object.
So, just change the term and secondaryTerm and call OnLocalize(), that should work fine.
The localize component does cache some of the data it uses, but not the actual Terms and translation. Given that I2 Localization can handle several object types, the RegisterTargets is called initially to detect what object is meant to be localized (i.e. if its Label or a Sprite, or a sound, etc).
You don't need to call RegisterTargets again unless you are actually destroying the GUIText component and creating a new one. But if you are only changing the term or text in the GUIText, then the cached values will be ok as only the reference to the GUIText component is cached as well as the functions that do the translation for that type of object.
So, just change the term and secondaryTerm and call OnLocalize(), that should work fine.
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
The following user(s) said Thank You: Jos
Please Log in or Create an account to join the conversation.
9 years 10 months ago #100
by Jos
Replied by Jos on topic Executing Localize script via script
Excellent - i had just tried this out in one of the example scenes. Much better then me having to tweak the code. It is like you had already thought of this use-case!
Thanks for the quick reply,
Jos
Thanks for the quick reply,
Jos
Please Log in or Create an account to join the conversation.
Time to create page: 0.433 seconds