How to Translate Your Game Using the Unity Translation Package

Welcome to the wild world of localization, where Veggie Gladiators are about to prove that vegetables aren’t just for salads, but for speaking multiple languages too! Picture this: your game is a hit in Tokyo, and suddenly the Veggie Gladiators have to fight in a sushi bar. Without localization, they’ll be lost in translation faster than a potato in a fruit salad. So, let’s arm our Veggie Gladiators with languages and take over the global gaming arena, one veggie at a time! By Ben MacKinnon.

Leave a rating/review
Download materials
Save for later
Share

Accessibility is an important topic in gaming, from friendlier control schemes to subtitles and color-blindness settings. But while developers add these settings, so many games overlook supporting multiple languages, particularly in the mobile games scene. With the Unity Localization package and a simple Google Spreadsheet, you can begin supporting multiple languages in your game with no cost to your development budget!

Getting Started

In this tutorial, you’ll learn about the Unity Localization package and how you can use it to set up translations not only of UI and other text but also of runtime assets. You’ll read about different ways to import localized strings from professional platforms in the XLIFF format before trying the free method for yourself with a Google Sheet integration.

You’ll use a project from our Unity Apprentice book for this tutorial. Download the sample project using the link at the top or bottom of this tutorial. Open the starter project and then the Title Scene at AssetsRWScenes. Click the Play button in the Unity editor to see the Veggie Gladiators opening menu.

The current title menu

Click New Game to head into the dining hall, where you control a Potato Warrior. Walk around the scene using WASD. Walk up to any NPC and initiate a conversation by pressing space bar.

Conversing with vegetables

Some of the conversations have multiple lines of dialogue with user input required, so spend some time walking around and discovering all the interesting dialogue. Once you’ve learned all you can from your fellow veggies, exit play mode.

Now, your task is to add some additional language support to this project.

Your First Translation

First up, you’ll need to add the Unity Localization package to the project.

Installing the Localization Package

This can be done by opening the Package Manager by selecting WindowPackage Manager. Ensure Packages: Unity Registry is selected, then scroll down the list to find the Localization package. Select it and click Install to add the latest package version to the project.

Installing the Localization Package

Once the package has been imported, you need to set up the Localization Settings Asset. Unity saves these settings as a serialized asset, so any changes to your localization settings can be monitored through source control.

First, create a new folder under the RW folder and name it Localization.

Then, open the Project Settings from the Edit menu, and select Localization on the list. Click Create and save the new Localization Settings file into the Localization folder you just created.

Create Localization Settings

You’ll see that the Project Settings Localization window will now update to show many options for localization. Selecting the new file in the Project window will also make these options appear in the Inspector window.

The Localization Settings Window

Before we dive into these options, you must set up your first locales.

Note: A locale represents a language and an optional region. They can also contain additional information, such as currency, calendar, and user-added custom data.

Click the Locale Generator button to open a new window. In the Locale Generator window, select English (en), which is the current and default language of the project, and German (de). Then click Generate Locales.

Save the new assets to the same Localization folder as before.

Locale Generator Window

However, German words are typically longer than those in other languages. So, German translations can be a great way to check if your app’s UI is flexible enough to handle any translation.

Note: Why German? In truth, it may not be the most commonly spoken language by your app users. Ultimately, it’s down to you to decide what languages to support using analytics of the demographics of your user base. Or maybe you want to target a specific region with your app, so you should support those locales.

With the new Locale files created for English and German, you then need to select the default locale for the project. In the Localization Settings window again, add the English (en) locale to both the Specific Locale Selector and Project Locale Identifier options.

Add the default locale to the Localization Settings window

With that, you are now ready to add your first translation!

Adding Translation

The Title menu currently only has two pieces of text that can be translated. The title and the New Game button.

Both of these are using a TextMeshPro component to render the text. The Localization Package is built to work directly with TextMeshPro and Legacy Text components, as they are the most likely things you’ll need to localize.

Select the CanvasPanelTitle text in the hierarchy. Then, from the Component Menu of the TextMeshPro component, the kebab menu button, click Localize.

Localize a TextMeshPro component

This will add a new component to the Title GameObject, the LocalizeStringEvent. This is the main component for driving the localization across your project. When adding it through the TextMeshPro menu, it automatically assigns a callback to its UpdateString method to update the text value of the TextMeshPro component.

Localize String Event

However, there’s one last thing to do before you can start translating the values in these text components. You’ll notice that the two dropdowns for String Reference and Table Collection have no selectable values. That’s because you first need to create a collection to work from!

Click Create Table Collection to open up the Localization Tables window. Name this new table UI Strings and save it into a new folder at RWLocalizationMenu.

New string table

You’ll notice that it automatically selects the locales you set up earlier. The table will be populated with a column for each locale the app supports.

Created Table

With the table now set up, keep the Localization Tables window open and navigate back to the Title text. You’ll now be able to select the UI Strings table from the Table Collection dropdown. Once you have, the button below will change to Add Table Entry.

Click Add Table Entry. The component will change visually once more, enabling you to enter an Entry Name and a value for each locale. Fill in the new fields with the following values:

  • Entry Name: Title
  • English(en): Veggie Gladiators
  • German(de): Gemüse Gladiatoren

New String Entry

Once you have updated the values here, you’ll see that they also updated in the table.

Entry in Table

Now, you’ve set up your first translated string in Veggie Gladiators! Click Play in the Unity Editor, and you’ll see that a new dropdown appears in the game window. This will let you change the loaded locale at any point.

Change Language in Play mode

Great! But now you need to set up a way for the player to choose what language to see in the game.

Contributors

Ben MacKinnon

Author and Topics Master

Gijs Bannenberg

Tech Editor

Adriana Kutenko

Illustrator

Toby Flint

Final Pass Editor

Over 300 content creators. Join our team.