some problems with localization with Unity package

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

some problems with localization with Unity package

Post by Pixelf0x3 »

Hi. Im testing the dialog system in a clean project to later add it to another advanced project.
In that other project I'm already using unity's localization package, so I was testing with the DS, and I found some inconveniences:
I tested the default in-editor localization and it works fine when using unity's one just for changing the language. It works changes the language even in middle of a conversation.

The problem comes when I try to use the unity's localization tables, and the Guid.
  • Sometimes creates no Guid, for some reason. In the table i show below the player string was one of them, I had to create it with a web Guid generator.
  • The answers the player can give, arent translated no matter what, it uses the default text (uses "Dialog Text" field, not default locale). I checked the Guid, and all are correct
  • It loads the locale from the beggining and stays like that untill restart: If I want to change between languages, to take effect I have to save the player pref key, stop, and start again. In build each time i would like to change language, i would have to close entirely the game and open it again.
In this image the current selected language is portuguese. The NPC gives the french one because is the last locale in player prefs when i played the scene. And the answer i can give is not translated
Image

In this one there´s the dialogue, and the corresponding table entries
Image



Also, something i found interesting: in the tables it creates, the NPC name and the player are an option to translate, so I tested it. It turns out that the npc name doesnt translate right away like what he says, you have to change the locale, and then the name displays with the language it started playing (not the current one), at least when playing in editor...

Image


Things I already tried:
-changing DS language through code when the unity one does (unnecesary, the bridge already does it)
-Adding the adsressables in the welcome wizard (nothing changed)
-Building and running (maybe having to build the adressables was the problem):
---but this caused weird behaviour: Same as before that only when changing language the npc name changed, In the build the NPC name didnt change when changing language mid game, but also his text was reverted to default ("Dialog Text"). It starts displaying text normally with the language stored in player prefs, but in the moment you change language, it starts giving the non localized string.

Is something that im missing? or just isn't fully supported/functional yet?
I would like to know what is this integration capable of, to use it fully. I think this dialog system is an awesome asset overall

thanks in advance.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: some problems with localization with Unity package

Post by Tony Li »

Hi,

Everything you described should be supported.

Were there any errors or warnings in the Console window?

> Sometimes creates no Guid, for some reason. In the table i show below the player string was one of them, I had to create it with a web Guid generator.

Technically it doesn't need to be a Windows-style GUID at all. If a dialogue entry already has a field with the Unique Field Title (which defaults to "Guid"), it won't create a new GUID. It will just use that field. However, just now I can see how this could generate an issue if you were to go to the Templates section of the Dialogue Editor and add a blank "Guid" field to all dialogue entries. I'll update the Localization Package integration to assign a valid GUID if an entry has a blank "Guid" field.

> The answers the player can give, arent translated no matter what, it uses the default text (uses "Dialog Text" field, not default locale). I checked the Guid, and all are correct

If your dialogue entry has Dialogue Text and Menu Text, then your Localization Table should have two keys: one that's just the GUID, and another that appends "_MenuText" to the GUID, such as:
  • Dialogue Text: f3b9c130-b5a1-48c7-9bc9-01a55d039ae2
  • Menu Text: f3b9c130-b5a1-48c7-9bc9-01a55d039ae2_MenuText
> It loads the locale from the beggining and stays like that untill restart: If I want to change between languages, to take effect I have to save the player pref key, stop, and start again. In build each time i would like to change language, i would have to close entirely the game and open it again.

Try setting the Localization Package language. Since the bridge hooks into the LocalizationSettings.SelectedLocaleChanged event, it will set the Dialogue System's language to the same. This will also update the actor names so the correct language appears in UIs.
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: some problems with localization with Unity package

Post by Pixelf0x3 »

Thanks for the quick response :)

About the non localized player answers, now I understand better how this all works: So the menu text like a button with a small hit of what the player can say, and the dialogue text is the full text the player gives.
Then if my game only uses the menu text, but dont need to use the dialog part i can just simply add _MenuText at the end the generated row, instead of creating a new entry manually for each answer. (As im writting this i tested what happens if the field isnt empty when using the DS to Loc tool... it also creates the entries for menu text. So complete and amazing!)

Now this problem is solved, thanks!

But now I have one question: I usually edit the default text from the node view, but it is linked always to the dialogue text. Is it posible to link it to menu text only for player answers?


