Forum rules - please read before posting.

Language switching (synchronized with Unity Localization package) fails the first time it's used.

Hello! I've been following the tutorial and successfully managed to synchronize Unity's localization Package with Adventure Creator, and I'm able to add the translations to the text lines without issue.

However, there is a weird bug where the first time I click on the Language button on the menu (the basic one that the game has), the Unity Localization Package does detect the change, but Adventure Creator half-does.

I tracked down the MenuElement script and added a debug log onto one of the functions it calls when the language changes (I apologize, I do not remember which), and the function does get called and the language changes for the Localization package, but its not until the second click that Adventure Creator changes language.

In short:

  • I have 3 languages: Spanish, Catalan and English. They are in this order both in the Adventure Creator and in the Localization Package.
  • Localization package is set to initialize with Spanish as the default all the time.
  • Adventure Creator has the "Auto-sync locale with Language?" checkbox active.
  • Gathered all the text with the options:
    Translatable Text types: Everything.
    ID Number Recycling: Never.
    Matching text ID merging: Always Merge.

  • Added a few of the translations using the Localization.

  • When starting the game, it starts in Spanish.
  • I go to the options menu and click once on the Language button: now the Localization and text on the button indicates the Language has changed to Catalan, but the text in-game stays the same.
  • I click on the language button again: now the Localization and text on the button indicates the language is English, but the text in-game displays the Catalan text.
  • I click again: Localization and text button indicate Spanish, but the language in-game is now the English one.

Basically, since it takes one click for the translation to actually happen, the game is always "behind" the actual language that should happen. I tested disabling one language so it was only two or gathering the text without merging the IDs, and the same happened.

It is important to notify that this issue was NOT happening when I tried the translations with only Adventure Creator without the Localization package.

  • Unity version: 2022.3.25f1
  • Adventure Creator version: 1.80.4
  • Unity Localization Package version: 1.4.5

Comments

  • Thanks for the thorough write-up.

    The Language/Locale sync should be one-way, so I'm not immediately sure as to how this behaviour is happening. It's only when AC's language itself changes, that the Locale is affected.

    • In the Speech Manager, is Spanish the default language because it's a rename of the default "Original" language, or because you've disabled the "Original" language, still listed separately?
    • Is the Language button's text, which displays the active language name, added to the Localization tables - or is it pulled from AC's Speech Manager?

    If you're going through the code to try to see what's going on: the synchronisation takes place in RuntimeLanguage's SetLocalCo function. Placing Debug.Log ("Set Locale index: " + index); at the top of it may help give a clue as to what's going on.

  • Yeah, I imagine this is quite the weird bug.

    In the Speech Manager, is Spanish the default language because it's a rename of the default "Original" language, or because you've disabled the "Original" language, still listed separately?

    Spanish is a rename of the "Original" language. It is written as "Español", but so are all the others in their respective languages (Catalan is written as "Català", and English to, well, "English").

    Is the Language button's text, which displays the active language name, added to the Localization tables - or is it pulled from AC's Speech Manager?

    The button itself (so, the "Language" part) is translated through the tables ("Idioma", "Llengua", etc.). The language name is NOT translated through the tables, using AC's Speech Manager directly since they're already in their respective languages.

    I also tested adding the Debug.Log mentioned above:

    • When starting the game, it's called two times one right after the other. With the game in Spanish it calls index 0, which is correct.
    • After that, each click calls it once, updating the index correctly, including looping as it should.
  • edited May 7

    The button itself (so, the "Language" part) is translated through the tables ("Idioma", "Llengua", etc.). The language name is NOT translated through the tables, using AC's Speech Manager directly since they're already in their respective languages.

    What's the exact text in full (i.e. "Language: The language") at each state? You're welcome to share screenshots on imgur if it's easier.

    After that, each click calls it once, updating the index correctly, including looping as it should.

    To be clear: 1, 2, 0, 1 etc?

    When starting the game, it's called two times one right after the other. With the game in Spanish it calls index 0, which is correct.

    Start in Spanish, click once to Catalan. Exit Play mode and re-enter - does the Debug.Log start with index 1?

    It's also possible to see the current language index from within the Save-game File Manager, available at the top of the Settings Manager. Is that showing the correct index?

  • What's the exact text in full (i.e. "Language: The language") at each state?

    Starting with the Localization in Spanish, it reads:

    • At start, Idioma: Español
    • Click 1, Idioma: Català
    • Click 2, Llengua: English
    • Click 3, Language: Español

    To be clear: 1, 2, 0, 1 etc?

    Yep, exactly that as can be seen above.

    Start in Spanish, click once to Catalan. Exit Play mode and re-enter - does the Debug.Log start with index 1?

    Correct, the index value is 1 and the Localization indicates it is the Catalan language.

  • If the "Language:" label is pulled from Localization, and the actual language name itself is from AC, then it sounds like the other way around - AC is updating, but Localization is one click behind. Or am I misinterpreting?

    I think the best way for me to get to the bottom of this is for me to see it for myself. Are you able to PM me a .zip of the project? The Library folder and art assets can be omitted to reduce file size.

  • Hi again! Sorry for going radio silent, stuff came up.

    To begin, sadly the project is under NDA, so for the time being I can't share anything.

    However, I did eventually find a solution! On a clean branch (created a new project and just added the translation tables) the issue kept happening, so I tested with an ActionList and found out you can change the language with one action.

    So I created a PopUp with 0, 1 and 2 and when clicking the language button, I call the action to change to the next language twice, one after another. This thankfully resolved the issue.

    (I'm calling it two times in a row in all languages because after trying it on the first one and working, it was the second language that suddenly didn't change on the first click).

  • I've managed to recreate this.

    Looks to be a case of the order in which events are hooked up. The Menus are updated while Locale is being set - but the latter is asynchronous process and can take a frame or two to occur.

    I'll see this remedied in the next update - thanks for helping me to track this bug down.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.