Author Topic: Localization system  (Read 49360 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #45 on: October 04, 2014, 08:10:22 AM »
The new consolidated localization system pulls everything from one file containing all the text. You can have multiple files if you use the old approach instead, but then you won't have a list of languages to work with. You can also set your own localization data at run time if you prefer -- then this data can come from anywhere.

For example in Windward, the first person to host the game actually sends their localization file to everyone else, so that if the host made any modifications, others will receive them automatically.

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
Re: Localization system
« Reply #46 on: October 04, 2014, 08:17:36 AM »
your localization system is very convenient and I would like to use it for more complex things (not just in game menus, or simple dialogs..) that would need multiple  spreadsheets and localization files for easier management, because data I want to be localized is logically separated in multiple spreadsheets and using one file would be very hard to manage. Do you have any plans in updating this system to be able to use multiple data files? Is it going to take too much time?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #47 on: October 05, 2014, 09:14:02 AM »
I would suggest you create a different class for this. You can use ByteReader.ReadCSV to parse a CSV file into a dictionary of data for you to use. It doesn't have to be done through the Localization class.

rextr

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Localization system
« Reply #48 on: October 11, 2014, 02:48:58 PM »
Hi,

I have just switched from 3.4.9 to 3.7.3, but I couldn't get the old style localization work. I couldn't find any documentation on the old style localization. Someone here suggest putting the language files to the Resources folder, but still doesn't work. It says  "Localization key not found: 'some_key' "

I set Localization.language = "English"; in awake function and I have "English.txt" in the Resources folder. Is there anything else that I should do? English.txt consists of key = value pairs. Also it was working in 3.4.9 because there we could set all the language files in editor through a public variable of Localization.cs. But now, there is no such list and it can't load the file from Resources.

Thanks.

EDIT: Ok , I found it. I had to delete the file NGUI/Examples/Resources/Localization file to fix it. I think you should put this info to the documentation.
« Last Edit: October 11, 2014, 03:26:03 PM by rextr »

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: Localization system
« Reply #49 on: November 30, 2014, 11:05:30 PM »
My Localization.csv first language is not an English. Unity 4.6 , NGUI 3.7.6

KEY,RU,EN
string,string,string
TID_LANGUAGE_RU,Русский,Русский
TID_LANGUAGE_EN,English,English
..
..
..

i got error (see below the attach), could you explain to me , why ?

thanks.
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #50 on: December 02, 2014, 12:32:05 PM »
Your keys are strange. It should be:
  1. KEY,RU,EN
  2. TID_LANGUAGE,Русский,English
What's the point of duplicating all that data? The whole point of localization is to translate values. When you localize "TID_LANGUAGE" you will get "Русский" if you're using the Russian language, and "English" if you're using the English language.

Other than that, make sure that you number of columns is the same. You have 3 columns, so all rows must also have 3 columns.

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: Localization system
« Reply #51 on: December 04, 2014, 09:45:58 PM »
but Why preview doesn't work anymore ?

Quote
What's the point of duplicating all that data?
So tell me pls , how could i get many values of key ? i need get values for a one key.
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #52 on: December 05, 2014, 01:05:19 AM »
I don't understand what you mean.

In my example Localization.Get("TID_LANGUAGE") will return "English" if the Localization.language is set to "EN", or "Русский" if the language is "RU".

kulesz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Localization system
« Reply #53 on: December 30, 2014, 08:06:00 AM »
I got my localization system partially working. But after reading 4 pages of this topic there's still a problem.

A have only one Localization.csv file in the project.
When I add UILocalize component to label I cannot select my keys from the list (red cross on the right). However after manually entering key and running a project the preview field get's filled and it works as expected (while still running). After stopping the game in editor UILocalize "holds" its values for a while / a few clicks and then it disappears again (red cross).
I cannot also change language in runtime. When I do: Localization.language = "French" nothing changes. Labels stay the same, but whats interesting - after disabling and enabling buttons the labels change to 'key' value.
It's seems very random and messy to me... Does anyone know what can cause such problems?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #54 on: December 30, 2014, 02:00:12 PM »
Well first it should be Localization.txt, not .csv and second -- make sure you don't have any other Localization files in your Resources folders. Remember, NGUI comes with one.

kulesz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Localization system
« Reply #55 on: December 30, 2014, 03:09:10 PM »
Thanks, but I still have some issue,
I've changed the file name and there's only one Localization.txt file (double checked). And this is what I'm doing:

  • I opened fresh Unity editor with the project loaded
  • I click on the label object
  • Apparently everything is fine, because I see proper values in the UILocalize inspector (green tick):
[ATTACHMENT SCREEN 1]
  • The preview functionality also works in the editor
  • I'm running the game
  • Everything is still fine in the inspector
  • I'm clicking on some buttons to change the language - and nothing happens - the label still has text in English
  • I'm disabling the panel where the label is and turning it back on - the labels has the KEY text
  • Inspector shows me this (red tick):
[ATTACHMENT SCREEN 2]


kulesz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Localization system
« Reply #56 on: December 30, 2014, 04:51:34 PM »
Got it working :)

It seems that language string that I passed had "\r\n" on the end (which was difficult to spot in inspector).
After removing those everything works fine.

JorgeM

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
    • Mascota Hogar
I2 Localization
« Reply #57 on: January 09, 2015, 06:16:44 AM »
Was I2 Localization made by NGUI team?
In case it wasn't, is it as good as NGUI and better than the default NGUI Localization system?
I am considering buying it.
Thank you.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Localization system
« Reply #58 on: January 10, 2015, 01:13:37 PM »
No, it's a third party tool. It expands the localization functionality of NGUI, adding new features. You can find its thread in the general forum: http://www.tasharen.com/forum/index.php?topic=8324.0

emile_d

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Localization system
« Reply #59 on: January 26, 2015, 08:42:57 AM »
We're working for a multi-language game now. Is there any method to 'localize' font for UILabel? I mean using different font for every language? (Because a font may not contain all characters for all languages. And we're using dynamic font renderering in Unity.)

What I thought to implement this is to attach a script on all game objects which have UILabel components. The script can change the font of the UILabel according to the current language users selected. Do you have any other better idea?

Thank you!