NGUI Label with dynamic term

More
9 years 10 months ago - 9 years 10 months ago #498 by StKiller
Hello,

I have a button which has action depending on context. So, from code, I update button's caption to either "one", "two" or "three".
I have these terms defined in the localization source and there is attached an localization component to the button's label.

The problem is that the localization is not always updated when the label 'text' field is updated. Can I force it to refresh the localization, somehow?

Thank you in advance.

**Update**

I started to use api for in-code localization and removed the localization component from the label itself. Now it works fine.
Last edit: 9 years 10 months ago by StKiller.

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

More
9 years 10 months ago #499 by Frank
Replied by Frank on topic NGUI Label with dynamic term
Hi,
The Localize component takes the Label's text only when its enabled for the first time, if it doesn't have a term.
To change the localized term at runtime, you need to call the function SetTerm of the localize component:
// Instead of 
// label.text = "one";
// call:

label.GetComponent<Localize>().SetTerm("one", null);

Calling the SetTerm will change the term that is used and will update the label's text with the translation.

Thanks,
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.191 seconds
Template by JoomlaShine