Localization doesn't work on Scene Change

I have the settings to select the language in the main menu it works fine in the main menu when I change the language from English to Portuguese, but when I change the scene the language reverts back to English(default), even though The selected language shown above in the Editor is Portuguese.

Another Problem is Sometimes When I show 2 Text boxes one after another when Portuguese is selected, The first one appears in Portuguese but the second one appears in English even though again The selected language shown above in the Editor is Portuguese.


How are these text boxes being localized? Are you using a LocalizedStringEvent or a custom script?
When you switch language through the language bar do they update or always stay in English?

I am using localized string events, They do update when I change the language in main menu but as soon as I change the scene they switch back to english.

Are you able to share the project so I can take a look at what’s going wrong?

Here is a video to show you what’s the problem https://drive.google.com/file/d/13wqfj0-JMOSw2sZ1wBcvKsBOOpVO_c9A/view?usp=sharing

And these are my settings
8416374--1112898--upload_2022-9-5_16-18-33.png

And the table

Can’t share the project At the moment but these are the settings, you need to see anything else I can show you.

Nothing stands out from the screenshots.
Can you show a screenshot of the Text components and its LocalizeStringEvent inspector when its showing the wrong language?

Are you able to reproduce it in a new project?


Here is the script that I am using

 public static LocalizationScript Instance;
    public Locale english,estonian,finnish,french,german,indonesian,norwegian,portugese,russian,spanish,turkish;
    LocalizationSettings settings;
    bool selectLanguage = false;
    public GameObject LanguageSelection;
    public int languageindex;
    // Start is called before the first frame update
    void Awake()
    {
        DontDestroyOnLoad(this.gameObject);
        Instance = this;
        settings = LocalizationSettings.Instance;
    }

    // Update is called once per frame
    void Update()
    {
        if (!selectLanguage && LocalizationSettings.InitializationOperation.IsDone)
        {
             SelectLanguage(PlayerPrefs.GetInt("Language"));
        }
    }
    public void SelectLanguage(int index)
    {

     
        if (index == 0)
            ChangeLanguage(0, "en", english);
        if (index == 1)
            ChangeLanguage(1, "et", estonian);
        if (index == 2)
            ChangeLanguage(2, "fi", finnish);
        if (index == 3)
            ChangeLanguage(3, "fr", french);
        if (index == 4)
            ChangeLanguage(4, "de", german);
        if (index == 5)
            ChangeLanguage(5, "id", indonesian);
        if (index == 6)
            ChangeLanguage(6, "no", norwegian);
        if (index == 7)
            ChangeLanguage(7, "pt", portugese);
        if (index == 8)
            ChangeLanguage(8, "ru", russian);
        if (index == 9)
            ChangeLanguage(9, "es", spanish);
        if (index == 10)
            ChangeLanguage(10, "tr", turkish);
    }
    void ChangeLanguage(int index, string language,Locale localeName)
    {
        languageindex = index;
        settings.SetSelectedLocale(localeName);
        LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
        PlayerPrefs.SetInt("Language", index);
        LanguageSelected();  
    }


    void LanguageSelected()
    {
        selectLanguage = true;
      //  LanguageSelection.gameObject.SetActive(false);
    }

There’s a problem with your language changer script. Don’t hold public references to Locales in script. It will create duplicates in the build.
Instead use the LocaleIdentifier struct.
Also don’t use player prefs, instead add the Player pref selector to the localization settings locale selectors. Move it to the top of the list.

Also try disabling WaitForCompletion on the localized string event for the object that is not working. See if that makes a difference.

Okay, I will try. But this script only works once in the main menu, which shows correct language, when I change the scene the script does not destroy on load and there is no change made, but there the text does not show correctly, but I will try what you just said.

The language menu problems are unlikely to be the cause of the original issue but they will create new problems once you start building the game.

WaitForCompletion could be the issue though.

Okay I did try to disable WaitForCompletion but it did not work, one more thing when I try to change the language back to English and then again Portuguese while in the level scene then I can see the language being changed on the text component.

I’m afraid I’m out of ideas. We will need a bug report with a reproduction project that shows this issue so we can debug and understand what’s going on.

There is another thing I have noticed, there is a text called Level, its value is changing in the new scene because it’s an Active component when the scene is started. But the dialogues are inactive at the start of the scene, they are made active after a few seconds. Only dialogue text is not changing.

I don’t believe this would make a difference.
Do you have any errors or warnings in the log?

Is that the default text being shown? The text that is set in the Tmp component?