Welcome, Guest
Username: Password: Remember me

TOPIC: Secondary Term for Font on all Localize components

Secondary Term for Font on all Localize components 2 months 2 weeks ago #2373

  • fiveamp
  • fiveamp's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
We are using a secondary term on Localize components to switch the font based on languages. And using Textmesh Pro to split our fonts into smaller atlases with characters used per language. Is there any easy way to force this secondary term to be on all localize components without the need to add it manually to each component?

I wrote a simple editor script to do this for us, but I still feel like there must be an easier more efficient way to accomplish this. Any thoughts?
[MenuItem("Tools/i2 - Add Font to Loc Components", false, 512)]
public static void AddFontToLocs()
{
	int locsFixed = 0;
	Localize[] locList = FindObjectsOfType<Localize>();
	foreach (Localize loc in locList)
	{
		if (string.IsNullOrEmpty(loc.SecondaryTerm)) {
			loc.SecondaryTerm = "UI_MAIN/DefaultFont";
			locsFixed++;
		}
	}
	string message;
	if (locList.Length < 1) {
		message = "No Localize Components Found in current Scene Hierarchy";
	}
	else {
		message = locList.Length.ToString() + " Localize's found. ";
		if (locsFixed > 0) {
			message += locsFixed.ToString() + " fixed with DefaultFont secondary term";
		}
	}
	Debug.Log(message);
}
The administrator has disabled public write access.

Secondary Term for Font on all Localize components 2 months 2 weeks ago #2374

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 873
  • Thank you received: 189
  • Karma: 55
Is there any easy way to force this secondary term to be on all localize components without the need to add it manually to each component?

Yes,
I2 Localization will try to detect which term should be used based on the context.
In the case of secondary terms it uses the name of the original font.

To setup this, just place your TMP label, and assign one of the fonts (e.g. "TMP_Arial")
Then, create a font with that EXACT name (e.g. "TMP_Arial"). and assign each of the per-language fonts to each of the translations (e.g. TMP_Arial_ch, TMP_Arial_ru, etc)


When the game runs, it will see that it doesn't have a secondary term, so it tries to infer it by getting the name of the font (TMP_Arial), it will see that there is a term named like that, so it will use it.

If you set this correctly, you will see the secondary term in the inspector automatically detecting the font term and showing it in a darker color so that you know it is an "inferred term".

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
The administrator has disabled public write access.
The following user(s) said Thank You: fiveamp

Secondary Term for Font on all Localize components 2 months 2 weeks ago #2375

  • fiveamp
  • fiveamp's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Perfect!
Note, it looks like the naming restriction for the additional Font assets is not necessary. Only that the term itself is named after the main font so that the 'inferred' feature works. In the term we have a different asset resources & naming for each lang as the font assets do not derive from the same font.
The administrator has disabled public write access.

Secondary Term for Font on all Localize components 2 months 2 weeks ago #2376

  • fiveamp
  • fiveamp's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Additional quick question:
If secondary terms are left empty, will they be inferred during runtime or do they need to be auto-inferred during edit mode which will set the secondary term.

example attached.
Attachments:
The administrator has disabled public write access.

Secondary Term for Font on all Localize components 2 months 1 week ago #2378

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 873
  • Thank you received: 189
  • Karma: 55
Empty terms will be inferred at runtime.
But if you open the localize inspector, and make a change in the term's popup, that inferred term will become a regular term. Unless you manually select the last popup option to make it <inferred> again.

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
The administrator has disabled public write access.
The following user(s) said Thank You: fiveamp

Secondary Term for Font on all Localize components 2 months 1 week ago #2380

  • fiveamp
  • fiveamp's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Karma: 0
Awesome, thanks!
The administrator has disabled public write access.
Time to create page: 0.095 seconds
Colors