Running my game on iOS, where the system language is set to German, causes the Localization system to detect it as English. It does work on Android though. Where could I start looking to figure out why that is?
We only currently detect the system language, not the application preferred language. We have a bug for this that just came in yesterday so we will be looking at supporting preferred language for iOS.
How can I make my iOS app select the language that’s selected in iOS, rather than English? Unfortunately, I can’t wait for a Localization package update, I need to find a workaround as soon as possible.
In the iOS language settings, it uses German (Deutsch) for both, system and preferred language, yet the Localization system still selects English:
What’s weird is that UnityEngine.Application.systemLanguage returns the correct language, but it seems the Localization system doesn’t pick it up.
On the other hand, what I found in the Localization code is that the SystemLocaleSelector first tries to get the locale from CultureInfo.CurrentUICulture and only attempts to use UnityEngine.Application.systemLanguage in case the CurrentUICulture locale wasn’t found.
Perhaps CultureInfo.CurrentUICulture returns English on iOS always, regardless of the actual system or preferred language setting.
FYI: The CultureInfo seems incorrect on Android when using Hindi as system language. The Hindi two-letter-iso would be hi, but it returns iv. Is this a known Unity/Mono bug?
CurrentCulture.EnglishName: Invariant Language (Invariant Country)
CurrentCulture.TwoLetterISO: iv
CurrentCulture.ThreeLetterISO: IVL
CurrentUICulture.EnglishName: Invariant Language (Invariant Country)
CurrentUICulture.TwoLetterISO: iv
CurrentUICulture.ThreeLetterISO: IVL
Application.systemLanguage: Unknown
I am experiencing the same issue on macOS Ventura 13.2.1, using Unity 2021.3.27f1 Personal.
I want the display language to be Japanese when the system language is Japanese, and English otherwise.
However, even when Application.systemLanguage is Japanese, LocalizationSettings.SelectedLocale.Identifier always remains ‘en’.
I haven’t yet tested on platforms other than macOS.
Is there any way to ensure the locale matches the system language correctly?
using UnityEngine;
using UnityEngine.Localization.Settings;
using TMPro;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.Localization;
public class VersionAndLocalTextUI : MonoBehaviour
{
[SerializeField]
TextMeshProUGUI m_label;
void Start()
{
LocalizationSettings.SelectedLocaleAsync.Completed += OnLocaleSelectionCompleted;
}
void OnLocaleSelectionCompleted(AsyncOperationHandle<Locale> handle)
{
UpdateVersionAndLocaleText();
}
void UpdateVersionAndLocaleText()
{
string versionString = Application.version;
SystemLanguage systemLang = Application.systemLanguage;
var localeIdentifier = LocalizationSettings.SelectedLocale.Identifier;
m_label.text = $"{versionString}\nsystemLanguage:{systemLang}\nselectedLocale:{localeIdentifier.Code}";
}
}
What version of the package are you using? Try updating to 1.4.4. If it’s not visible in the package manager you can edit the manifest.json file in the projects Packages folder.
Thank you for your response.
I updated the Localization to version 1.4.4 by modifying the manifest.json file. I created a macOS build and ran it, but the result was the same.
Even though Application.systemLanguage is Japanese, LocalizationSettings.SelectedLocale.Identifier is still ‘en’.