Unity 4.3.0f4 Application.systemLanguage returns Unknown on Android

Hi,

I really don’t want to believe that this is an issue again. :-x But on all of my Android devices I get “Unknown” from Application.systemLanguage. Can anyone confirm this?

Ben

I’m experiencing the same issue on this Unity build.

Yup

Oh so I’m not the only one…yes I can confirm this bug. Did some of you already send a bug report?

Anyone reported this as a bug? Could you post the bug number if you have.

What about iOS?

I submitted it: http://fogbugz.unity3d.com/default.asp?576515_2s1bv3fiq6hps1pc

@MrEsquire: on iOS it works fine, the problem is only on Android.

When I run a android app created with 4.3 on my Droid 2 it locks up my Droid and I have to take the battery out to start the Droid. I am about to put 4.2 back on. Too many bugs in 4.3.

same here. f***ed up on andriod

Funny thing is, this bug #576515 to be found here: http://fogbugz.unity3d.com/default.asp?576515_2s1bv3fiq6hps1pc is not findable in the new and shiny issue tracker to vote for.

the ticket was created yesterday and if i sort the issues in the tracker it is not among the ones from yesterday.

I have the same problem on Android. I reported this really severe bug a week ago and my ticket is still open! It seems to happen on ALL Android devices - this bug must effect a whole lot of developers. It’s a shame they couldn’t make a hotfix yet. This delays our next update, as we have already updated other tools for Unity 4.3 and we don’t want to go back to v4.2

same here…our next update is also delayed! I have only three words for this…WTF

Bug has been already fixed, but for now you can workaround the problem by grabbing the language through JNI.

AndroidJavaObject locale = new AndroidJavaClass("java/util/Locale").CallStatic<AndroidJavaObject>("getDefault");
string language = locale.Call<string>("getLanguage");

Issue tracker only includes cases, which were confirmed by QA and converted to bugs, otherwise were would be a lot of sensitive or useless information in there.

This code returns the language code (e.g. “en”) and not the language name (e.g. “English”) as Application.systemLanguage.ToString() would.
Here is a more transparent fix :

#if UNITY_ANDROID
	// bugfix for Unity 4.3
	AndroidJavaClass localeClass = new AndroidJavaClass("java/util/Locale");
	AndroidJavaObject defaultLocale = localeClass.CallStatic<AndroidJavaObject>("getDefault");
	AndroidJavaObject usLocale = localeClass.GetStatic<AndroidJavaObject>("US"); 
	string systemLanguage = defaultLocale.Call<string>("getDisplayLanguage", usLocale);
#else
	string systemLanguage = Application.systemLanguage.ToString();
#endif

Unity 4.3.1 was released and I still have the same problem. Language is always Unknown on Android devices. Could someone confirm that ?

yeah, its a joke…

Jaro, I confirm I still have the same problem with Unity 4.3.1. However the fix I posted some days ago is totally transparent. I use it in production code without any problem. [quote=“Jaro, post:15, topic: 520249, username:Jaro”]
Unity 4.3.1 was released and I still have the same problem. Language is always Unknown on Android devices. Could someone confirm that ?
[/quote]

Hello, thanks for the code!

Application.systemLanguage returns not String - it returns SystemLanguage.

To make the code compatible with Application.systemLanguage I have made some changes.

In fact, I am not completely sure that getDisplayLanguage() result names are completely identical with “SystemLanguage” values… But on my devices with Russian locale this code is working OK.

Please, confirm this for your devices/languages…

static SystemLanguage GetApplicationSystemLanguage() {
	#if UNITY_ANDROID  ! UNITY_EDITOR
		// bugfix for Unity 4.3
		AndroidJavaClass localeClass = new AndroidJavaClass("java/util/Locale");
		AndroidJavaObject defaultLocale = localeClass.CallStatic<AndroidJavaObject>("getDefault");
		AndroidJavaObject usLocale = localeClass.GetStatic<AndroidJavaObject>("US");
		string systemLanguage = defaultLocale.Call<string>("getDisplayLanguage", usLocale);
		SystemLanguage code;
		try {
			code = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), systemLanguage);
		} catch {
			code = SystemLanguage.Unknown;
		}	
	#else
		SystemLanguage code = Application.systemLanguage;
	#endif
	return code;
}

FINALLY FIXED in Unity 4.3.3

It is fixed in Unity3d 4.3.3

check release notes,
http://unity3d.com/unity/whats-new/unity-4.3.3