Localization on Prefabs on Mobile

More
7 years 10 months ago #2060 by mitchea
I'm having a problem with some localizations. Everything works in the Unity editor, but it some of the items fail after deploying to a mobile device.

The items that fail are a) tied to a Prefab, b) are fed from a JSON resource file and c) have a category assigned. When I open a particular scene, it creates objects based on the prefab. Then, it calls the Localize.SetTerm() method on the game object to assign the correct localization key. For example, let's say the button's localization key is "My Category/Start.Button". That string, "My Category/Start.Button" would be read from the JSON file and then applied to the Localize script using SetTerm(). As mentioned, this works fine in the Unity editor. When I run it on a phone, though, the text is not localized. Instead, the text shows the initial value of "button text".

Here are some things I tried:

1) I thought "maybe the terms weren't compiled and sent to the phone". I created a fake scene with UI text objects. I added Localize to the text objects and assigned the terms from the JSON file. This didn't work.

2) I used "Build Script with Selected Terms" in case this helped establish the terms in the app. I made sure to reference that script in one of my other scripts. This didn't work.

3) This one worked, though. I switched some of the JSON file terms to ones that were used elsewhere in the application. This time, the text showed correctly. That's why I tried #1 above.

4) I created a new term, without categorization, and switched some of the JSON terms to it. This did not work.

If you have any thoughts on how to get this to work, that would be great. Thanks in advance.

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

More
7 years 10 months ago #2062 by Frank
Are you using multiple LanguagesSources? Or are all your term in I2Languages.prefab?

If you have instantiated LanguagesSources in your Scene, those terms are only available when those scenes are loaded. For example, the Demo scenes that come with the plugin, they all have a LanguageSource in the scene, so that the terms in there are only valid for that scene. Nonetheless, its normally advised to have your terms in the I2Languages.prefab (without instantiating it in the scene), that way ALL localizations are GLOBAL and usable in all scenes.

If you have LanguageSources as prefabs and not in the Scene, then they will not be loaded when playing, you will need to add them manualy by calling LocalizationManager.AddSource( prefab ) or add their name into the LocalizationManager.GlobalSources array (LocalizationManager.cs line 208). Otherwise they wont be loaded by default.


For testing, you could add a Localize object into your scene and set the term in the inspector (instead of using SetTerm at runtime). If you see the translation in the device, then the problem is in the call to SetTerm and not in the plugin not finding the LanguageSource. In that case, double check that the term string is matches the casing and spaces (e.g. "My Term/Term1" does't match "My term/term1" or "My term / term1")

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.

More
7 years 10 months ago #2063 by mitchea
I debugged down to LanguageSources.cs on both my laptop and my phone. The mTerms variable has the following counts while running:

Laptop: 310
Phone: 173

So, there are over 100 items that aren't making it into mobile.

While debugging, I looked at each of the 173 items in mTerms on my phone. I2 definitely brings over terms that a) I have defined but b) are not referenced except by an external JSON file. So that part works. I verified this by changing some areas that had problems and pointing them to some terms found a) only in other JSON files that b) I knew were found in the mTerms variable. The terms loaded correctly.

For a while I thought the problem was categorization. I counted my uncategorized items, and I have 151. While looking through the 173 items that made it, I don't remember seeing any that had a category.

The problem with the categorization theory is that I tested it. I created a new, uncategorized term. That term did not make it into the 173 items either and does not display on the phone (though it works on my laptop of course)

So, my current theory is that my stuff is blowing up somewhere near the 173rd item in the languages list. They work on my laptop. But, those items aren't getting packaged for mobile.

My ideas:

1) perhaps I screwed things up with a strange name and everything afterwards had problem
2) perhaps the serialization around item 174 had a bad day and needs to be reset
3) could I dump my info to a CSV file and re-import it?

Any thoughts? I have to head off to kid duty now but will check again tonight. Thanks again.

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

More
7 years 10 months ago #2064 by mitchea
One more thing before I head off....

I've been creating and assigning terms and categories in a single step. I like categories because they help me organize things. Once I discovered them (probably around the time I was creating item 174!) I noticed that they were stored as "category/term". For example, the "Mummy" item in category "Monster" will be stored and referenced as "Monster/Mummy". At least that seemed to work for me.

So, I've been adding items to categories on the fly. When I create a new item, I'll name it "Monster/Werewolf" and it will drop into the Monster category. Everything works great on my laptop.

But perhaps that has consequences for mobile. Anyway, let me know if there's anything you want me to try when I get back. Thanks.

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

More
7 years 10 months ago #2065 by Frank
Hi,
Terms with or without categories follow the same logic. Categorized terms are just terms with '/' in their name, but everything else follows the same flow.

Can you please email me your I2Languages.prefab so that I can check if there is any miss-setup or issue. I will try to reproduce that problem of seeing less terms in the phone than in the desktop.

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.

More
7 years 10 months ago #2066 by mitchea
I just emailed it.

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

Time to create page: 0.211 seconds
Template by JoomlaShine