Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
3
Question by Elum224 · Jun 18, 2014 at 10:45 AM · language

Using Application.systemLanguage returns Unknown

On Android if I get the string of .systemLanguage while my phone is set to German it returns unknown. Is there some other way to get the language? Or is there some issue with Unity?

I'm feeling it is something with Unity as I am partly sure I have had my localisation swapping dependant on what language my phone was set to.

If it is just broken in Unity how else can I get the devices language?

Edit: I'm using the Nexus 4 (Android 4.3) with Unity 4.3.0f4

Comment
Add comment · Show 1
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 JPBA1984 · Aug 10, 2017 at 05:19 PM 0
Share

Here is way to get actual data for debuggin or for searching your localizations: string localization = Application.systemLanguage.ToString();

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by Bunny83 · Jun 18, 2014 at 11:57 AM

Well, just tried it on my Nexus7 and it worked well. However i still use Unity 4.3.4f1 but i'm just downloading Unity 4.5.1 as i write this ;)

Keep in mind that systemLanguage isn't a string! It's a enum. However if you "concat" a string with an enum value it will be converted to a string:

     GUILayout.Label("systemLanguage :"+Application.systemLanguage);

This prints "systemLanguage :German" for me. I usually have set the language to English and it also prints correctly if i set the language to English.

edit
Just installed Unity 4.5.1f3 and it still works for me just fine. You might want to try my MobileStats app (just made a fresh build) and see if it works for you. I added the system language as the last point in the general info box.

second edit

I just wrote two helper functions which uses the JNI interface to query the system language directly from the JAVA environment:

 // C#
 // returns "en" / "de" / ...
 public static string GetLanguage()
 {
     #if UNITY_ANDROID
     try
     {
         var locale = new AndroidJavaClass("java.util.Locale");
         var localeInst = locale.CallStatic<AndroidJavaObject>("getDefault");
         var name = localeInst.Call<string>("getLanguage");
         return name;
     }
     catch(System.Exception e)
     {
         return "Error";
     }
     #else
     return "Not supported";
     #endif
 }
 
 // returns "eng" / "deu" / ...
 public static string GetISO3Language()
 {
     #if UNITY_ANDROID
     try
     {
         var locale = new AndroidJavaClass("java.util.Locale");
         var localeInst = locale.CallStatic<AndroidJavaObject>("getDefault");
         var name = localeInst.Call<string>("getISO3Language");
         return name;
     }
     catch(System.Exception e)
     {
         return "Error";
     }
     #else
     return "Not supported";
     #endif
 }


Comment
Add comment · Show 4 · 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 Elum224 · Jun 24, 2014 at 02:01 PM 0
Share

The point of the question is that the value is SystemLanguage.Unkown ins$$anonymous$$d of SystemLanguage.German Why is Unity not able to detect the language?

avatar image Bunny83 · Jun 24, 2014 at 04:51 PM 0
Share

And my answer clearly said that it does work. If it doesn't work on your device it's most likely something with your device. You didn't even tell us what device you're using and what Android version.

Do you have any security addons or a custom Android version? Have you tried my test app? Does it also say $$anonymous$$?

ps: you should never do a language selection only based on what's the system's language. You should always provide an in game menu to select a language. You can use Application.systemLanguage to do a preselection but forcing it to the system language is always a bad idea.

I always have my system language set to english, however i'm german as well.

You can always use a native plugin or use JNI to query values from the Android SD$$anonymous$$ such as the system language. I'll add an example to my answer.

ps: I've updated my test app which now includes the 2 and 3 character language code returned by getLanguage and getISO3Language

avatar image Elum224 · Jun 26, 2014 at 09:29 AM 0
Share

Thanks for the updated answer. I'm using the Nexus 4 (Android 4.3) to test this. Other (non unity) apps were switching happily when the system was in German mode. I'm using AppLock as a security add on. Does that affect Unity's ability to detect language? The example code gave "de" and "deu" respectively. Either way I'll use the method in the Stackoverflow answer.

Thanks for the response (even with my lack of details!)

Oh and there will indeed be a button to choose language!

avatar image andrew_pearce · May 09, 2021 at 04:48 AM 0
Share

Thank you! You saved my day! There are no Farsi (Persian, "fa") and Tagalog (Filipino, "tl") in Application.systemLanguage so the only way to detect those languages was to use native code for the case when Application.systemLanguage equals to SystemLanguage.Unknown.

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

25 People are following this question.

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

Related Questions

What is Mono? Is it a compiler? A language? Or what? 3 Answers

adding localization 1 Answer

how to transfer data to unity efficiently 1 Answer

Embedding scripting language (webgl-compatible) 3 Answers

Unity2019.3 and I18N.dll 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