Best way to localize a label in script
7 years 11 months ago #1947
by SteveF
Best way to localize a label in script was created by SteveF
Hi,
Just bought this asset, its working really well but i wanted to check the best way to localize in this situation:
Im using the built in unity GUI, i have a label that can be one of about 50 strings depending on player level.
Whats the best way to localize this? Its a bit trickier because i need to set modifiers in the localize script, and also assign a font as a secondary term.
Many thanks,
Steve
Just bought this asset, its working really well but i wanted to check the best way to localize in this situation:
Im using the built in unity GUI, i have a label that can be one of about 50 strings depending on player level.
Whats the best way to localize this? Its a bit trickier because i need to set modifiers in the localize script, and also assign a font as a secondary term.
Many thanks,
Steve
Please Log in or Create an account to join the conversation.
7 years 11 months ago #1948
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Best way to localize a label in script
Hi,
In that case:
- Create a term for each of the 50 strings. (That way they can be localized to each language)
- Add a Localize component to your label
- Set the Secondary Term to allow changing the Font
- Set any Callback/Parameter/Modifier that you need
- Set the primary term with any of the terms you created for the 50 strings.
At runtime, you can call localizeCmp.SetTerm( "TermName" ). That will get the translation of that term into the current language, apply any Modifier/Parameter/Callback you defined and then show the result in the label.
instead of
you can do:
Hope that helps,
Frank
In that case:
- Create a term for each of the 50 strings. (That way they can be localized to each language)
- Add a Localize component to your label
- Set the Secondary Term to allow changing the Font
- Set any Callback/Parameter/Modifier that you need
- Set the primary term with any of the terms you created for the 50 strings.
At runtime, you can call localizeCmp.SetTerm( "TermName" ). That will get the translation of that term into the current language, apply any Modifier/Parameter/Callback you defined and then show the result in the label.
instead of
label.text = "PLAYER_LEVEL_3";
you can do:
var localize = label.GetComponent<Localize>();
localize.SetTerm("PLAYER_LEVEL_3");
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.152 seconds