• 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
Question by GutoThomas · Jun 21, 2012 at 01:49 PM · stringlanguage

What's the best way to create multi-language support for your games?

Hey everyone! I'm with some tricky question here. I was thought about what's the best way to put an option to language selection for subtitles and texts. Obviously, this is not hard at all, but I was thinking about the best way to change between every language supported.

For each text, I thought in an array of string with n elements, where n is the number of languages supported, but I don't know how expensive is this for the memory to manage(seems pretty expensive), so I wish someone could guide through this, giving me some hints and a way which can give good results without killing the performance in mobile devices, for example.

I also bring some code. The idea I passed above:

 public class languageManager : UnityEngine.MonoBehaviour {
 
     public enum Language {
         
         English,
         Portuguese,
         Spanish
         
     }
     
     private static Language _curLanguage;
 
     public string[] MENU_Play;
     public string[] MENU_Options;
     public string[] MENU_Quit;
     public string[] MENU_Credits;
 
     [...LOTS OF MORE ARRAYS ABOVE...]
     
     public string getText(string[] texts, Language language) {
         
         return texts[(int)language];
         
     }
     
     public string getTextInCurrentLanguage(string[] texts) {
         
         return texts[(int)_curLanguage];
         
     }
     
     public static Language currentLanguage {
         
         get { return _curLanguage; }
         set { _curLanguage = value; }
         
     }
     
 }

Thanks for any help!

Comment
Alexei_UA

People who like this

1 Show 0
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

1 Reply

  • Sort: 
avatar image
Best Answer

Answer by Tim-Michels · Jun 21, 2012 at 02:26 PM

A common way that is used is to have an XML-file for each language. The XML-file should contain every phrase you use in your game with a unique ID.

In your code, you can then get the correct phrase out of the current language's XML, using the correct ID.

Comment
GutoThomas

People who like this

1 Show 3 · 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 GutoThomas · Jun 21, 2012 at 02:35 PM 0
Share

This would be possible for mobile, as well?

avatar image programmrzinc · Jun 21, 2012 at 02:41 PM 1
Share

the above answer should work for both desktop and mobile formats.

avatar image GutoThomas · Jun 21, 2012 at 03:21 PM 0
Share

Great! I don't know nothing about .xml sintax but I start searching about it, just to get used to. I came up with this:

 <menu>
     <mainMenu> Play </mainMenu>
     <mainMenu> Options </mainMenu>
     <mainMenu> Credits </mainMenu>
     <mainMenu> Quit </mainMenu>
 </menu>

Something like this is right?

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How can I convert UTF8 string to arabic? 2 Answers

FormatException: Input string was not in the correct format 1 Answer

String.Split With Backslash 2 Answers

What is string? 5 Answers

GameObject.name to string 2 Answers


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