Getting started with Smart Localization 2.x for Unity3D

There has been quite some changes with the Smart Localization project since version 1.x. First of all, the development is no longer handled by Cry Wolf Studios. Since we decided to liquidate the studio, me(Niklas Borglund) and Jakob Hillerström decided to take over the project and release it under the developer name janeTech.

As I mentioned above, there's been some changes to the project since then. The biggest ones are:

  • We are not using the System.Globalization.CultureInfo class anymore. We are using our own class called SmartCultureInfo.

  • Everything is now encapsulated within the namespaces SmartLocalization and SmartLocalization.Editor

  • The ability to Export/Import/Update CSV files

  • Completely reworked ground for increased stability.

  • Translation Window can be used at runtime (2.1 and above)

  • Completely reworked GUI with features such as resizable column widths (2.1 and above)

To get started with Smart Localization you will have to start by downloading the project from the asset store and importing it to your project.

Once you've done that, navigate to Window->Smart Localization.

 

The window will prompt you to create a Smart Localization workspace if you haven't done so already. Follow the instructions until you see the main localization window.

Press the Edit Root Language File button. This will bring up a new window where you create all the keys and root values along with the key types for your project. We'll start by adding two keys; SmartLocalization.Welcome and SmartLocalization.LocalizedString.

Once you've done that, press save and return to the main localization window.

Now it's time to create some languages. For the purpose of this tutorial, we'll create two languages; English and Swedish. Find the two cultures in the Add/Update Languages scroll list and press Create on each one.

Now press the 'Translate' button placed on the English culture row. A new window will be brought up. Since we wrote our root values in english, all we have to do here is to press the "Copy All Values From Root" – button. Don't forget to press save and return to the main window.

Now do the same procedure with Swedish. Press Translate and write the Swedish values in the 'Value' column. If you don't know Swedish, just copy what it says in the image below or write whatever value you want. Again, don't forget to press save when you are done.

That's basically all the setup you need to get started. By now, you can open the scene LoadAllLanguages.unity that can be found in the Smart Localization package from the store and you should see the created values in the scene when you press play.

Next I'll show a basic and easy way to get the localized values from code. I'll start by creating a new script called SmartLocTutorial.cs. In the script we'll load the english language and print the two localized strings we created earlier.

Adding this script to an empty game object in your scene should produce the following output.

What if you want to switch to the swedish values at runtime? Simplest way to do that would be to expand the OnGUI method in our SmartLocTutorial script.

Play your scene again, press the Swedish button, and you should see the Swedish values on the screen.

Posted on September 16, 2014 and filed under Smart Localization.