Just recently, I learned about localizing games made with Unity, a flexible real-time development platform that streamlines and simplifies the game development process. Two teammates and I decided to test our newly acquired skills and embarked on a mission to localize Jumping Giraffe, a 2017 2D open-source game we found on UnityList, into Arabic, French, and Russian. We were aware from the beginning that Unity does not have its own built-in solution for localization. For us to progress, we started out by evaluating the game’s-readiness for localization. The game consists of 7 main scenes and there are few strings in the code, but most of the strings were in the UI.  When we started looking at the game, we knew that there was zero support for Arabic in Unity, and by that, I mean text display and text direction. So, we knew that we needed to fix this problem before starting any internationalization or localization work.

Preparation

Luckily, we had access to the I2 Localization plugin, an easy and powerful localization system that includes all the necessary tools for localization. We were extremely happy with the plugin when we learned about it, however, it did not take us long to realize that the plugin alone won’t be able to meet some of our localization needs.

The plugin is powerful. It was mostly straight forward to add French and Russian support. However, adding Arabic was another story. Although the plugin has support for RTL languages and the code has methods to deal with Arabic, the text direction and the orientation were LTR instead of RTL.

We researched how others solved Arabic localization problems with Unity. We found this free feature-complete Arabic Plugin named “Arabic Support for Unity” on the Unity Asset Store. The plugin has a method ArabicFixer.Fix(“”) that you can annotate strings in the code with, to correct the orientation and connect the Arabic letters.

Original Arabic text display (i.e disconnected letter, LTR)
Corrected Arabic display

Workflow

The ArabicFixer plugin and the I2 plugin did not play well together for two reasons:

a) Since the only way to use ArabicFixer is to annotate the strings in the code, the Arabic fixer script gets invoked even for non-Arabic script-based languages, causing them to not be displayed properly.

b) Since the I2 plugin claims to include Arabic support, it actually reversed the impact of the ArabicFixer. Additionally, ArabicFixer only works in code, this means that any UI strings won’t be fixed.

To overcome these issues, we consulted with an engineer who strongly advised against embedding text into the code and advised instead to do the following:

a) We changed the ArabicFixer plugin to check if the string to fix only contains Arabic characters. If the string didn’t contain any Arabic characters, we return the string as is.

b) We changed the Text rendering class in Unity to have it call the ArabicFixer before it returns the rendered text. This simple change prevented us from wrapping each and every code string with the ArabicFixer method. This brilliant fix made the process more dynamic, reducing recoding and adaptation time.  

Adding the “ArabicFixer” function to Unity’s text rendering component

c) We changed the I2 plugin to disable RTL fixing by default.

Disabling RTL fixing from the I2 plugin

Attaching text objects to the UI

Unity does a good job recognizing text objects. For us to get around the localization of UI the elements, we created a variable for each UI element in the corresponding script for the scene and each variable had a string value, thus changing every UI string to be a code string. After getting this step done, we went back again to Unity and we attached each text object to UI element on the specific canvas. The below picture shows our workaround.

Attaching text objects to the UI

After fixing issues with RTL and UI strings, we were finally able to work on internationalization and localization.  

All strings that appear in code were externalized using the I2.Loc.LocalizationManager.GetTranslation(“”) method, and then adding the keys and their translations in the three languages in the language source of the I2 package.

Adding keys

After thoughts

I am really glad that I have learned so much about Unity working on this game. Even though my workaround seems to be long, it gave me the opportunity to work with C# and to really think outside of the box but not relying entirely on the two plugins I used. However, now that I am looking back, we needed to spend some time exploring the I2 plugin. It seems to be a powerful tool and we might have only needed to invest some time to fix issues with RTL to make the most out of the plugin. We also could not figure out how to make the languages appear in-language, something that we learned later from some of our colleagues and could easily be done in Unity.

Even though Unity does not have its built-in localization environment, it still supports the process by allowing you to create components, which cuts out a good chunk of the manual coding process.