Actor Name Localization

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
zpr
Posts: 5
Joined: Fri May 08, 2015 10:22 am

Actor Name Localization

Post by zpr »

Hello,



In DS wiki http://www.pixelcrushers.com/dialogue_s ... ation.html I couldn't find an example on how to localize actor names.



I've tested like this: http://i.imgur.com/WeQUhkO.png



"Name {localize_ID}"
zpr
Posts: 5
Joined: Fri May 08, 2015 10:22 am

Actor Name Localization

Post by zpr »

forgot to mention it didn't work the "Name {localize_ID}"
User avatar
Tony Li
Posts: 20771
Joined: Thu Jul 18, 2013 1:27 pm

Actor Name Localization

Post by Tony Li »

Hi,



The Dialogue System doesn't automatically localize actor names, but it's easy to do. Here's one way:







1. Set up localized name field exactly as you have done (e.g., "Name fr-FR").







2. Add an Override Actor Name component to the GameObject.







3. Add this script to the GameObject:

using UnityEngine;

using System.Collections;

using PixelCrushers.DialogueSystem;



[RequireComponent(typeof(OverrideActorName))]

public class LocalizeActorName : MonoBehaviour {



private IEnumerator Start() {

yield return null; // Wait 1 frame for Lua to initialize.

var overrideActorName = GetComponent<OverrideActorName>();

var initialName = string.IsNullOrEmpty(overrideActorName.overrideName) ? gameObject.name : overrideActorName.overrideName;

overrideActorName.overrideName = DialogueLua.GetLocalizedActorField(initialName, "Name").AsString;

if (string.IsNullOrEmpty(overrideActorName.internalName)) {

overrideActorName.internalName = initialName;

}

}

}
zpr
Posts: 5
Joined: Fri May 08, 2015 10:22 am

Actor Name Localization

Post by zpr »

Hello again,



I'm unable to get DialogueLua.GetLocalizedActorField() right. It's returning an empty string



Tested others functions and  got the following



DialogueLua.GetActorField(initialName, "Name").AsString; // returns 'Ingrid'



DialogueLua.GetActorField(initialName, "Ability").AsString; //returns 'Leadership'







My Setup:



http://i.imgur.com/3rpRc39.png



and overrideName field in OverrideActorName script is set to "Ingrid"







Edit:



I'm using DS 1.5.0 and Unity3d 4.6.4f1







EDIT:



MY MISTAKE. ALL GOOD NOW. TY
Post Reply