Fonts Per Language Questions
- JohnLawrie
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
8 years 1 month ago #1841
by JohnLawrie
Fonts Per Language Questions was created by JohnLawrie
Hello,
I have a questions relating to using a different font per language. I know that I2 Localization has the capability and I use it in several place by using the font terms and it works well. However, there are some use cases in our game that don't follow the normal flow.
We use Text Mesh Pro text boxes throughout our game. In many places, we dynamically set the contents of the text by assigning to the .text field. For example, we essentially do this:
If this were the only place that did this, I could add a localize component to the prefab and set the font using the secondary term. However, our code will end up reusing the same Text Mesh Pro text box many times changing the value. Essentially:
Is there a way that I can continue to set the text from script but still use I2 Localizations functionality to set the language? The only idea I have it to attach a localize component to the prefab but to make it use an empty term. This seems like a hack and I don't even know if it would work.
Thank you
John Lawrie
I have a questions relating to using a different font per language. I know that I2 Localization has the capability and I use it in several place by using the font terms and it works well. However, there are some use cases in our game that don't follow the normal flow.
We use Text Mesh Pro text boxes throughout our game. In many places, we dynamically set the contents of the text by assigning to the .text field. For example, we essentially do this:
TalkBubbleText.text = I2.Loc.ScriptLocalization.Get("UI/StartSimulation");
If this were the only place that did this, I could add a localize component to the prefab and set the font using the secondary term. However, our code will end up reusing the same Text Mesh Pro text box many times changing the value. Essentially:
// Called at some point later on in the game
void StartStage2()
{
TalkBubbleText.text = I2.Loc.ScriptLocalization.Get("UI/Stage2");
}
// Called at some point even later on in the game.
void StartStage3()
{
TalkBubbleText.text = I2.Loc.ScriptLocalization.Get("UI/Stage3");
}
Is there a way that I can continue to set the text from script but still use I2 Localizations functionality to set the language? The only idea I have it to attach a localize component to the prefab but to make it use an empty term. This seems like a hack and I don't even know if it would work.
Thank you
John Lawrie
Please Log in or Create an account to join the conversation.
8 years 1 month ago - 8 years 1 month ago #1842
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Fonts Per Language Questions
Hi,
You can use the Localize component built-in functionality instead of assigning the text directly.
Just add a Localize component to the TextMeshPro object.
Then, change the primary and secondary term of the Localize component instead of modifying the .text property.
Whenever you call SetTerm(primary, secondary), the localize component, will translate the term and modify the .text and .font properties using the translations.
Hope that helps,
Frank
Edit: in that example, the term "Arial" can be localized, so that it holds different fonts based on the language.
You can use the Localize component built-in functionality instead of assigning the text directly.
Just add a Localize component to the TextMeshPro object.
Then, change the primary and secondary term of the Localize component instead of modifying the .text property.
TalkBubbleText.GetComponent<I2.Loc.Localize>().SetTerm( "UI/StartSimulation", "Arial");
// later
TalkBubbleText.GetComponent<I2.Loc.Localize>().SetTerm( "UI/Stage2", "Arial");
// or don't specify the secondary term and it will remember the previous one
TalkBubbleText.GetComponent<I2.Loc.Localize>().SetTerm( "UI/Stage2");
Whenever you call SetTerm(primary, secondary), the localize component, will translate the term and modify the .text and .font properties using the translations.
Hope that helps,
Frank
Edit: in that example, the term "Arial" can be localized, so that it holds different fonts based on the language.
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 1 month ago by Frank.
Please Log in or Create an account to join the conversation.
- JohnLawrie
- Topic Author
- Offline
- New Member
Less
More
- Posts: 9
- Thank you received: 0
8 years 1 month ago #1856
by JohnLawrie
Replied by JohnLawrie on topic Fonts Per Language Questions
What about if we are doing something like this:
where the string is set to something dynamic?
Thanks
John Lawrie
XPText.text = string.Format("XP: {0:N0}", _card.xp);
where the string is set to something dynamic?
Thanks
John Lawrie
Please Log in or Create an account to join the conversation.
8 years 1 month ago #1857
by Frank
Are you Give I2L 5 stars!
Are you Please lets us know how to improve it!
Replied by Frank on topic Fonts Per Language Questions
Dont set .text directly.
Instead, call SetTerm and use Parameters or Callbacks to modify the translation.
That will make the text follow the grammar rules and ordering of the selected language. And the text will also update automatically whenever the language is changed.
Instead, call SetTerm and use Parameters or Callbacks to modify the translation.
That will make the text follow the grammar rules and ordering of the selected language. And the text will also update automatically whenever the language is changed.
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.146 seconds