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.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
How to Translate Your Game Using the Unity Translation Package
30 mins
- Getting Started
- Your First Translation
- Installing the Localization Package
- Adding Translation
- Building the Menu
- Adding a Translation Option Menu
- Setting Up Localization Manager
- Localization Settings
- Connecting Everything
- Finding Translations
- Importing Localization Files
- Translating Dialogue
- Translating the Interaction System
- Translating NPC Names
- Translating Questions
- Habla Español?
- Where to Go From Here?
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 Assets ▸ RW ▸ Scenes. Click the Play button in the Unity editor to see the Veggie Gladiators opening 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.
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 Window ▸ Package 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.
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.
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.
Before we dive into these options, you must set up your first locales.
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.
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.
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.
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.
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 Canvas ▸ Panel ▸ Title text in the hierarchy. Then, from the Component Menu of the TextMeshPro component, the kebab menu button, click Localize.
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.
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 RW ▸ Localization ▸ Menu.
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.
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
Once you have updated the values here, you’ll see that they also updated in the 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.
Great! But now you need to set up a way for the player to choose what language to see in the game.