The GUID thing is exactly what you said: when I was testing with having a mixed translation between Unity's and the integrated one, I used the menu to sync templates and assets (that way all assets could have the locales [es,en,fr] without losing the guid field), but that way the guid field was empty for new ones, and when using the loc tool, as the guid field was already created (but blank). wasnt giving any code.
I tried using the Unique ID tool, but I think its only for databases, not its contents. And the working solution i have currently if something has blank guid is to remove that field, and use the Loc tool button again.



About the changing language mid game, I was too vague in the first post about what i did for my tests:
The dropdown you see in the screenshots allows me to change the language (unity localization) mid game. In the first screenshot the NPC name hadn't any translations. The text was in french (because of the first selected language by the unity localization at start), the selected language before starting the conversation was portuguese, and the npc name didnt change (because no translations).

In the third screenshot is the same scenario, but the NPC name had translations. The starting language was french, the selected language before starting conversation was english. If i had started the conversation without changing language, the npc name would be the untranslated one "NPCC". But since i changed the language, before starting conversation, it updates the npc name, bit like the text, not to the selected language, it uses the one that was stored in player prefs at the begining.


The DS bridge works changing the DS language, but if im using unity tables, it doesnt update untill I restart the game.
It works runtime if im using the "es" "en" "fr"... in the dialogue fields for translation.

Maybe with this video i can show better what I mean: the first conversation is alright BUT is not using unity localization tables, it only uses the bridge to change the DS language.
The second one uses unity tables.

second conversation + translated rows
Image
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: some problems with localization with Unity package

Post by Tony Li »

Hi,

This updated package sets valid GUIDs for actors and dialogue entries that have blank Guid fields:

DS_LocalizationPackageIntegration_2022-10-07.unitypackage

I think I follow you regarding the PlayerPrefs issue. Add a UILocalizationManager component to the Dialogue Manager, and UNtick Save Language In PlayerPrefs. That should prevent the Dialogue Manager's localization manager from using PlayerPrefs.

Regarding the edit box when you double click on on a node in the Dialogue Editor, we'll keep it to the Dialogue Text to prevent confusion. Note: If your player response nodes only have one set of text (i.e., you show the same text in the response menu and in player subtitles), you can leave Menu Text blank and only use Dialogue Text. The menu will use Dialogue Text if Menu Text is blank.

On the other hand, if you want to show a shorthand version of the response in Menu Text and an expanded version in Dialogue Text, you can edit Dialogue Text on the node itself or in the Inspector view, and you'll have to edit Menu Text in the Inspector view.
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: some problems with localization with Unity package

Post by Pixelf0x3 »

Thanks again for the reply.

I've tested that if Menu text is blank, it will use dialog text instead. But this was precisely the problem I was facing in the first post, when it wasn't traslating. Im talking about unity localization integration, when using the built in translations works as you described.
When I translate Dialogue Text in an answer node (blank Menu Text), It will use the default Dialogue text, even if there are translations for it, no translation (at least when generating the buttons for the player to choose answer).
Using the _MenuText after Guid in the tables solved it for me (even if the default Menu Text still blank).

About the playerPrefs, I think is not the problem. I tried what you sugested but still the same result. I checked with player prefs viewer that the "Language" player pref is not updated, just the Player pref the unity Loc is using. Is like the Loc package bridge saved the language the localization package starts with, and doesnt want to change until the game is entirely reloaded.
Despite the dialog system knowing the language changed, and working fine changing the inside-system localization, it doesnt change the language is using inside the unity's localization tables.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: some problems with localization with Unity package

Post by Tony Li »

