Malay language in Android is not working

More
7 years 3 months ago #1998 by gfaraj
Hello,

I've added the "Malay" language with "ms" code to the I2 localization settings. All my terms are translated to that language, yet when I change the language of my Android device to "Bahasa Melayu" my application is still using the English texts.

Do you know why this would happen?

Thanks,
George

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #2000 by Frank
Hi,

I've added the "Malay" language with "ms" code to the I2 localization settings. All my terms are translated to that language, yet when I change the language of my Android device to "Bahasa Melayu" my application is still using the English texts.


When the plugin tries finding the device language by name it will compare "Bahasa Melayu" to "Malay" and that will be different, so that language will not be found.

The plugin will also try to compare by language code, but if your device is reporting a language with the region, then that could fail (I will investigate this case a bit more and add to the new release that it fallback to the language without a region). But at this moment, the plugin could be trying to compare "ms" to "ms-BN" or "ms-MY").

Could you try either changing the name of the language to "Behasa Melayu" or making the language code "ms-MY"?

I will try reproducing this and get back to you with a better detection for that case.

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #2001 by gfaraj
I'll be testing with changing the language name to Bahasa Melayu and the code to "ms-MY" and I'll let you know in a little bit.

The plugin will also try to compare by language code, but if your device is reporting a language with the region, then that could fail (I will investigate this case a bit more and add to the new release that it fallback to the language without a region).


I thought this was how it worked? If not, is there a reason why it doesn't work that way? For example, I just have 1 translation for French as "fr" but if I change my device to "French (Canada)" it still works correctly. I'm guessing this is because of the language name and not the code. I do strongly suggest you make the language fall back to the generic language without a region in this case. Maybe as a configurable option.

Thanks for the response!

George

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #2002 by gfaraj
The change to the name and language code didn't work. I'm not sure what's wrong.

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #2003 by Frank

I thought this was how it worked? If not, is there a reason why it doesn't work that way? For example, I just have 1 translation for French as "fr" but if I change my device to "French (Canada)" it still works correctly. I'm guessing this is because of the language name and not the code.


That's exactly how the system is implemented. If there is no direct match, then a loose matching is done by removing the region.
inter-illusion.com/assets/I2Localization...InitialLanguage.html

I just checked the code and tested in the editor and its working as described. Will test in the device again now.


BTW, Remember that the language is only detected if you haven't previously selected a language. If you open your game, change the language with a button inside your game, then I2 Localization will remember that choice and will use it from that point on, discarding the device language.
If you did that, then you will have to delete the game from the device and reinstall again so that the PlayerPrefs get cleared.

Another possibility is that the language code that your android is reporting is the "ms". Can you place a log to see what it is reporting?

You can place it in the function SelectStartupLanguage() in file LocalizationManager.cs line 160.
Just change it by this one:
        static void SelectStartupLanguage()
		{
			// Use the system language if there is a source with that language, 
			// or pick any of the languages provided by the sources

			string SavedLanguage = PlayerPrefs.GetString ("I2 Language", string.Empty);
			string SysLanguage = Application.systemLanguage.ToString();
			if (SysLanguage=="ChineseSimplified") SysLanguage = "Chinese (Simplified)";
			if (SysLanguage=="ChineseTraditional") SysLanguage = "Chinese (Traditional)";

Debug.LogFormat("SysLanguage: {0}, Saved {1}", SysLanguage, SavedLanguage); 

			// Try selecting the System Language
			// But fallback to the first language found  if the System Language is not available in any source

			if (HasLanguage (SavedLanguage, Initialize:false))
			{
				CurrentLanguage = SavedLanguage;
				return;
			}

			// Check if the device language is supported. 
			// Also recognize when not region is set ("English (United State") will be used if sysLanguage is "English")
			string ValidLanguage = GetSupportedLanguage(SysLanguage);

Debug.LogFormat("Valid Language: {0}", ValidLanguage); 

			if (!string.IsNullOrEmpty(ValidLanguage))
			{
				SetLanguageAndCode( ValidLanguage, GetLanguageCode(ValidLanguage), false);
				return;
			}
Debug.LogFormat("Nothing found: selecting the first language in the Source"); 

			//--[ Use first language ]-----------
			for (int i=0, imax=Sources.Count; i<imax; ++i)
				if (Sources[i].mLanguages.Count>0)
				{
					SetLanguageAndCode( Sources[i].mLanguages[0].Name, Sources[i].mLanguages[0].Code, false);
					return;
				}
		}


If you run your game with that modification and then check the device logs, you will know what path it takes and if the problem is that its not finding the language or reverting to one previously selected.

Nonetheless I will try reproducing this as well.

Hope that helps,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

More
7 years 2 months ago #2005 by gfaraj
Here's what the log is saying:

01-25 11:19:27.261 20111-20142/? I/Unity: SysLanguage: Unknown, Saved

(Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
01-25 11:19:27.296 20111-20142/? I/Unity: Valid Language:

(Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)
01-25 11:19:27.296 20111-20142/? I/Unity: Nothing found: selecting the first language in the Source

(Filename: ./artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)


It looks like the problem is with Unity's Application.language returning Unknown. That is strange.

Please Log in or Create an account to join the conversation.

Time to create page: 0.149 seconds
Template by JoomlaShine