Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Localization not working in build

Discussion in 'Localization Tools' started by csmith747, Apr 28, 2021.

  1. csmith747

    csmith747

    Joined:
    Mar 27, 2021
    Posts:
    5
    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:

    Code (CSharp):
    1. public LocalizedString localizedText = new LocalizedString();
    2. public Text text;
    3.  
    4. public void SetLocalizedString(string localizationTable, string localizationKey)
    5. {
    6.      localizedText.TableReference = localizationTable;
    7.      localizedText.TableEntryReference = localizationKey;
    8.        
    9.      var stringOperation = localizedText.GetLocalizedString();
    10.  
    11.      if (stringOperation.IsDone && stringOperation.Status == AsyncOperationStatus.Succeeded)
    12.           text.text = stringOperation.Result;
    13. }
    I have completed all steps in this thread: https://forum.unity.com/threads/troubleshooting-addressables-issues.1060346/ 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
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Everything looks correct. You say it works using the LocalizedStringEvent but not with your script?
    Are you able to share your project?
     
  3. csmith747

    csmith747

    Joined:
    Mar 27, 2021
    Posts:
    5
    Yes I have sent you a message with a link to my project and build, thanks.
     
    karl_jones likes this.
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    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
    Screen Shot 2021-04-28 at 15.31.50.png

    You can see the group is blank. It should look more like this
    Screen Shot 2021-04-28 at 15.32.14.png

    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
     
    Last edited: Apr 28, 2021
  5. csmith747

    csmith747

    Joined:
    Mar 27, 2021
    Posts:
    5
    I did as you said and it works now, thanks for your help!
     
    karl_jones likes this.
  6. TortugaXel

    TortugaXel

    Joined:
    Oct 18, 2013
    Posts:
    4
    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!
     

    Attached Files:

  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Did you build the addressables?
     
  8. TortugaXel

    TortugaXel

    Joined:
    Oct 18, 2013
    Posts:
    4
    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!
     
  9. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    I believe you would do the same each time. The update a previous build option is for content updates:
    https://docs.unity3d.com/Packages/c...ateWorkflow.html#building-for-content-updates
     
  10. denis_bogdanov

    denis_bogdanov

    Joined:
    Apr 20, 2015
    Posts:
    139

    auto before the build

    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEditor.AddressableAssets;
    3. using UnityEditor.AddressableAssets.Settings;
    4. using UnityEngine;
    5. using System.Collections;
    6.  
    7. class BuildAddressablesProcessor
    8. {
    9.     /// <summary>
    10.     /// Run a clean build before export.
    11.     /// </summary>
    12.     static public void PreExport()
    13.     {
    14.         Debug.Log("BuildAddressablesProcessor.PreExport start");
    15.         AddressableAssetSettings.CleanPlayerContent(
    16.             AddressableAssetSettingsDefaultObject.Settings.ActivePlayerDataBuilder);
    17.         AddressableAssetSettings.BuildPlayerContent();
    18.         Debug.Log("BuildAddressablesProcessor.PreExport done");
    19.     }
    20.  
    21.     [InitializeOnLoadMethod]
    22.     static void Initialize()
    23.     {
    24.         BuildPlayerWindow.RegisterBuildPlayerHandler(BuildPlayerHandler);
    25.     }
    26.  
    27.     static void BuildPlayerHandler(BuildPlayerOptions options)
    28.     {
    29.         if (EditorUtility.DisplayDialog("Build with Addressables",
    30.             "Do you want to build a clean addressables before export?",
    31.             "Build with Addressables", "Skip"))
    32.         {
    33.             PreExport();
    34.         }
    35.         BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
    36.     }
    37.  
    38. }
     
  11. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    Hi, I have a problem where this:
    upload_2022-5-17_23-24-51.png
    Works in Editor, but not in the Game Build. Yes, addressables are build.
     
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    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.
     
    stroibot likes this.
  13. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    Thanks, that worked
     
    karl_jones likes this.
  14. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
  15. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    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.
     
  16. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Oh cool, any chance u could send a screengrab of where i find that setting? Im on 2021.3.13f LTS
     
  17. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
  18. Fejes

    Fejes

    Joined:
    Jan 25, 2022
    Posts:
    4
    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,
     
  19. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Are you using a compatible font file for those languages?
    Do you get any errors in the log file?
     
    Last edited: Feb 13, 2023
  20. Fejes

    Fejes

    Joined:
    Jan 25, 2022
    Posts:
    4
    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
     
  21. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Would it be possible for you to share a simple project that demonstrates the problem? It would be much appreciated as it will help us to more effectively troubleshoot and resolve the issue.
     
  22. Fejes

    Fejes

    Joined:
    Jan 25, 2022
    Posts:
    4
  23. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Did you build the addressable assets? It sounds like it's not finding them.
     
  24. Fejes

    Fejes

    Joined:
    Jan 25, 2022
    Posts:
    4
  25. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
  26. uncolike

    uncolike

    Joined:
    Jan 17, 2020
    Posts:
    31
  27. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
  28. topboyz

    topboyz

    Joined:
    Sep 6, 2018
    Posts:
    4
  29. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    That's an unusual error. Did you switch unity version? Try clearing and rebuilding the addressables.
    It may be worth updating to the latest patch release.
     
  30. topboyz

    topboyz

    Joined:
    Sep 6, 2018
    Posts:
    4
    thanks for your quick reply!
    Yes it works now,Idk why!
    thanks sir :)
     
    karl_jones likes this.
  31. HannaJordan

    HannaJordan

    Joined:
    Apr 19, 2023
    Posts:
    1
    -Make sure you have updated the localization package to the latest version (1.4.3) and cleaned and rebuilt the addressable assets after that.

    -Make sure you have enabled the option to auto build addressable assets when making a player build in the addressable assets settings.

    -Check that you have added all the localization tables to an addressable assets group and set them the correct labels.

    Best regards, Hanna from CodeIT
     
  32. magister_yoda_

    magister_yoda_

    Joined:
    Mar 27, 2016
    Posts:
    32
    Hello @karl_jones. Can you please help me with addressables as I think I don't understand something.

    Look, in my project I have both local and remote Addressable groups. Also I'm using Localization. Suppose I run DefaultBuildScript to build addressables. Then I upload remote bundles to server, build my game for Android and everything works fine.
    But after some time I realize that I have to change some remote content (in remote addressable group) and change some texts in a localization table (which are local addressable group). When I run UpdatePreviousBuild and build my game for Android, the game throughs exception like
    "RemoteProviderException : Invalid path in AssetBundleProvider: /bla-bla-bla/aa/Android/localization-string-tables-russian(ru)_assets_all_0783fc7a55d068b3fc710a3dbe0540fc.bundle'."
    And if run DefaultBuildScript the game starts working just ok.
    Finally the question, why the UpdatePreviousBuild doesn't work for local group changes OR I have to use UpdatePreviousBuild only for remote content?
     
  33. Meurer

    Meurer

    Joined:
    Nov 30, 2014
    Posts:
    10
    My project works normally the first time I compile it, the second time I compile it there is a problem and it doesn't find the localization.
     
  34. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Can you share the editor log file?
     
  35. nexasoft

    nexasoft

    Joined:
    Jan 8, 2019
    Posts:
    6
    Hi, I build the localization addressable but it still gives error

    upload_2023-11-22_12-31-39.png


    2023-11-22 11:46:37.156 6153-6180/? E/Unity: OperationException : Addressables - Unable to load runtime data at location UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[[UnityEngine.AddressableAssets.Initialization.ResourceManagerRuntimeData, Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]].


    2023-11-22 11:46:37.185 6153-6180/? E/Unity: UnityEngine.AddressableAssets.InvalidKeyException: Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown. No Location found for Key=Locale


    2023-11-22 11:46:37.208 6153-6180/? E/Unity: OperationException : ChainOperation failed because dependent operation failed


    2023-11-22 11:46:37.245 6153-6180/? E/Unity: No Locale could be selected:
    The following (3) IStartupLocaleSelectors were used:
    UnityEngine.Localization.Settings.CommandLineLocaleSelector
    UnityEngine.Localization.Settings.SystemLocaleSelector
    UnityEngine.Localization.Settings.SpecificLocaleSelector


    2023-11-22 11:46:37.284 6153-6180/? E/Unity: OperationException : SelectedLocale is null. Could not load table.
     
  36. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Sounds like an issue with the addressables configurations. Can you share a screenshot of the addressables settings asset properties?

    Or you can share the project.
     
  37. nexasoft

    nexasoft

    Joined:
    Jan 8, 2019
    Posts:
    6
    sure, is this want you want to see?
     

    Attached Files:

    • 1.png
      1.png
      File size:
      85.9 KB
      Views:
      30
    • 2.png
      2.png
      File size:
      106 KB
      Views:
      32
  38. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
  39. nexasoft

    nexasoft

    Joined:
    Jan 8, 2019
    Posts:
    6
    yeah, playing in editor everything is working, I'm using the update existing build. But when I build it gives the error in logcat android studio. My project is kind of big, is it possible for a live chat?
     
  40. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142
    Im not sure I would be able to help, you would need to speak to someone on the addressables team.
    Does it work if you do a full rebuild instead of updating the existing build?
     
  41. nexasoft

    nexasoft

    Joined:
    Jan 8, 2019
    Posts:
    6
    I even clean build and build using default build script, still contain those errors. May I know how I can communicate with someone on addressable team?
     
  42. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,142