Localization in Inventory engine support

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
balsamina
Posts: 8
Joined: Sun Oct 01, 2023 10:03 am

Localization in Inventory engine support

Post by balsamina »

Hello, I am writing to you because I have a question about localization in the inventory support of the dialogue system. I unpacked the inventory engine support as indicated on the homepage, assigned the dialogue manager prepab to the ui manager, and even made a text table, but I don't know what text table to make. I want to localize "ItemName" and "Description" in multiple languages among the items in the inventory engine, should I create a text table named "ItemName" and "Description"? I'm sorry if it's an inexperienced question. Thank you always,
https://www.pixelcrushers.com/dialogue_ ... ngine.html
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localization in Inventory engine support

Post by Tony Li »

Hi,

Create a text table (Assets > Create > Pixel Crushers > Common > Text Table) and name it whatever you want. Assign it to the Dialogue Manager GameObject's Display Settings > Localization Settings.

Then create two fields for each item: one that matches the item's name, and another that matches its description:

ieLocalization.png
ieLocalization.png (12.09 KiB) Viewed 331 times
balsamina
Posts: 8
Joined: Sun Oct 01, 2023 10:03 am

Re: Localization in Inventory engine support

Post by balsamina »

Thank you for answer! Thanks to you, I found a solution to the problem, but when I created and applied a text table, it seems that even if I change the language settings, the changed language is not applied and only the default language is displayed. Do I need to add the Localize UI component to inventory details? Unity localization package integration has already been completed.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localization in Inventory engine support

Post by Tony Li »

Hi,

The Dialogue System's Inventory Engine integration does not use Unity's Localization Package.

If you have already set a language, the language value may be stored in PlayerPrefs. To reset it, click the Dialogue Manager's Localization Settings > Reset Language PlayerPrefs. Then the Dialogue System will recognize the language you have specified in Localization Settings.
balsamina
Posts: 8
Joined: Sun Oct 01, 2023 10:03 am

Re: Localization in Inventory engine support

Post by balsamina »

Thank you, I almost solved my problem. Sorry to bother you, but I have one last question. What code should I write to change the in-game language settings by clicking a specific button in the game? I am not sure which function should be used with code such as DialogueManager.SetLanguage( "es" );, which is shown as an example on the homepage. Could you please give me a simple example? If this is a bothersome question, feel free to ignore it.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localization in Inventory engine support

Post by Tony Li »

That line of code is correct. You could write a script and add it to a UI Button to call that line of code. For example:

Code: Select all

using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(Button))]
public class SetLanguageButton : MonoBehaviour
{
    public string languageCode; // <-- SET IN INSPECTOR
    void Start()
    {
        GetComponent<Button>().onClick.AddListener(() => PixelCrushers.DialogueSystem.DialogueManager.SetLanguage(languageCode));
    }
}
Add this to a UI Button and set the Language Code field. You don't need to confgure the OnClick() UnityEvent. The script will take care of that.
balsamina
Posts: 8
Joined: Sun Oct 01, 2023 10:03 am

Re: Localization in Inventory engine support

Post by balsamina »

I'm very sorry, but when I pasted the code you provided, the result was "Assets\Scripts\SetLanguageButton.cs(13,62): error CS0234: The type or namespace name 'DialogueManager' does not exist in the namespace 'PixelCrushers' (are you missing an assembly reference?)” error occurs. I don't know much about coding, so I don't know which part to fix. I would really appreciate your help...
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localization in Inventory engine support

Post by Tony Li »

I had a typo. Try it now.
balsamina
Posts: 8
Joined: Sun Oct 01, 2023 10:03 am

Re: Localization in Inventory engine support

Post by balsamina »

Ah, it finally works! Thank you so much for your help. Have a nice day!
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Localization in Inventory engine support

Post by Tony Li »

Glad to help!
Post Reply