Localization problem with UI component
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Localization problem with UI component
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:
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:
Here is a screenshot of my UI TextTable with my UI_Title_NewGame_Label line in FR:
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!
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:
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:
Here is a screenshot of my UI TextTable with my UI_Title_NewGame_Label line in FR:
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!
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Localization problem with UI component
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".
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".
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Localization problem with UI component
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.
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.
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Localization problem with UI component
Is the Scripting Define Symbol 'TMP_PRESENT' set? (Edit > Project Settings > Player > Other Settings)
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Localization problem with UI component
Yes it is defined. Any spot to debug? Directly in LocalizeUI.cs?
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Localization problem with UI component
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.
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.
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Localization problem with UI component
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.
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.
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Localization problem with UI component
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.
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.
-
- Posts: 106
- Joined: Wed Aug 23, 2017 4:10 pm
- Location: Canada
Re: Localization problem with UI component
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.
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.
Unity 2022.3.17f1
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Dialogue System 2.2.44.1
OpenAI Addon 1.0.12
Re: Localization problem with UI component
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.
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.