The best way to do localization in Unity
Asked Answered
N

4

6

I am building an android game with unity and I would like to add 1 or more language. I tried the smart localization asset in the asset store. I was searching for an asset that would allow me to edit language directly from the text component (in the editor) but I couldn't find so I tried this: Find all the text Components on the scene and change the text according to the user preferred language. For example I don't put the real text in the buttons but the unique key of the text and the scripts will do the change in his start method. But I wonder if this is the better to do localization.

Nomadic answered 9/10, 2016 at 8:49 Comment(2)
What you're describing are Resource files (.resx) that will allow you to maintain string key/value pairs for runtime localization. You can support a variety of languages while keeping your application dynamic. Take a look at msdn.microsoft.com/en-us/library/fw69ke6f.aspx or search SO or the interwebs for additional examplesSulfate
AFAIK resx files aren't really an option with Unity3d.Amorphous
R
4

(Update Sept 2020) How you go about localization really depends on your project. I've since written a blog post on the subject here. It includes a basic 50 line localization tool for Unity.

Nowadays there are a few localization packages for Unity.

I think the best asset to use is No Such Localization. It is simple yet powerful. (Disclaimer I am the creator of the asset).

Unity has a localizaition package (as of Sept 2020 still in preview). Still janky but will probably become the de-facto localization package in the long run.

Reinke answered 17/6, 2020 at 21:22 Comment(0)
A
2

I would strongly advise against embedding text into your code. It will make your life harder and slow down the localization process (having to look through code to find text is not the quickest and best way to approach localization).

Go with separate files. It makes updates/changes easier and faster, without having to access the code.

Have you tried l2 localization? It's a handy Unity plugin, pretty similar to Smart Localization, that allows you to manage translations of your game.

You can have all your localized strings in a single Google Spreadsheet. Once set up, all you need to do is fill it out to see the results in the game.

I am a game translator myself and happen to be managing a small team of game translators called Level Up Translation. We posted a beginner's guide for localization in Unity in our blog a couple of months ago. Feel free to check it out!

Aplanospore answered 1/3, 2017 at 16:26 Comment(0)
S
1

Since it is third result on "Unity Localization" search I would like to share my 5 cents on this topic.

First of all, I definitely agree with Damien Yoccoz opinion regarding having the text in the code directly or in Unity Text components - simply don't do this if you want to translate your game. Let me propose a solution I used in one of my recent games:

  1. Create property files with languages you want to support. Those files will have key-value structure, (e.g. greetings=Hello!)
  2. Create a script - let's call it LangResolver - that will read those files on a game startup (e.g. in a Splash screen). This script will hold key-value pairs, so Dictionary<> will be a data structure of choice.
  3. Mark all Text components available for translation. I wouldn't go for searching all Text components, since some of them might not be needed (e.g. numbers only fields). So, another script - let's call it LangText - to bind keys from properties to Text components should be created. This script will have a public String field to identify a key from properties.
  4. Last step, LangResolver should have a method to collect all LangText on a scene, get their identifiers and set the actual text as per current system language or a language selector. This method then will be called from some other UIHandler component on a scene.

Those steps should be a good start for anyone trying to build a simple localization support, if you are searching for nice tutorial with pictures\video, here it is.

Swimming answered 15/2, 2020 at 22:44 Comment(0)
L
0

I would suggest taking a look at Unity localization package + Crowdin.

This way, you'll be able to create localization tables and preview all in Unity, while collaborating on translations in a user-friendly editor, where you can edit text components, use Machine Translation if needed, or invite your community/translation agency to make translations without the need to export the file manually and copy-paste values later.

Luane answered 4/9, 2023 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.