What is Localization?
For all practical purposes, Localization is the process of making your software application available in multiple languages. Localization is sometimes used interchangeably with internationalization (a word so long it is often abbreviated to i18n). To get a bit nit-picky, i18n is the process of designing and developing a software that can then be localized into different languages. In this post I simply refer to the whole process as Localization.
I will also focus on the development aspect of localization. Localization involves translators and potentially artists and voice actors to create content that needs to get localized in other languages.
Since Unity is cross platform, it needs to have its own localization features. However as of yet, localization is not included in the Unity Editor. So how should you localize you Unity application? in this blog post we will discuss the options in detail.
What Needs to Be Done
The most fundamental task for localization is to remove “string values” (a.k.a. text) from code and your game objects and replace them with “unique ids” which can then be replaced by text depending on the language.
Take the simple menu in the above picture. Instead of having “Resume”, “Settings” and “Exit” as literal texts in the text boxes, we replace them with ids which we can later at runtime replace when we know the current user’s language. Ids could be string values themselves such as “menu_resume”, “menu_settings”, etc.
The same technique of referencing string values by id at development time and loading the actual string value at runtime can be used for any resource type. AudioSource, Sprites, Textures, Colors and pretty much anything that needs to change depending on the user’s language can be referenced by a unique id. The actual resource will then be loaded at runtime when the language is known.
For those of you who know programming, let’s create a very basic localization tool here.
Essentially we created a class which keeps a map from language and ids to the actual text for the UI. In
Start this localizer component will set the text of its
Text component to the appropriate value.
OnValidate Unity message handler makes it work at edit time. Here is a screenshot of our basic 30 line localization tool!
Do I Need a Localization Tool?
This decision depends on various factors:
- The size of your project.
- The amount of work that is needed for localization.
- importance of having accurate localization for the success of your game.
A simple one file solution like the one above will work for you if you are working on a small hobby project you want to put on itch.io.
If you have a larger project, with many engineers and translators working independently on it to localize into say 20 languages, having the translations in external files which get fetched at runtime would make the system more robust.
Localization in Unity
Having the essentials of localization covered, let’s look at different options you have for localizing your Unity game.
1) Write your own code
Mentioning briefly here in case you skipped over the previous parts. Video games can have minimal text and speech. Graphics are often universal and don’t need to be localized. You don’t need to localize anything for shooting down enemies in an FPS and hear their screams of pain. All that remains is the text in the menus.
- You don’t have to learn a new tool.
- Its lightweight and easy to implement if you are a decent programmer.
- You need to spend development time on localization. You still need to detect and save language, handle corner cases where a resource id is missing, etc.
- You will be limited to the most basic localization features.
- You need to know programming.
2) Unity’s Official Localization Package (still in preview August 2020)
Unity has a localization package in development which you can add through its package manager. You can find it here. The package is still in preview with no clear timeline for release. In the long run this will probably become the de-facto localization solution for Unity and be the foundation for other localization tools and assets.
The package uses addressable assets under the hood and essentially give you the map from resource id and language to the actual resource in a fancy and robust way. It needs quite a bit of tweaking to get it setup for your project. So the initial setup is less than ideal for a small team and beginner developers.
- It is official so it has good support and integration into Unity Editor.
- It is free.
- It is still in beta (August 2020)
- Not beginner friendly. You need to know some coding.
- Initial setup is currently a bit cumbersome. You’d have to go through some hoops to get it working.
A great aspect of developing in Unity is the amazing community that surrounds it. As with any other missing functionality, you bet there are developers and artists out there that filled the gap. As with Localization, there are 20+ assets on the asset store! Ranging from basic implementations that give you a class with a
Dictionary to l2 localization which seems to be the most feature rich of the assets at a $45 price point.
It is tricky to pick a good asset. And doubly tricky for me to suggest one to you as I am the author of “No Such Localization” asset on the Unity asset store (third result in the search in the picture above, there is free version too!). I want to keep this post informational rather than promotional, so I leave it to you to pick an asset.
- You get many features and save development time with the right asset.
- The assets are usually beginner friendly and easy to ramp up on.
- You still need to learn a new tool. Maybe not as complex and bare bone as the current Unity package, but still.
- Not always free. Some assets are free and some are paid.