Page 1 of 2

Localization revert to default fails

Posted: Sat Oct 05, 2019 7:55 pm
by Thistis
Hello,
I wanted to test localization of UI elements with Text Tables, but I ran into a problem. Resetting to default language after switching languages doesn't seem to work. I'll explain what I did so far:
Image

I have this simple options menu with 3 buttons, English, Deutsch (German language) and Back. In this menu, I want to set the player language before the game starts. For this, I did the following:

- create a Text Table called "UI elements" with two languages, Default (I didn't change that one) and de (german). I translated the fields accordingly.

- Added a Localize UI script to the button "Back" that links to the field "Back" in my Text Table

- Add an OnClickListener to the language Buttons, which will call the following methods in my Menu.cs file:

Code: Select all

    public void English() {
        DialogueManager.SetLanguage(""); //I've tried this also with DialogueManager.SetLanguage(null);
        Debug.Log("Language set to english");
    }

    public void German() {
        DialogueManager.SetLanguage("de");
        Debug.Log("Language set to german");
    }
- Added the Text Table to the Localization Settings in my Dialogue Manager
Image

- Added a Localization UI Manager to my Dialogue Manager to save language settings and add the table here as well (not sure if any changes need to be done here or in the Localization settings)
Image

When I start now a new game, a scene is loaded with my main menu, the default language is English. Then I want to go to the options menu (a second scene) and change the language. On the option screen, the following works:

Testcase #1
- click on "Deutsch" button
- back button text changes to german translation
- I get the log message that the language is set to german
- clicking on back button button shows the german translation of the main menu.

But this doesn't work
Testcase #2
- go to options menu
- click on "Deutsch" button
- I get the log message that the language is set to german
- change your mind and click on "English" button again
-> the text of the back button stays in german language. Also, I don't get a log message that the language was set to english

But still it somehow does seem to change the language, if I click on the back button after doing testcase 2, the main menu is in English. Also when I go back to the options menu again (loading options scene), I cannot successfully click on "English" after having clicked on "German" in the same run.

But I'm wondering, why it is not working on the same screen, whereas it is working fine for setting a defined language. As written above, I tried both options, DialogueManager.SetLanguage("") and DialogueManager.SetLanguage(null), the result stays the same. Am I missing something here? How can I make the UI update in the same screen? In my opinion, it only seems to work if I first try to set the language to English before German, but then it never works again.

All the best,
Evelyn

Re: Localization revert to default fails

Posted: Sat Oct 05, 2019 9:05 pm
by Tony Li
Hi Evelyn,

That's an oversight in the LocalizeUI component. I'll post a patch here by tomorrow.

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 8:44 am
by Tony Li
Hi Evelyn,

This patch allows DialogueManager.SetLanguage("") to revert to the default language:

PixelCrushers_LocalizeUI_Patch_2019-10-06.unitypackage

It's also available on the Dialogue System Extras page. The change will be in the next Dialogue System update, too.

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 9:46 am
by Thistis
Hello Tony,

thank you very much for the speedy reply and the patch, it works like a charm now :)

All the best,
Evelyn

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 10:09 am
by Thistis
Hello Tony,

I just tried again and found one other minor little issue:

- I start the game and see the main game screen (one scene) with choices: New game, continue game, options, end game
Image

- I go to the options screen (loading second scene) and set the language to German
Image
- I click on the back button (loading main game screen)
- On the main game screen, I see the german translations and start a new game ("Neues Spiel", loading first level scene)
Image
- In the level I talk with an NPC, I see german dialogue, it looks fine
- I pause the game (UI overlay over current scene) and select go back to main menu (load main game screen)
- When I'm back in the main game screen, the button labels are sudenly english again.
Image
- If I click on options though to change it, I can see that it still is german (the back button has the german translation) and if I start a new game again
Image

All buttons in the main menu have the Localize UI script for the text fields, but I guess else it also wouldn't work in the first place. Do you have any idea, why suddenly the UI semi-switches back to english text? I have tried to Reset Language PlayerPrefs in the Localization Settings of the Dialogue Manager and also used Tools - Pixel Crushers - Dialogue System - Tools - Clear Saved Localization Settings to make sure that nothing is left from my previous attempts.

All the best,
Evelyn

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 10:32 am
by Tony Li
Hi Evelyn,

I don't know. Are the main menu and options menu in a separate scene? Or are they inside a Canvas that gets carried across scene changes? Are they in a prefab that gets instantiated?

Have you by any chance configured it so the Dialogue Manager GameObject disppears when the player returns to the main menu? (I'm fishing for possibilities. This isn't likely, but I thought I'd ask.)

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 1:29 pm
by Thistis
Hello Tony,

yes the main menu and options menu are two different scenes. They are no prefabs, just scenes that are loaded when needed.

Regarding the Dialogue Manager, it is instantiated as a singleton and if I watch the game in play mode, it is the same Dialogue Manager all the time. When I go back into the main menu after having started a game in german, the Dialogue Manager still shows german as set language, but the menu appears in english in Main Menu.

Re: Localization revert to default fails

Posted: Sun Oct 06, 2019 2:12 pm
by Tony Li
Your setup sounds correct.

Would you please try out these test scenes?

DS_TestLocalization_2019-10-06.unitypackage

Import it into Unity, then add scenes 00 MainMenu, 01 Options, and 02 Gameplay to the build settings. Then play 00 MainMenu. It appears to work correctly here. If it works correctly for you, too, please compare it to your scenes for any differences.

Re: Localization revert to default fails

Posted: Mon Oct 07, 2019 5:33 pm
by Thistis
Hello,

I just tried your test package and the package worked fine.
I tried to adapt it by replacing your 02 Game scene by one of my game scenes and to load your 00 MainMenu scene from my ingame menu. But then it will also show again the incorrect text translation on the first screen (00 MainMenu), on 01 Options it is correct as it is in my game.

I still need to further investigate this. The Dialogue Manager stays the same object the whole time and also displays "de" as set language.

Re: Localization revert to default fails

Posted: Mon Oct 07, 2019 5:40 pm
by Tony Li
Please feel free to send a reproduction project to tony (at) pixelcrushers.com. I'll be happy to take a look. You can zip up the Assets, Packages, and ProjectSettings folders; I won't need any other files or folders.