How to set a new term on a localised Text?
- protostarDean
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
9 years 6 months ago #675
by protostarDean
How to set a new term on a localised Text? was created by protostarDean
Hi there,
Great plugin! Has been good so far except for this one issue. Forgive me if I have missed something obvious.
I have a ugui text that I want to be localised, but it's term needs to be set dynamically in code.
The last system I worked with, when you did for example:
it would look up "ITEM_0", translate it, and set the text to the localised string.
With i2, the Localize component is expecting a certain term, and just localizes to that term regardless of what I set the text to. I cant seem to add a component with an unspecified term.
What would be the equiavalent of the above example? is there something I have missed, or do I just have to have the text non localised and manually look up the translation in code?
Many thanks for your help.
Great plugin! Has been good so far except for this one issue. Forgive me if I have missed something obvious.
I have a ugui text that I want to be localised, but it's term needs to be set dynamically in code.
The last system I worked with, when you did for example:
myText.text = "ITEM_0";
it would look up "ITEM_0", translate it, and set the text to the localised string.
With i2, the Localize component is expecting a certain term, and just localizes to that term regardless of what I set the text to. I cant seem to add a component with an unspecified term.
What would be the equiavalent of the above example? is there something I have missed, or do I just have to have the text non localised and manually look up the translation in code?
Many thanks for your help.
Please Log in or Create an account to join the conversation.
9 years 6 months ago - 9 years 5 months ago #676
by Frank
Are you
Give I2L
5 stars!
Are you
Please lets us know how to improve it!
Replied by Frank on topic How to set a new term on a localised Text?
Hi
When the Localize component is enabled, if there is no term, it takes the text of the Label and uses that as the term.
Modifying the label's text after that point doesn't override the Localize component.
If you want to change the term dynamically, you can use the SetTerm(term, null) function.
Here is an example:
inter-illusion.com/forum/i2-localization...ith-dynamic-term#499
Basically, instead of modifying the label text, you have to pass that string into the SetTerm and the Localize component will update the label's text with the correct translation.
instead of
you should do:
that will translate ITEM_0 to the current language and update the myText.text with the translation.
Alternatively, you can do it manually (you don't need a Localize component for this next)
You can also use the Localization Callback to override the Localize component and get the correct term, but that will be more code than needed![:-) :-)](/media/kunena/emoticons/smile.png)
Hope that helps
Frank
When the Localize component is enabled, if there is no term, it takes the text of the Label and uses that as the term.
Modifying the label's text after that point doesn't override the Localize component.
If you want to change the term dynamically, you can use the SetTerm(term, null) function.
Here is an example:
inter-illusion.com/forum/i2-localization...ith-dynamic-term#499
Basically, instead of modifying the label text, you have to pass that string into the SetTerm and the Localize component will update the label's text with the correct translation.
instead of
myText.text = "ITEM_0";
you should do:
myText.GetComponent<Localize>().SetTerm("ITEM_0", null);
that will translate ITEM_0 to the current language and update the myText.text with the translation.
Alternatively, you can do it manually (you don't need a Localize component for this next)
myText.text = ScriptLocalization.Get("ITEM_0");
You can also use the Localization Callback to override the Localize component and get the correct term, but that will be more code than needed
![:-) :-)](/media/kunena/emoticons/smile.png)
Hope that helps
Frank
Are you
![:-) :-)](/media/kunena/emoticons/smile.png)
Are you
![:-( :-(](/media/kunena/emoticons/sad.png)
To get the betas as soon as they are ready,
check this out
Last edit: 9 years 5 months ago by Frank.
Please Log in or Create an account to join the conversation.
- protostarDean
- Topic Author
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
9 years 6 months ago #677
by protostarDean
Replied by protostarDean on topic How to set a new term on a localised Text?
Hi Frank,
Ok, No probs. I can deal with that.
Thanks for the super quick reply.
Keep up the good work
Ok, No probs. I can deal with that.
Thanks for the super quick reply.
Keep up the good work
![:-) :-)](/media/kunena/emoticons/smile.png)
Please Log in or Create an account to join the conversation.
Time to create page: 0.141 seconds