Search Unity

Localization apply delay

Discussion in 'Localization Tools' started by dkazbek, Nov 25, 2021.

  1. dkazbek

    dkazbek

    Joined:
    Nov 23, 2021
    Posts:
    1
    I have localization like this and its work almost perfectly: upload_2021-11-25_17-27-26.png

    But when on device default localization isnt english after start of the app users see english version of the text for ~ 0.1s and after it changes to right language.
    On second load of the scene (without reboot app) all text in correct language from start.
    How I can fix this?
     
    GuirieSanchez likes this.
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    This is due to the Addressables loading. We do it asynchronously which means Unity can still run whilst the loading is happening.
    You have a few ways to handle this.
    Preloading will allow you to mark tables to be loaded at start, this will mean that things should be immediately available.
    You will still need to wait for the initialization operation to complete for Preloading. You can either implement a loading screen for this, check the package samples for an example.
    You can also set the LocalizationSettings to Initialize Synchronously(Project Settings/Localization) which will force the InitializationOperation to complete immediately when it is started but this will mean the main thread is blocked, this can make the app appear to be unresponsive if its loads a lot of data.
     
    Gamerfreund007 and DankalApps like this.
  3. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Hi @karl_jones

    I found this thread since I was experiencing exactly what was described above. It seems that the UI has changed, so the instructions in the Preloading section (in the latest version 1.5.0-pre.6 of the documentation) can't be followed for preloading the tables.

    The closest I've found to this is in the localization settings, under 'Preload Behavior' and 'Initialize Synchronously':
    upload_2024-2-3_18-25-9.png

    Unfortunately, when hitting play, the default English locale shows and after a small delay (0.5s-1s) it changes to Chinese, which is set for testing in the Awake function (I also test it on the Start function with a similar result).
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    The preload option has moved to the main table window, just under the top where you select the table. It's supposed to be easier to find :oops:
    The option is now applied to all tables instead of per table.

    We will get the docs updated before we come out of the pre-release

    upload_2024-2-3_18-37-7.png
     
    Last edited: Feb 3, 2024
    GuirieSanchez likes this.
  5. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Are we talking about this window? Sorry, I only know the 'LocalizationTable', 'locales', and 'LocalizationSettings' windows. I bet it's got to be something easy to find so my apologies
     

    Attached Files:

  6. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    Yes although that screenshot is from a pre 1.5 version. In that, you need to click the metadata button {@} next to the locale name
     
    GuirieSanchez likes this.
  7. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Thank you for the walk-through, I managed to get it working :)

    So, a quick summary. Assuming you're not using a custom loading screen and want to preload the tables so that the first thing you see is the correct locale already loaded based on
    SystemLanguage
    or user's preferences (so that you don't see that glitch-like language change on app launch).

    For this to work, there seems to be 3 steps needed:

    (1) The Preload Table checkmark of your target table(s) or the Preload All Tables checkmark enabled in the metadata button ({@}) of the 'LocalizationTables' window.

    (2) The Preload Behavior set to Preload your Selected Locale(s)/Fallbacks or Preload All Locales in the 'LocalizationSettings' window.

    (3) The Initialize Synchronously checkmark set to "enabled" in the 'LocalizationSettings' window.
     
    karl_jones likes this.
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,282
    We also have an example that shows how to do a loading screen in the package samples. They can be accessed from the package manager.
     
    GuirieSanchez likes this.