Lean Localization: Implementing Indian Languages in Unity

Posted by The Walking Developers on February 20, 2021

We are going to implement Lean Localization in our Unity project today. Lean Localization is a localization asset, allowing you to easily add language-specific text, images, and much more.

#1. Installation

  1. Search for Lean Localization in the Unity Asset Store and then add it to your account for importing it.
  2. When you are done with it, log in to Unity with your same account and then click,
    Window > Package Manager > Lean Localization > Import

When it's done, you should see something like this in your Assets folder.

Now, we will move to the part on how to implement it.

#2. Implementation

Now, that we are going to implement this in our Unity project, I went ahead and made a simple scene with UI elements such as Canvas, Panel, Text, and Buttons.

  1. Now, go ahead and make an Empty Game Object and name it as LeanLocalization as you can see in the Hierarchy scene below.

2. Now, Find a script named as LeanLocalization in your Lean assets folder.
Assets > Lean > Localization > Scripts > LeanLocalization.cs

3. Now, add this script to your LeanLocalization Game Object that you just made a few moments ago. It all should look like this now.

4. Now, from the Inspector tab of LeanLocalization Game Object, you would see various fields to play with.

Click the Button Add and select English and then click Add again, but this time select Others.. and then name it as Hindi, now repeat this again for 2 more Others.. and name them as Marathi and Gujrati. Now, your Languages panel should look like something like this.

5. Set your Current language and Default Language from the inspector tab as English or any language that you want your project to be in Default. Like this,

6. The last field in the Component, you would see something called Translations, type something that would make you remember it for different texts. As for me, I like to keep the same as my texts in Unity.
For this project, I would write Languages and then click Add

It would open up like this,

7. Click Create to every language and Add translations for the text. I used Google Translate to translate my text Languages. It should look something like this,

Now, you are 70% done with the Implementation. Hang on a little more.

8. Now, click your text that you want the translation to be done, and add a script called as Lean Localized Text or you can drag and drop from the location to the inspector tab of text.

Assets > Lean > Localization > Scripts > Behaviours > LeanLocalizedText.cs

9. There are two fields in that script on the tab, On the option Translation Name, Click List and then select the name that you added in your Lean Localization GameObject in Translation. Mine looks like this,

We are now, 85% done.

10. Now, Select your button from the scene and we are going to play with onClick() here. Drag and drop your LeanLocalization GameObject to that None field or choose it.

Example: I'm adding this object to my English Button.

11. Now, Click No Function and select Lean Localization, and from that Choose SetCurrentLanguage(String) and add English to your Field. Like this,

12. Now, do the same for all the buttons. And add their name in the field.

We are now 99% done with our implementation, now whats that left is that you go ahead and run your Unity project and click those buttons and watch your texts go in different Indian languages

In the end, I would really want to thank Carlos Wilkes for making an exceptional plugin that not only helps with the text localization but also, image, sound, and sprite localization with Language detection and much more.

Image placeholder

Danish Shaikh

Undergraduate Computer Engineer, I love learning and developing games and web applications. I've always been fascinated by the web and the endless possibilities that it offers. I am always exploring different tools and technologies and experimenting around with them.