iOS: Localization uses English always, regardless of system language

Unity 2019.4.20f1, Localization 1.0.4, Addressables 1.19.9

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?

Running this code:

yield return LocalizationSettings.InitializationOperation;
yield return LocalizationSettings.StringDatabase.PreloadOperation;
yield return LocalizationSettings.SelectedLocaleAsync;
       
Debug.LogFormat("Application: {0}", Application.systemLanguage);
Debug.LogFormat("Localization: {0}", LocalizationSettings.SelectedLocale.Identifier.Code);

Outputs on iOS:

Application: German
Localization: en

Here is my Localization setup:

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.

1 Like

Thank you for the reply.

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:

I have not had a chance to fully look into it yet but I believe you can do something like this:

Then create a custom locale selector that uses this value.
https://docs.unity3d.com/Packages/com.unity.localization@1.0/api/UnityEngine.Localization.Settings.IStartupLocaleSelector.html

Although, if the Application.systemLanguage is working correctly then you could modify the SystemLocaleSelector to use that before the CultureInfo

Thank you for the reply.

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

Yeah this sounds very familiar. I think theres an IL2CPP bug with CultureInfo.CurrentUICulture. Ill see if I can dig it out.

Found it Unity Issue Tracker - Globalization.CultureInfo.CurrentCulture does not map to system language on OSX

Wont fix :frowning:
Seems to be a Mono bug. Maybe we can add our own workaround for IOS

1 Like

Thank you for the quick reply, much appreciated!

1 Like

I’m giving it another shot:
(Case 1376786) CultureInfo returns “Invariant Language” instead of the actual language

1 Like

Was this bug fixed? I have a similar issue with WebGL build.

1 Like

This bug has been fixed https://issuetracker.unity3d.com/issues/android-mono-currentculture-returns-invariant-language-instead-of-the-actual-language-when-running-app-on-android

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’.

9136573--1268917--スクリーンショット 2023-07-10 19.56.49.png

It sounds like a bug. Could you please file a bug report? Unity QA: Building quality with passion

1 Like

I submitted a bug report.

1 Like