Page 1 of 1

How to update visible dialogue to language changes

Posted: Wed Feb 01, 2023 12:00 pm
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.

Re: How to update visible dialogue to language changes

Posted: Wed Feb 01, 2023 1:56 pm
by Tony Li
Hi,

Try:

Code: Select all

var state = DialogueManager.conversationModel.GetState(DialogueManager.currentConversationState.subtitle.dialogueEntry);
DialogueManager.conversationController.GotoState(state);

Re: How to update visible dialogue to language changes

Posted: Wed Feb 01, 2023 3:29 pm
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)

Re: How to update visible dialogue to language changes

Posted: Wed Feb 01, 2023 4:16 pm
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?

Re: How to update visible dialogue to language changes

Posted: Wed Feb 01, 2023 4:17 pm
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.