How to localize actor name?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

How to localize actor name?

Post by joeylu »

Hi Tony
If I add a localize field like "Name zh-CN" and tick the "main" checkbox in actor template, it won't show the localize field in the actor editor, not like the "Display Name zh-CN".
Is there any special way to localize actor name? tks
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to localize actor name?

Post by Tony Li »

In general, you should localize the Display Name, not the Name field. Is there a reason you want to localize the Name field? Perhaps I can suggest a different approach.

Side note: There's a small bug in the current DS version's Dialogue Editor that doesn't show "Name xx" fields in the main section even if you've ticked the template's Main checkbox. It'll be fixed in 2.2.45.
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: How to localize actor name?

Post by joeylu »

For example, let's say there's an actor named "Joe Smith", and he is a teacher, so I set his diaplay name to "Teacher Smith" (yeh, I know, more like a nick name, but it makes player much easier to remember his role)

In my game, the subtitle (dialogue entry) uses display name, so the subtitle will display "Teacher Smith".
However, sometimes I need show this actor's name more formly, for instance, in his resume, or profile. So I will use the Name field.

Nevertheless, it is ok to use fields to assign nick name, etc, but another problem is that to get the actor's name (not from conversationModel), there is only one property "localizedName", and that points to the actor Name, not the display name.

So I guess I need to develop my own method/property to to get localized display name, just curious if we can get direct access to the localized display name from Actor class :)
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to localize actor name?

Post by Tony Li »

It's fine to localize the Name field, and 2.2.45 will show localized Name fields in the main section. I just wanted to make sure there wasn't a better approach.

To get the localized Display Name field, use DialogueLua.GetLocalizedActorField("name", "Display Name").asString, where "name" is the actor's Name. You can write a function or two if you want:

Code: Select all

public string GetLocalizedDisplayName(Actor actor)
{
    return DialogueLua.GetLocalizedActorField(actor.Name, "Display Name").asString;
}
joeylu
Posts: 111
Joined: Sun May 17, 2020 1:07 pm

Re: How to localize actor name?

Post by joeylu »

Thank you Tony
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to localize actor name?

Post by Tony Li »

Glad to help!
Post Reply