Localization not working in build

The localization tool has been working great in the editor, but will not work in any of my builds.

My code test derived from the package sample:

public LocalizedString localizedText = new LocalizedString();
public Text text;

public void SetLocalizedString(string localizationTable, string localizationKey)
{
     localizedText.TableReference = localizationTable;
     localizedText.TableEntryReference = localizationKey;
       
     var stringOperation = localizedText.GetLocalizedString();

     if (stringOperation.IsDone && stringOperation.Status == AsyncOperationStatus.Succeeded)
          text.text = stringOperation.Result;
}

I have completed all steps in this thread: Troubleshooting Addressables Issues and all tables are preloaded.

The LocalizeStringEvent component does work fine in editor and build.

I have done several builds now, trying different locale selectors, cleaning and rebuilding addressables, I have been at it for a while but still no solution. These errors I receive from the build log:

Exception encountered in operation CompletedOperation, status=Failed, result= : Exception of type ‘UnityEngine.AddressableAssets.InvalidKeyException’ was thrown., Key=Locale, Type=UnityEngine.Localization.Locale

No Locale could be selected:
No Locales were available. Did you build the Addressables?

Exception encountered in operation UnityEngine.Localization.LoadTableOperation`2[UnityEngine.Localization.Tables.StringTable,UnityEngine.Localization.Tables.StringTableEntry], result=‘’, status=‘Failed’, status=Failed, result= : SelectedLocale is null

Unity 2020.3.5f1
Localization 0.11.0
Addressables 1.17.17

Thanks

Everything looks correct. You say it works using the LocalizedStringEvent but not with your script?
Are you able to share your project?

Yes I have sent you a message with a link to my project and build, thanks.

1 Like

Hi,
This is a rare issue I have only seen a few times.
The addressable group has lost its configuration, so its essentially a group that does nothing

You can see the group is blank. It should look more like this

Ill speak to the Addressables team and see if they know what could be causing it.
For now the best thing to do is delete any groups like this and then go into Tools/Analyze in the Addressables window. Run the 3 localization analyzers and apply the fixes.
Ill see if I can add a check into our analyzers for this

5 Likes

I did as you said and it works now, thanks for your help!

1 Like

Hello!

I’m currently running into the same issue. The localized strings work normally when running the game in the editor. However, the localized strings won’t work in the build (A text mentioning no entry was found in place of the string is displayed). My project looks like the ideal scenario shared in the previous screenshots on this thread. Any help would be appreciated.

Thanks in advance!

Did you build the addressables?

Hey Karl! Thanks for your answer.

I opened the Addressables Group window (Window > Asset Management > Addressables > Groups) and selected (Build > New Build > Default Build Script). Then I built my project and the localized strings now work!

Just to clarify. In the future while I continue to add new strings to my project and before I built it, Will I have to perform that same process every time? or should I instead use the option: Update a previous build?

Thanks!

7 Likes

I believe you would do the same each time. The update a previous build option is for content updates:
https://docs.unity3d.com/Packages/com.unity.addressables@1.16/manual/ContentUpdateWorkflow.html#building-for-content-updates

auto before the build

using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using System.Collections;

class BuildAddressablesProcessor
{
    /// <summary>
    /// Run a clean build before export.
    /// </summary>
    static public void PreExport()
    {
        Debug.Log("BuildAddressablesProcessor.PreExport start");
        AddressableAssetSettings.CleanPlayerContent(
            AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
        AddressableAssetSettings.BuildPlayerContent();
        Debug.Log("BuildAddressablesProcessor.PreExport done");
    }

    [InitializeOnLoadMethod]
    static void Initialize()
    {
        BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler);
    }

    static void BuildPlayerHandler(BuildPlayerOptions options)
    {
        if (EditorUtility.DisplayDialog("Build with Addressables",
            "Do you want to build a clean addressables before export?",
            "Build with Addressables", "Skip"))
        {
            PreExport();
        }
        BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
    }

}
5 Likes

Hi, I have a problem where this:


Works in Editor, but not in the Game Build. Yes, addressables are build.

I don’t think this is supported.

Locales are built into addressables so should not be referenced like this. It’s likely got 2 versions of the locale, the addressables one and the referenced one. Take a look at the samples we have, there’s some that show how to do a language selection menu.

1 Like

Thanks, that worked

1 Like

I think a default feature of the Localization package should be a prompt asking if you want to build addressables when you press “Build”

[quote=“mrCharli3, post:14, topic: 838665, username:mrCharli3”]
I think a default feature of the Localization package should be a prompt asking if you want to build addressables when you press “Build”
[/quote]in newer versions of Unity you can set addressables to auto build when you do a player build. We did have a warning about building the addressables in the localization package but it stopped working, the logic it was using to detect the addressable build seems to be obsolete.

Oh cool, any chance u could send a screengrab of where i find that setting? Im on 2021.3.13f LTS

https://docs.unity3d.com/Packages/com.unity.addressables@1.21/manual/AddressableAssetSettings.html#build

I’ve been having a similar issue to the what was initially mentioned here, I followed the instructions and that managed to address it. However I’m not running into an issue where it is no longer displaying my text in different alphabets, so Languages like English and French will work, but when I switch it to Korean, it runs my function and sets the locale, but the string fields are blank. This is only in builds,

Are you using a compatible font file for those languages?
Do you get any errors in the log file?

I am not receiving any errors in the debug log. The font I’ve had selected worked fine in the editor, but when it’s running in a build it displays a blank string, only displaying numbers in the translated sections