GooRain
November 19, 2020, 1:50pm
1
Hello! I’m using 0.9.0-preview version, and having problem with selecting locale according to system language: it’s always selecting “en-US” even if setting system language to other languages.
i have tried using link.xml with:
link.xml
and
link.xml
1 Like
GooRain
November 19, 2020, 3:05pm
3
This code seems to be working!
private IEnumerator Start()
{
yield return LocalizationSettings.InitializationOperation;
var cultureInfo = GetSystemCulture();
var systemLanguage = GetApplicationSystemLanguage();
Debug.Log($"CultureInfo: {cultureInfo} SystemLanguage:{systemLanguage}");
if (systemLanguage != SystemLanguage.Unknown)
{
var locale = LocalizationSettings.AvailableLocales.GetLocale(systemLanguage);
if (locale != null)
{
Debug.Log($"Set Locale: {locale}");
LocalizationSettings.SelectedLocale = locale;
}
}
}
GooRain:
This code seems to be working!
private IEnumerator Start()
{
yield return LocalizationSettings.InitializationOperation;
var cultureInfo = GetSystemCulture();
var systemLanguage = GetApplicationSystemLanguage();
Debug.Log($"CultureInfo: {cultureInfo} SystemLanguage:{systemLanguage}");
if (systemLanguage != SystemLanguage.Unknown)
{
var locale = LocalizationSettings.AvailableLocales.GetLocale(systemLanguage);
if (locale != null)
{
Debug.Log($"Set Locale: {locale}");
LocalizationSettings.SelectedLocale = locale;
}
}
}
I think there’s a long-standing bug with CultureInfo returning en-US instead of the correct culture.
Are you using IL2CPP?
GooRain
November 19, 2020, 3:42pm
5
Yes, on iOS we are using IL2CPP.
Ah yes, it sounds like the bug.
1 Like
Hello,
looks like the System Locale Selector doesn’t work in the package of version 1.2.1 if the target locale can’t be converted into a CultureInfo.
For example, I can’t use the Crimean Tatar language (crh). At the same time, Apple does recognize it. The language is included in ISO 639-2 and ISO 639-3 standards
Hey. Could you please file a bug report so we can look into this?
Hey. I have also set Specific locale selector and whenever I start the app it changes to English. The Localization version is 1.3.2
If you want it to use Greek then you need to drag it to be the top or it will only use Greek when the other selectors can not find a locale.
Hey Karl. I did put it on top but it doesnt work. The only way to set it is use something like this at the beginning
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.Greek);
Also there is another strange bug in my application and I am not sure why this is happening. These line cause the program to freeze. I call them in the Start function. This works normally in the android build but not in the iOS one.
if (LocalizationSettings.SelectedLocale == LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.English) )
{
m_Dropdown.value = 1;
}
else
{
m_Dropdown.value = 0;
}
AR_Tehcnoplus:
Hey Karl. I did put it on top but it doesnt work. The only way to set it is use something like this at the beginning
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.Greek);
Also there is another strange bug in my application and I am not sure why this is happening. These line cause the program to freeze. I call them in the Start function. This works normally in the android build but not in the iOS one.
if (LocalizationSettings.SelectedLocale == LocalizationSettings.AvailableLocales.GetLocale(SystemLanguage.English) )
{
m_Dropdown.value = 1;
}
else
{
m_Dropdown.value = 0;
}
In the screenshot it’s not at the top, it needs to be where the command line selector is.
The pause is likely because you have not waited for the initialization operation to complete and so it’s forcing it synchronously.
Try yielding on LocalizationSettings.InitalizationOperation.
Are you using 1.3.2?
1 Like
karl_jones:
In the screenshot it’s not at the top, it needs to be where the command line selector is.
The pause is likely because you have not waited for the initialization operation to complete and so it’s forcing it synchronously.
Try yielding on LocalizationSettings.InitalizationOperation.
Are you using 1.3.2?
The pause was fixed ! i didn’t know that it was an asynchronous operation. Thank you for your help Karl!
1 Like