How Can I Refresh UI Language After Change Language?

Announcements, support questions, and discussion for the Dialogue System.
wlchfl5359
Posts: 29
Joined: Sat Jan 02, 2021 4:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by wlchfl5359 »

I just tried with new canvas and I added 'UI Localization Manager.cs' and it works!

I think I have a problem with my Dialogue Manager. I have only 1 UILocalizationmanager.cs but it doesn't work.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

Hi,

That should be fine. The UILocalizationManager can be anywhere; it doesn't have to be on the Dialogue Manager.
wlchfl5359
Posts: 29
Joined: Sat Jan 02, 2021 4:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by wlchfl5359 »

I found a problem.

I was looking at code

public void UpdateUIs(string language)
{
m_currentLanguage = language;
if (saveLanguageInPlayerPrefs)
{
if (!string.IsNullOrEmpty(currentLanguagePlayerPrefsKey))
{
PlayerPrefs.SetString(currentLanguagePlayerPrefsKey, language);
}
}

var localizeUIs = m_alsoUpdateInactiveLocalizeUI
? GameObjectUtility.FindObjectsOfTypeAlsoInactive<LocalizeUI>()
: FindObjectsOfType<LocalizeUI>();

for (int i = 0; i < localizeUIs.Length; i++)
{
localizeUIs.UpdateText();
}
}

and I just turned off "Also Update Inactive Localize UI" and it works well.
I don't know why this happened.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

Hi,

I'll investigate that.
wlchfl5359
Posts: 29
Joined: Sat Jan 02, 2021 4:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by wlchfl5359 »

Thank you.
Please tell me if there is a problem. :)
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

I've confirmed that m_alsoUpdateInactiveLocalizeUI works correctly in a test scene. Can you send a reproduction project to tony (at) pixelcrushers.com?
elektronische
Posts: 9
Joined: Mon Dec 03, 2018 4:31 pm

Re: How Can I Refresh UI Language After Change Language?

Post by elektronische »

Hi, I have a question about the same topic. I'm using the method DialogueManager.Instance.SetLanguage to set the language when the user changes it from the options menu. This works correctly, but if a dialogue is active, the language does not change until the dialogue node ends and moves to the next one. Is there any way to make that UI update immediately? So that as soon as the player returns from the options menu, the subtitle language is already updated? Thank you!
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

Hi,

If you're showing a subtitle, you can replay the same dialogue entry:

Code: Select all

var state = DialogueManager.converationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
DialogueManager.conversationController.GotoState(state);
If you're showing a response menu, just call DialogueManager.UpdateResponses().
elektronische
Posts: 9
Joined: Mon Dec 03, 2018 4:31 pm

Re: How Can I Refresh UI Language After Change Language?

Post by elektronische »

Tony Li wrote: Mon Mar 27, 2023 4:30 pm Hi,

If you're showing a subtitle, you can replay the same dialogue entry:

Code: Select all

var state = DialogueManager.converationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
DialogueManager.conversationController.GotoState(state);
If you're showing a response menu, just call DialogueManager.UpdateResponses().
Thanks for the quick response! :D

Is this the only way? I ask because besides the subtitles, I also use sequences in the dialogue nodes that trigger other things like sounds, animations, etc. So it doesn't seem very efficient to replay the entire dialogue node just to update the subtitles' language.
User avatar
Tony Li
Posts: 22145
Joined: Thu Jul 18, 2013 1:27 pm

Re: How Can I Refresh UI Language After Change Language?

Post by Tony Li »

You could tell the subtitle panel to update its content:

Code: Select all

var subtitle = DialogueManager.currentConversationState.subtitle;
subtitle.formattedText = FormattedText.Parse(subtitle.dialogueEntry.currentDialogueText);
DialogueManager.standardDialogueUI.ShowSubtitle(subtitle);
Post Reply