Author Topic: Changing language  (Read 3477 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Changing language
« on: May 08, 2012, 08:18:11 AM »
Ok, this is probably a really simple question, and it probably is more to do that I am not so sure of Unity rather than NGUI.

My issue, I am using the Localization, and UILocalize. My menu buttons are already in two separate text files for Japanese and English, I am all set up and working, just like in the tutorial. Yet, I can't seem to figure out to do the simplest of things, which is to change the language once the program has started in code.

What I am looking for I guess is:-

"Localization.instance.languages = 0; // Japanese"
"Localization.instance.languages = 1; // English"

The above gives me an error though, I guess what I am trying to do is probably really simple.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing language
« Reply #1 on: May 08, 2012, 11:38:47 AM »
Just use the name of the language.

Localization.instance.currentLanguage = "English";

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Changing language
« Reply #2 on: May 08, 2012, 08:38:41 PM »
Thanks, ok, so 'languages' and 'currentlanguage' was my problem. Thanks for that :)
I had another problem but now I have realised that carriage returns are the end of the label.
I had labels such as

Main =
This is Main !

which simply did nothing. :O



This NGUI is awesome. Ok my next question is, can I do cool things like combine variables inside the text string, for example something like this:-

public string name = "Jeffrey";
public int age = 16;



moo.txt
____
Label_name = Your name is [var Myclassname.name]
Label_name2 = Your age is  [var Myclassname.age]
____




and then later on in my code after calling moo.txt, my text strings would automatically be "Your name is Jeffrey" and "Your age is 16" ?


Thanks. :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing language
« Reply #3 on: May 08, 2012, 09:00:19 PM »
You have to do that manually. I suggest looking into how string.Format works as well.

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: Changing language
« Reply #4 on: May 08, 2012, 09:04:40 PM »
Yes, it would be easier to just concatenate the string in C# and just call the string in separate tag chunks. Not only is that easier and better, but I already know how to do that.

Sorry about the stupid post there. :)