Unable to use existing localization keys

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Juwdah
Posts: 1
Joined: Wed May 22, 2024 3:29 am

Unable to use existing localization keys

Post by Juwdah »

Hey,

I'm in the process of trying out this asset for a game that's been in development for a while, as a need has come up for a proper dialogue system. The game currently uses I2Localize.

I've looked into setting up a conversation / quest, but have come towards an issue when trying to do this using existing localization keys. The DS to I2 tool will create localization keys for recently created conversations that I can translate, but instead I want to use existing localization keys and assign them to the conversation's dialogue text.

I cannot seem to figure out how to properly do this. What is the correct workflow here? Am I glaring over something obvious? I have set the dialogue text to existing localized text, to key ID, etc. but nothing seems to work.

Also, I have found the option 'Use Key Field' but this does not seem to do anything with I2Localize. Is there a way to forego the entire 'from I2' import workflow, and just assign keys to text instead?

Thanks in advance
User avatar
Tony Li
Posts: 20989
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unable to use existing localization keys

Post by Tony Li »

Hi,

The Dialogue System's i2 integration uses unique terms starting with "Dialogue System/" so it can identify the terms that it's created in the i2Assets file. That's a restriction of the integration to ensure it can clean up after itself if you click the Clear I2 button.

If you want to use your existing terms instead, you can bypass that integration and add a custom field to your dialogue entry template. Here, I've added a field named "Term" and ticked the Main checkbox so it appears in the main inspector section when editing dialogue entries:

customTermField.png
customTermField.png (45.17 KiB) Viewed 81 times

In each dialogue entry, set the Term field to match the corresponding i2 term.

Then add a script with an OnConversationLine(Subtitle) method that looks up the translation from i2:

Code: Select all

void OnConversationLine(Subtitle subtitle)
{
    string term = Field.LookupValue(subtitle.dialogueEntry.fields, "Term");
    term = I2.Loc.I2Utils.GetValidTermName(term, true);
    var translation = I2.Loc.LocalizationManager.GetTermTranslation(term, true, 0, true, false, null, I2.Loc.LocalizationManager.CurrentLanguage);
    if (!(string.IsNullOrEmpty(translation) || string.Equals(translation, "Null")))
    {
        subtitle.formattedText = FormattedText.Parse(translation);
    }
}
You'll also want to do the same in an OnConversationResponseMenu(Response[]) method to translate the text that appears on response menu buttons. See DialogueSystemUseI2Language.cs for an example.
Post Reply