How to update visible dialogue to language changes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
etsapekis
Posts: 39
Joined: Tue Oct 12, 2021 4:21 pm

How to update visible dialogue to language changes

Post by etsapekis »

In my project, which uses i2 for localization, it is possible to change the language in the settings while a dialogue is diaplayed. We see both the actor name and the dialogue text. Translation works fine when a new conversation is started, but is there any way i could force a refresh that would take new language change into account?

Code: Select all

LocalizationManager.CurrentLanguage = selectedLanguage;
string languageCode = LocalizationManager.CurrentLanguageCode;
DialogueManager.Instance.SetLanguage (languageCode);
OnLanguageChanged?.Invoke (selectedLanguage, languageCode);
I noticed that simply calling SetLanguage on the DialogueManager did nothing, so I added an event that will be received in the code where I handle the DialogueSystem Api.

I believe I need a one-liner for this. Please let me know what I can do.
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to update visible dialogue to language changes

Post by Tony Li »

Hi,

Try:

Code: Select all

var state = DialogueManager.conversationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
DialogueManager.conversationController.GotoState(state);
etsapekis
Posts: 39
Joined: Tue Oct 12, 2021 4:21 pm

Re: How to update visible dialogue to language changes

Post by etsapekis »

that worked for the dialogue text, but i need to reset the actor name as well (there's a name label indicating who is speaking)
etsapekis
Posts: 39
Joined: Tue Oct 12, 2021 4:21 pm

Re: How to update visible dialogue to language changes

Post by etsapekis »

I solved my issue by modifying the code as so:

Code: Select all

var state = DialogueManager.conversationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
state.subtitle.speakerInfo.Name = CharacterInfo.GetLocalizedDisplayNameInDatabase (state.subtitle.speakerInfo.nameInDatabase);
DialogueManager.conversationController.GotoState(state);
Seems fine. Should I do it in any other way?
User avatar
Tony Li
Posts: 22135
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to update visible dialogue to language changes

Post by Tony Li »

Sorry, I forgot to reply about that. You'll need to manually set it. After the code I suggested above, you can get the current localized actor name from state.speakerInfo.Name.

Never mind. Looks like you got it.
Post Reply