OverviewLocalizing your game using NGUI is as simple as creating a CSV file with all your text and using the
UILocalize component on your labels and sprites that you want to be localized.
NOTE: The CSV support was added in 3.5.0
The first step is creating the CSV file. You can use Google Docs, Excel, or any other application that's capable of creating excel style files.
The CSV file should contain two or more columns. The
first column should contain
keys that you will use in the Key field of the UILocalize component. Other columns should contain the actual localized values for those keys.
The
first row should contain your language names -- English, French, Simplified Chinese, etc. When you want to switch a language in-game you can either use
Localization.language = "English;" (or any other language defined in the first row), or just attach the
LanguageSelection component to a drop-down list, turning it into a language selection list.
All other rows should contain the
key in the first column and text values in all the subsequent columns. Just make sure that there are localized values present for all the given keys, or things may not work properly.
Once you're done, export the file in CSV file format as
Localization.csv, and place it in the
Resources folder. Unity 4 treats CSV files as Text files, but if you are still on Unity 3, you will need to rename that file to have a TXT extension or it won't be recognized.
To localize any label or sprite, attach
UILocalize script to it and choose a key defined in the CSV file you created, and that's it! The label or sprite's value will be pulled from the localization file automatically, and when you switch languages, so will your label or sprite.
Pro-Tip #1If you don't remember what your key was, just start typing in the UILocalize's "key" field. It will bring up a list of relevant entries for your convenience. Click on one of them to choose that value. Likewise you can click on the Preview options to have the localized object immediately assume that value.
Pro-Tip #2If you are doing custom localization, you can still use the localization system. Use
Localization.Get(key) anywhere in code to retrieve a localized value for the current language. To change the language --
Localization.language = "New Language";Pro-Tip #3Want even better localization tools? Have a look here --
http://www.tasharen.com/forum/index.php?topic=8324.0Class Documentationhttp://tasharen.com/ngui/docs/class_u_i_localize.htmlhttp://tasharen.com/ngui/docs/class_localization.htmlIf you have a question regarding this component or would like me to clarify something, just post a reply here.