Page 1 of 2

Localization problem with UI component

Posted: Sun Jan 05, 2020 1:13 am
by mgregoirelds
Hello Tony,

There may be a few things I'm doing wrong but I started doing the localization of the game. I created a TextTable containing all my UI related text and I handle 3 languages now ("Default" which is English, "FR" which is French and "JA" which is Japanese).


So upon loading the game, I read a config file and call DialogueManager.SetLanguage(value) where value is the read value ("FR" in my case). As you can see in the screenshot, the Language is set to FR:
Loc_01.PNG
Loc_01.PNG (37.1 KiB) Viewed 1396 times

Then, I attached a Localize UI component with my Text Mesh Pro component. I reference my UI TextTable (called UI) and my field is named UI_Title_NewGame_Label:
Loc_03.PNG
Loc_03.PNG (68.68 KiB) Viewed 1396 times

Here is a screenshot of my UI TextTable with my UI_Title_NewGame_Label line in FR:
Loc_02.PNG
Loc_02.PNG (9.33 KiB) Viewed 1396 times

Any reason why, upon displaying that field when running in the editor, I am seeing the default version? This is strange since I did set DialogueManager language to FR in the code, I did configure the Localize UI component and it does seem to match properly my UI table with its Field since I see the English sentence "Press Any Button". I expected to see the French version. I may have forgot something...

Thanks!

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 9:10 am
by Tony Li
Hi Maxime,

Try clicking the Dialogue Manager's Reset Language PlayerPrefs button. If a language selection is already stored in PlayerPrefs, it will use the PlayerPrefs value instead of "FR".

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 1:00 pm
by mgregoirelds
Hi Tony,

I tested both with Reset Language PlayerPrefs in DisplaySettings of the prefab object and with Tools->Pixel Crushers->Dialogue System->Tools->Clear Saved Localization Settings, without success. I still see the English version of the text.

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 4:37 pm
by Tony Li
Is the Scripting Define Symbol 'TMP_PRESENT' set? (Edit > Project Settings > Player > Other Settings)

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 6:15 pm
by mgregoirelds
Yes it is defined. Any spot to debug? Directly in LocalizeUI.cs?

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 6:52 pm
by Tony Li
Yes, can you put a breakpoint on LocalizeUI's UpdateText() method and step through it?

The first three lines set two variables: textTable and language. Make sure the values of these variables are what you expect.

The rest of the method will attempt to apply localization to the UI Text, UI Dropdown, and/or TextMeshProUGUI component, whichever are present.

If the code in "#if TMP_PRESENT" is still grayed out, it's possible that Unity didn't recompile it. In this case, right-click on the LocalizeUI script and select Reimport.

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 8:10 pm
by mgregoirelds
This is pretty weird...

The following line: var language = UILocalizationManager.instance.currentLanguage;
returns an empty string. However, I did set DialogueManager.SetLanguage("FR"); a few lines before...

And yes, TMP_PRESENT is enabled.

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 8:29 pm
by Tony Li
Add a UILocalizationManager component to the Dialogue Manager.

The DialogueManager.SetLanguage() method should add a UILocalizationManager automatically if it isn't already present, but it doesn't in the current version. I'll fix this for the next release. In the meantime, if you add it yourself at design time it works just as well.

Re: Localization problem with UI component

Posted: Sun Jan 05, 2020 9:45 pm
by mgregoirelds
Your suggestion worked, thanks a lot!

I have another question for you, related to a localization problem...

I created a new language in a TextTable, "EN'. Most of the strings in that table for that language are not filled with any value. Since I call DialogueManager.SetLanguage("EN"), my guess, based on the documentation, is that if no value is set in a TextTable for the set language, it will use the Default entry. Am I right?

I have a value set in Default for a Field and for "EN", the field is empty. When the UI is displayed, it is not showing the default value but showing an empty string instead. That may be the default behavior, however I am not sure.

Re: Localization problem with UI component

Posted: Mon Jan 06, 2020 8:55 am
by Tony Li
It used to work like that, but the default behavior is to now use the empty string in EN because it's possible that the designer actually wants to show an empty string for a specific language. Previously there was no way to force it to use an empty string because it would default to using the default entry instead.

If you want to quickly fill EN with all of the default values, you can export it to CSV. Then copy the entire field name column into the EN column. Finally, import it back into the text table from CSV.

BTW, you don't have to assign the text table to each LocalizeUI component individually. If you assign it to the Dialogue Manager's Localization Settings > Text Table and leave the LocalizeUI component unassigned, the LocalizeUI component will use the Dialogue Manager's text table.