GetLocalizedString not making use of the Locale parameter

Unless I am mistaken, passing a Locale into GetLocalizedStringAsync should force the string with the specified key to be returned using the specified locale. In my case it is always using the currently set locale (English for this example).

The following section of code should demonstrate my issue:

         // the localeString variable is a string set to "fr"
        Locale locale = LocalizationSettings.AvailableLocales.GetLocale(localeString);           
        Debug.Log($"{locale}");  // This is printing out: French (fr)

        returnString = LocalizationSettings.StringDatabase.GetLocalizedString(
            "Example Table",
            "Example Key",
            new object[] { stepColliderReference.name, duration.ToString("0.0") ,
            locale});
           
         // this returnString is set to the currently set langue (English)
         return returnString;

I have French set up to work with the given table and it produces the French value when I switch the langue. Any help would be greatly appreciated.

Can you make sure you are using the latest version 1.3.2?

I can confirm I am on version Localization package 1.3.2

I see the problem! You are passing the locale in as a string argument

returnString = LocalizationSettings.StringDatabase.GetLocalizedString(
    "Example Table",
    "Example Key",
    new object[] { stepColliderReference.name, duration.ToString("0.0") ,
    locale});

should be

returnString = LocalizationSettings.StringDatabase.GetLocalizedString(
    "Example Table",
    "Example Key",
    new object[] { stepColliderReference.name, duration.ToString("0.0") },
    locale);

I moved the locale out of the object[ ] array so that it is the next argument.

1 Like

Oh wow silly me, thank you for catching that!

1 Like