How to Translate Your Game with Unity Localization
In this article
This guide walks you through adding multi-language support to your Unity game using the official Unity Localization package. By the end, you'll have a game that can switch languages at runtime, with text and UI elements properly translated. You'll need Unity 2019.4 or newer and a project you're ready to modify.
What You'll Need
- Unity Editor (2019.4 LTS or later)
- An existing Unity project (any template works)
- Basic familiarity with Unity's Inspector and Scene view
- Optional: a text editor for managing translation files
Step-by-Step
- Install the Localization package. Open your project in Unity. Go to Window > Package Manager. In the top-left dropdown, select "Unity Registry". Search for "Localization" and click Install. Wait for it to finish importing.
- Create a Localization Settings asset. In the Project window, right-click in any folder and choose Create > Localization > Localization Settings. Name it "LocalizationSettings" (or anything you like). This asset will hold your locale list and tables.
- Add locales. Select the settings asset. In the Inspector, under Locale Generator, click Add Locale. Choose the languages you want (e.g., English, Spanish, French). You can select multiple at once. Click Generate to create locale assets for each.
- Open the Localization Tables window. Go to Window > Localization > Localization Tables. This window lets you manage your translation strings.
- Create a String Table Collection. In the Tables window, click New Table Collection. Name it "UI Text" (or similar). Choose "String Table" as the type. Click Create. This creates a set of tables, one per locale.
- Add your strings. In the Tables window, you'll see a spreadsheet-like view. Click Add New Entry to add a key (e.g., "StartGame"). Then fill in the translation for each locale column. For example, "Start Game" for English, "Comenzar Juego" for Spanish. Repeat for every string in your game.
- Replace hardcoded text with LocalizedString. In your scripts, instead of
public string myText = "Hello";, usepublic LocalizedString myText;. Then assign the key in the Inspector. For UI Text components, you can also use the Localize String Event component (see next step). - Use the Localize String Event component (optional but recommended). Select a UI Text object in your scene. In the Inspector, click Add Component and search for "Localize String Event". Add it. Drag the Text component into the On Update String event field, select
Text.textas the method. Then in the String Reference field, assign the key you created. Now that text updates automatically when the language changes. - Set the default locale. In your Localization Settings asset, under Locale Selector, choose "Player Pref" or "System Locale" as the initial selection method. For testing, you can also manually set the locale in code:
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[1];(0 = first locale, 1 = second, etc.). - Test your translations. Play your game. If you used the code above, the language should switch at runtime. To test manually, you can add a simple UI dropdown that sets the selected locale.
- Build your game. When you build, make sure the Localization package is included. Unity does this automatically. Your translations will be embedded in the build.
Common Mistakes
- Forgetting to assign the LocalizedString key. If you leave the key empty, the string will be blank in-game.
- Using the same key for different contexts. For example, "Play" as a verb vs. a noun. Create separate keys like "PlayButton" and "PlayNoun".
- Not updating all locale columns. If you add a new entry and only fill English, other languages will show the key name (e.g., "StartGame") instead of a translation.
- Modifying the locale assets directly. Locale assets are generated; edit them via the Tables window only.
- Using TextMeshPro without the add-on. If you use TextMeshPro, you need to install the "Localization" package's TMP support (available in the package's Samples). Otherwise, text won't update.
Tips
- Use a naming convention for keys, like "UI_StartGame" or "Dialog_NPC1_Greeting". This keeps things organized.
- Export your tables to CSV for easy translation by external translators. In the Tables window, click Export and choose CSV.
- Test with a language that has longer text (e.g., German) to ensure your UI layouts can handle text expansion.
- Use the LocalizedString class in scripts for dynamic strings (e.g., player names) with
GetLocalizedString(). - For pluralization, use the Plural Form feature in the tables (available in the entry's properties).
Troubleshooting
- Text not changing when I switch locale. Check that you have a Localize String Event component on the object, and that the event is wired correctly. Also ensure the key exists in the table.
- I see the key name (e.g., "StartGame") in-game. This means the key is not found in the selected locale's table. Verify the table collection is assigned in the Localization Settings, and that the locale has a translation for that key.
- Package not showing up in Package Manager. Make sure you selected "Unity Registry" in the dropdown, not "My Registries".
- Build fails with localization errors. Check the Console for missing table references. Re-import the Localization package if needed.
- TextMeshPro text doesn't update. Install the TMP sample from the Localization package: In Package Manager, select Localization, go to Samples, and import "TextMeshPro". Then use the Localize String Event with TMP_Text instead of Text.
Frequently Asked Questions
Can I translate audio or images?
Yes, the Localization package supports asset tables for sprites, audio clips, and other assets. Create a new Asset Table Collection and assign assets per locale.
How do I add a new language after I've started?
Go to your Localization Settings asset, click Add Locale, generate the new locale, and then open the Tables window. The new locale will appear as a new column; fill in translations for existing entries.
Can I use Google Translate to fill in translations?
You can, but be cautious. Machine translations may be inaccurate. It's better to have a native speaker review them. You can export to CSV, translate, and import back.
Does the package work with Unity's UI Toolkit?
Yes, but you need to use the LocalizedString class in your UI Toolkit code. There is no drag-and-drop component like for UGUI Text.
How do I change the language at runtime from a button?
Create a script that sets LocalizationSettings.SelectedLocale to the desired locale from a list. Attach this to a button's onClick event.
Will localization slow down my game?
No, the package is optimized. String lookups are fast, and you can preload tables to avoid runtime loading delays.