Author Topic: Localization issues  (Read 6193 times)

n3k0san

  • Guest
Localization issues
« on: April 16, 2012, 05:53:03 PM »
Hello

I have some issues with localizations, which do not work.

What are the exact steps in order to get it working?

1) I've added the Localization prefab in my scene. I also created a 3rd language txt file, since I want to test with english, french and another language.
2) I've copied the same labels and only translated them in the new text file
3) I've set 3 languages in the prefab and added my 3rd language in the list
4) I've added an UILocalize script on my labels and I've set the key to match what is defined in the txt file.

The translations do not change.
My keys are all in 1 word (for eg: "BestLap" and not "Best Lap") Can we use multiple words per key, btw?
Files are saved as UTF-8.

Are there any things we need to be careful about? Like line endings, text file character set, etc?

Is there anything else that I need to do?
I've looked over the "Localization" example that you include and I don't see anything extra in there, so what am I missing?

I even tried setting the "Starting language" on the Prefab, but that does not work. Do we need to set there the "id" of the item in the array? The language name? I've tried both but in debug mode "MLanguage" is always empty, while in your "Localization" example it changes to the currently selected language.

NGUI so far has been a real lifesaver.

Thanks and best wishes

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localization issues
« Reply #1 on: April 16, 2012, 10:12:38 PM »
How do you change the language? At the end you mention that the mLanguage is always empty, implying it's never set. Do you ever call Localization.currentLanguage = ...?

n3k0san

  • Guest
Re: Localization issues
« Reply #2 on: April 17, 2012, 02:58:50 AM »
Hi

Thanks. It seems I need to call "Localization.instance.currentLanguage".
Starting language still does not work if I set it in the gameobject, but I don't mind setting it from code for the time being.

Best wishes

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Localization issues
« Reply #3 on: April 17, 2012, 04:42:53 AM »
The Localization script is designed to work with UILocalize.

UILocalize calls OnLocalize in OnEnable, which in turn checks the currentLanguage.

I'm guessing there is some script execution order issue if you aren't seeing this though. OnEnable has a tendency to get triggered before everything else, including some Awakes from what I've seen. Strange stuff. I'll add an extra check in there so it's not necessary.

Meltdown

  • Jr. Member
  • **
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 56
    • View Profile
Re: Localization issues
« Reply #4 on: February 21, 2014, 10:06:18 PM »
I had this same issue. The language is case sensitive and needs to be in the same case as your text file.

So if your text file is called 'french.txt', and you want to start with French, starting language must be set to 'french', even if the language key in your text file is called 'French'