How to localize a changing text

More
8 years 10 months ago #684 by j3d
I apologize if I missed this in the tutorial, but according to this: inter-illusion.com/tools/i2-localization/how-to-localize , it seems that the only way to localize a text is to add the localize script to your object and make sure that the text is in the main source.

Here is what I did: I added the term "run fast" to the source, and then I added the localize script to the guitext. The twist is that the text starts out with the text "don't run", and then later it will change to run fast, which is the text that I want to translate. I wish there was a line of code that would just localize every single guitext that I display but for now this is my issue.

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

More
8 years 10 months ago #685 by Frank
Hi,
If what you need its to change the term at runtime, you could call SetTerm.

Here is an example:
www.inter-illusion.com/forum/i2-localiza...a-localised-text#676

Basically, what you need to do is add both "don't run" and "run fast" to the language source and setup the translation of them for each language.

Then, instead of doing:
myText.text = "run fast";

you should do:
myText.GetComponent<Localize>().SetTerm("run fast", null); 

That will change the term and will update the label's text automatically.

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.

More
8 years 10 months ago #686 by j3d
Replied by j3d on topic How to localize a changing text
Okay seems simple, but when I use that particular line there is a minor problem. It says that the namespace Localize has not been found, so I looked at the Localize script and saw it had the namespace I2.Loc but when I used that, it says that it is looking for a type.

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

More
8 years 10 months ago - 8 years 10 months ago #687 by Frank
Hi
To avoid naming conflicts with other plugins, All classes in the I2L plugin are in the I2.Loc namespace.

You can add the namespace at the top of the file where you are accessing the Localize component:
using I2.Loc;

All the example scripts use that way.

The other way is to use I2.Loc.Localize instead of Localize
myText.GetComponent<I2.Loc.Localize>().SetTerm("run fast", null); 

BTW, are you using JavaScript or C#? Because in JavaScript the compilation order could make some classes inaccessible if the I2L is not moved into the Plugins folder.

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
Last edit: 8 years 10 months ago by Frank.

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

Time to create page: 0.244 seconds
Template by JoomlaShine