Page 1 of 1

Localize Display Name in Dialogue Entires

Posted: Fri Oct 25, 2024 5:06 am
by Loremu
Hi,

I need your help for localizing actor display names inside dialogue entries.

Problem description 1
in my dialogue entries I use the [lua(Actor["Actor Name"].Display_Name)] expression whenever a character mentions another character by name. However, I can't get it to localize properly.
I have added actor fields for the localization as described here: https://www.pixelcrushers.com/dialogue_ ... textTables

The display name and respective localization fields are set up as follows:
Actor Name: Villagers

Fields
Title: Display Name
Value: Dorfbewohner
Type: Text

Title: Display Name en
Value: Villagers
Type: Localization

However, if I use the above mentioned expression in my dialogue entries, the game shows the original display name, unless I specify it.
Expamle:
Dialogue Entry (default): "Siehst du die [lua(Actor["Villagers"].Display_Name)]?"
--> in play mode: "Siehst du die Dorfbewohner?"

not specified: Dialogue Entry (en): "Do you see the [lua(Actor["Actor Name"].Display_Name)]?"
--> in play mode: "Do you see the Dorfbewohner?"

specified: Dialogue Entry (en): "Do you see the [lua(Actor["Actor Name"].Display_Name_en)]?"
--> in play mode: "Do you see the Villagers?"


We are editing our texts in a spreadsheet that we import into the database. To avoid having to type the long expression in our spreadsheet we type the names followed by XXX (e.g. BenXXX) and later search and replace these with the expression before importing the sheet into the database.
Due to some other stuff it would be quite inconvenient for our workflow if we had to specify the localization in the name - it would be way easier if this was handled within the database.

Problem description 2
I wrote a custom component that we use for speechbubbles in comics that directly accesses the dialogue entry texts from the database. This is the relevant code snippet that draws the text from the database:

Code: Select all

fullEntryText = FormattedText.Parse(_entry.subtitleText).text;


Here, the names are not localized either.

Question
1: Is there a way to localize actor names within a dialogue entry without specifying the language code in the lua expression?
2: How to achieve this in the mentioned custom script that directly accesses the dialogue entry text?

Thanks in advance!
Best,
Lorena

Re: Localize Display Name in Dialogue Entires

Posted: Fri Oct 25, 2024 8:47 am
by Tony Li
Hi Lorena,

Write a C# method and register it with Lua. For example, add a script with these methods to the Dialogue Manager:

Code: Select all

void Awake()
{
    Lua.RegisterFunction(nameof(GetActorName), this, SymbolExtensions.GetMethodInfo(() => GetActorName("")));
}
string GetActorName(string nameInDatabase)
{
    return CharacterInfo.GetLocalizedDisplayNameInDatabase(nameInDatabase);
}
Then use this markup tag in text: [lua(GetActorName("Villagers"))].

BTW, if you want the names of the conversation's actor or conversant, you can use the markup tags [var=Actor] and [var=Conversant] instead. They'll already be set to the localized display names.

Re: Localize Display Name in Dialogue Entires

Posted: Mon Oct 28, 2024 7:11 am
by Loremu
Hi Tony,

works perfectly, thank you!

Best regards,
Lorena

Re: Localize Display Name in Dialogue Entires

Posted: Mon Oct 28, 2024 8:57 am
by Tony Li
Glad to help!