Pixelf0x3 wrote: Sat Oct 08, 2022 6:32 pmI've tested that if Menu text is blank, it will use dialog text instead. But this was precisely the problem I was facing in the first post, when it wasn't traslating. Im talking about unity localization integration, when using the built in translations works as you described.
When I translate Dialogue Text in an answer node (blank Menu Text), It will use the default Dialogue text, even if there are translations for it, no translation (at least when generating the buttons for the player to choose answer).
Using the _MenuText after Guid in the tables solved it for me (even if the default Menu Text still blank).
Just to confirm -- Is this working correctly for you now?
Pixelf0x3 wrote: Sat Oct 08, 2022 6:32 pmAbout the playerPrefs, I think is not the problem. I tried what you sugested but still the same result. I checked with player prefs viewer that the "Language" player pref is not updated, just the Player pref the unity Loc is using. Is like the Loc package bridge saved the language the localization package starts with, and doesnt want to change until the game is entirely reloaded.
Despite the dialog system knowing the language changed, and working fine changing the inside-system localization, it doesnt change the language is using inside the unity's localization tables.
I don't think I understand. Is the problem that the Unity Localization Package language doesn't automatically update when you change the Dialogue System language? If so, the integration doesn't handle that. Only change the Unity Localization Package language. The bridge will detect in the change in the Unity Localization Package language and update the Dialogue System accordingly.

There is one case where it will not update everything: if you change languages while a conversation is active. The Dialogue System caches character info when a conversation starts. This way it doesn't have to look up the character info with every line. If you change the language after the conversation has started, the character info cache will still have the previous translation of the characters' names. If this is the problem, let me know and I'll describe how to update the cache. (Briefly, just update DialogueManager.conversationModel.GetCharacterInfo(id).)

If you are changing the Unity Localization Package language but it's not updating the Dialogue System language, please send a reproduction project to tony (at) pixelcrushers.com along with the steps I should follow to see the issue.
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: some problems with localization with Unity package

Post by Pixelf0x3 »

Tony Li wrote: Sat Oct 08, 2022 8:47 pm Just to confirm -- Is this working correctly for you now?
It works for me, but Im' not sure is the behaviour intended for this asset. Is suposed that if you don't use Menu text, it should use Dialog text and its localizations. But when using unity localization tables, doesn't use the localized dialog text in the tables for the player answers buttons, instead, it uses the default Dialog Text in the field of the dialog system.
It works for me because doesn't bother me so much having to add the "_MenuText" after Guid in the unity Loc tables.

Tony Li wrote: Sat Oct 08, 2022 8:47 pm I don't think I understand. Is the problem that the Unity Localization Package language doesn't automatically update when you change the Dialogue System language? If so, the integration doesn't handle that. Only change the Unity Localization Package language. The bridge will detect in the change in the Unity Localization Package language and update the Dialogue System accordingly.
No, is not that. What i use to change language is the unity Localization example dropdown. So it changes unitys localization language first, then the bridge changes DS one. That is working perfectly.
Tony Li wrote: Sat Oct 08, 2022 8:47 pm If you are changing the Unity Localization Package language but it's not updating the Dialogue System language, please send a reproduction project to tony (at) pixelcrushers.com along with the steps I should follow to see the issue.
This is more like it. In the video I posted before I show that when changing language AND using Dialog System's localization fields it updates the next dialogue lines even if the conversation has started (this is the desired behaviour)
But when i do the same, and its handled through unity's localization tables and bridge doesnt update the language used. It only updates the language it should use at start, and ignores when language has changed in game.

I sent you an e-mail with a simple project and steps.
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: some problems with localization with Unity package

Post by Tony Li »

Thank you for the reproduction project. This updated integration should address the issue:

DS_LocalizationPackageSupport_2022-10-09.unitypackage
Pixelf0x3
Posts: 8
Joined: Thu Oct 06, 2022 1:41 pm

Re: some problems with localization with Unity package

Post by Pixelf0x3 »

It works flawlessly!!!

The only problem I'm still noticing is that the NPC name keeps updates ultiple times if you change the language various times, but doesnt update to the current language.

If the language at start is english, the NPC name remains untranslated.
If you change the language (to french for example), the NPC name would be the previous language (english).
and if you change once more the language (Spanish), then the name would be in French.

So it's synchronizing, but somewhat it's one step behind.

Anyhow, I dont pretend to change names in the various languages for my project, so now it has all the features I need.

so many thanks!! :)
User avatar
Tony Li
Posts: 21965
Joined: Thu Jul 18, 2013 1:27 pm

Re: some problems with localization with Unity package

Post by Tony Li »

Glad to help. Thank you for pointing out the issue so I could fix it.

Regarding the portrait names, this is because the conversation caches the info when the conversation starts. If you want to update the names when changing languages in the middle of a conversation, update DialogueManager.conversationModel.GetCharacterInfo(actorID).Name for each actor involved in the conversation.
Post Reply