Runtime Localization Issue for Quest Log and Dialogue System

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
VietLinh
Posts: 6
Joined: Sun Nov 07, 2021 5:43 am

Runtime Localization Issue for Quest Log and Dialogue System

Post by VietLinh »

Hi Tony,

I am currently working on a project using the Dialogue System for Unity and have implemented runtime language switching. While I can successfully update UI elements dynamically via UILocalizationManager.UpdateUIs() after calling DialogueManager.SetLanguage(languageCode), I noticed that active quests in the Quest Log and dialogues do not update immediately during runtime.

Current Behavior:

When switching languages during runtime, the UI updates correctly, but quest titles, descriptions, and dialogues remain in the previous language.
If I restart the game after switching the language, everything displays correctly in the new language.
Expected Behavior:
Quest Log entries and active dialogues should reflect the new language immediately after calling SetLanguage(), similar to how UI elements are updated.

Questions:

Is there a method to refresh or reload the Quest Log and active dialogues dynamically after switching languages?
Are additional steps required to ensure that quests and dialogues are updated in real-time?
Below is the script I am using to manage language switching:

using PixelCrushers;
using PixelCrushers.DialogueSystem;
using UnityEngine;
using TMPro;

public class LanguageManager : MonoBehaviour
{
public UILocalizationManager localizationManager; // Reference to Localization Manager
public TMP_Dropdown languageDropdown; // Dropdown for selecting languages
public TextMeshProUGUI dropdownLabel; // Text to display selected language
private const string LANGUAGE_KEY = "LanguageS"; // Key for PlayerPrefs storage
private bool isInitializing = true;

void Start()
{
languageDropdown.onValueChanged.RemoveAllListeners();
LoadLanguage();
languageDropdown.onValueChanged.AddListener(OnDropdownChanged);
isInitializing = false;
}

private void LoadLanguage()
{
if (PlayerPrefs.HasKey(LANGUAGE_KEY))
{
string savedLanguage = PlayerPrefs.GetString(LANGUAGE_KEY);
if (savedLanguage == "Default")
{
ApplyLanguage("Default", 0);
DialogueManager.SetLanguage("Default");
}
else
{
ApplyLanguage("fr", 1);
DialogueManager.SetLanguage("fr");
}
}
else
{
string systemLanguage = Application.systemLanguage.ToString();
if (systemLanguage == "French")
{
ApplyLanguage("fr", 1);
DialogueManager.SetLanguage("fr");
}
else
{
ApplyLanguage("Default", 0);
DialogueManager.SetLanguage("Default");
}
}
}

private void OnDropdownChanged(int optionIndex)
{
if (isInitializing) return;

switch (optionIndex)
{
case 0:
ApplyLanguage("Default", 0);
DialogueManager.SetLanguage("Default");
break;
case 1:
ApplyLanguage("fr", 1);
DialogueManager.SetLanguage("fr");
break;
default:
Debug.LogWarning("Unknown language selection!");
break;
}
}

private void ApplyLanguage(string languageCode, int dropdownIndex)
{
localizationManager.UpdateUIs(languageCode);
languageDropdown.onValueChanged.RemoveListener(OnDropdownChanged);
languageDropdown.value = dropdownIndex;
dropdownLabel.text = dropdownIndex == 0 ? "Language A" : "Language B";
languageDropdown.onValueChanged.AddListener(OnDropdownChanged);
}
}

I would appreciate any advice or recommended solutions to address this issue.
Thank you for your time and support.
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Runtime Localization Issue for Quest Log and Dialogue System

Post by Tony Li »

Hi,

DialogueManager.SetLanguage(languageCode) automatically updates UIs. You don't need to also call UILocalizationManager.UpdateUIs(). Call DialogueManager.SendUpdateTracker() to update quest UIs after changing languages. Example:

Code: Select all

DialogueManager.SetLanguage("fr");
DialogueManager.SendUpdateTracker();
Version 2.2.51 will automatically call DialogueManager.SendUpdateTracker() when calling DialogueManager.SetLanguage().
VietLinh
Posts: 6
Joined: Sun Nov 07, 2021 5:43 am

Re: Runtime Localization Issue for Quest Log and Dialogue System

Post by VietLinh »

Hi Tony,

Thank you for the quick response!
I have followed your instructions, and everything is now working perfectly:

Calling DialogueManager.SetLanguage(languageCode) changes the language.
Adding DialogueManager.SendUpdateTracker() updates the quest UIs.

I'm looking forward to version 2.2.51, where SendUpdateTracker() will be called automatically when SetLanguage() is used.

Thank you again for the excellent support!
User avatar
Tony Li
Posts: 23256
Joined: Thu Jul 18, 2013 1:27 pm

Re: Runtime Localization Issue for Quest Log and Dialogue System

Post by Tony Li »

Glad to help!
Post Reply