NGUI has a built-in localization system that allows you to easily define strings for each label in different languages.
The localization system works with a Localization.txt
file with this structure:
KEY,English,Francais
For example, if we wanted to localize our main menu's title, we would add this line in the Localization.txt
file:
MainMenu_Title, "Main Menu", "Menu Principal"
Let's create this localization file. Navigate to your project's Assets
folder and create a new Resources
folder. Inside this new folder, create a new Localization.txt
file and open it. Add these lines in it:
KEY,English,Francais
Francais, "French", "Francais"
English, "English", "Anglais"
MainMenu, "Main Menu", "Menu Principal"
On the first highlighted line, we define our two languages. The next three lines define our localization keys and their two different values: one in English
and the other in French
.
OK, the localization file is ready. Now, let's see how to assign a key to a label...