Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by jeromeboe · Sep 18, 2016 at 04:02 PM · xmllocalizationlocaleinternationalization

Best practice to internationalize(I18n) a unity project?

Hi, I already read many threads about this subject, but all of them was written 2 or 3 years ago. Does unity integrate a tool to handle internationalization properly?

All the solutions I read suggest loading files manually, parsing txt files, or hardcoding static strings, this looks a bit old fashion.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
5

Answer by 0xsven · Oct 02, 2016 at 12:30 PM

Hi @jeromeboe

About one year ago I was working on my first Unity Game Ducklings which we translated into 12 langauges. I am currently in the process of building a new game and so I will reuse the method.

I used MoonGateLab's solution, which worked very well! It uses JSON files that are loaded at the start of your game.

It depends a little on how you built your scenes. I added a I18nManager.cs to my scene which worked like that:

 using UnityEngine;
 using UnityEngine.UI;
 using TMPro;
 using Mgl;
 using ArabicSupport;
 
 public class I18nManager : MonoBehaviour {
 
     private I18n i18n = I18n.Instance;
 
     [SerializeField] private Text title;
     [SerializeField] private Text settingsText;
 
     private void Start () {
         Messenger.AddListener<string>("Language:Change", SetLanguage); // event when langauge change
         InitLanguage();
         arabButtonText.text = ArabicFixer.Fix(arabButtonText.text);
     }
 
     private void SetLanguage (string locale) {
         PlayerPrefs.SetString("Language", locale);
         I18n.SetLocale(locale);
         DoTranslations();
     }
 
     private void DoTranslations () {
         title.text = i18n.__("Ducklings");
         settingsText.text = i18n.__("Settings");
     }
 
     private void InitLanguage () {
 
         if (PlayerPrefs.HasKey("Language")) {
             SetLanguage (PlayerPrefs.GetString("Language"));
             return;
         }
 
         // Use system language:
         //Debug.Log("Current System Language: "+Application.systemLanguage);
 
         switch (Application.systemLanguage) {
             // case SystemLanguage.Afrikaans: SetLanguage(""); break;
             case SystemLanguage.Arabic: SetLanguage("ar"); break;
             // case SystemLanguage.Basque: SetLanguage(""); break;
             // case SystemLanguage.Belarusian: SetLanguage(""); break;
             // case SystemLanguage.Bulgarian: SetLanguage(""); break;
             case SystemLanguage.Catalan: SetLanguage("es"); break;
             case SystemLanguage.Chinese: SetLanguage("zh"); break;
             // case SystemLanguage.Czech: SetLanguage(""); break;
             // case SystemLanguage.Danish: SetLanguage(""); break;
             // case SystemLanguage.Dutch: SetLanguage(""); break;
             case SystemLanguage.English: SetLanguage("en"); break;
             // case SystemLanguage.Estonian: SetLanguage(""); break;
             // case SystemLanguage.Faroese: SetLanguage(""); break;
             // case SystemLanguage.Finnish: SetLanguage(""); break;
             case SystemLanguage.French: SetLanguage("fr"); break;
             case SystemLanguage.German: SetLanguage("de"); break;
             // case SystemLanguage.Greek: SetLanguage(""); break;
             // case SystemLanguage.Hebrew: SetLanguage(""); break;
             // case SystemLanguage.Hungarian: SetLanguage(""); break;
             // case SystemLanguage.Icelandic: SetLanguage(""); break;
             // case SystemLanguage.Indonesian: SetLanguage(""); break;
             case SystemLanguage.Italian: SetLanguage("it"); break;
             case SystemLanguage.Japanese: SetLanguage("jp"); break;
             case SystemLanguage.Korean: SetLanguage("ko"); break;
             // case SystemLanguage.Latvian: SetLanguage(""); break;
             // case SystemLanguage.Lithuanian: SetLanguage(""); break;
             // case SystemLanguage.Norwegian: SetLanguage(""); break;
             // case SystemLanguage.Polish: SetLanguage(""); break;
             case SystemLanguage.Portuguese: SetLanguage("pr"); break;
             // case SystemLanguage.Romanian: SetLanguage(""); break;
             case SystemLanguage.Russian: SetLanguage("ru"); break;
             // case SystemLanguage.SerboCroatian: SetLanguage(""); break;
             // case SystemLanguage.Slovak: SetLanguage(""); break;
             // case SystemLanguage.Slovenian: SetLanguage(""); break;
             case SystemLanguage.Spanish: SetLanguage("es"); break;
             // case SystemLanguage.Swedish: SetLanguage(""); break;
             case SystemLanguage.Thai: SetLanguage("th"); break;
             case SystemLanguage.Turkish: SetLanguage("tr"); break;
             case SystemLanguage.Ukrainian: SetLanguage("ru"); break;
             // case SystemLanguage.Vietnamese: SetLanguage(""); break;
             case SystemLanguage.ChineseSimplified: SetLanguage("zh-si"); break;
             case SystemLanguage.ChineseTraditional: SetLanguage("zh-tr"); break;
             case SystemLanguage.Unknown: SetLanguage("en"); break;
             
         }
 
         // Sanity check:
         if (!PlayerPrefs.HasKey("Language")) {
             SetLanguage ("en");
         }
 
     }
 }

For arab support I found this extension which I integrated with MoonGateLab's code like so:

 public string __(string key, params object[] args)
 {
     //...

     if (config[key] != null)
     {
 
         //....

         if (_currentLocale == "ar") {
             translation = ArabicFixer.Fix(translation);
         }


Then I used a service like https://phraseapp.com/ which uses native speakers to translate your english JSON file to any language you want. (Spent about 12 dollars per language). The nice thing is that it provided the JSON files in the right format. So all I had to do is click the download button and save it in my assets folder. Very robust solution I think.

Took a day to implement. Three days for the translations. Cost about 150 Dollars.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Nananaaa · Oct 05, 2016 at 12:19 PM 0
Share

Thank you for sharing this! Strange though that unity doesn't have a built in solution for a common task like i18n.

avatar image Omar47i · Jan 17, 2017 at 04:48 PM 0
Share

Thanks @0xsven, i implemented your solution and it works great!

avatar image
2

Answer by ditzel · Oct 14, 2017 at 12:41 PM

Hi,

I use this class for all my projects: I18n.cs

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I determine the current locale, or at least the currency symbol? 4 Answers

Line break in xml 1 Answer

Localize iOS App name from Unity 1 Answer

How to preload language? 0 Answers

How to switch language in-game using official unity localization 0.9? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges