Forum rules - please read before posting.

Localize strings in Scriptable Objects

Hi, I have a lot of scriptable objects that store description texts for example. Is there an easy way to tell the localization system that these strings have to be translated too?

Comments

  • You can add non-AC lines to the Speech Manager by implementing AC's ITranslatable interface - see the Manual's "Custom translatables" chapter, as well as the "Custom Translatable Example" script, for details.

    The Speech Manager can only search MonoBehaviours that implement this directly, however. If your data is in a ScriptableObject, though, it should be possible to have it be referenced by creating a dedicated scene that uses a series of components that each reference a SO - acting as a "bridge" of sorts, i.e.:

    using UnityEngine;
    using AC;
    
    public class MyTranslationBridge : MonoBehaviour, ITranslatable
    {
    
        public MyScriptableObject myScriptableObject;
    
        public string GetTranslatableString (int index) => myScriptableObject.GetTranslatableString (index);
        public int GetTranslationID (int index) => myScriptableObject.GetTranslationID (index);
    
        #if UNITY_EDITOR
    
        public void UpdateTranslatableString (int index, string updatedText)
        {
            myScriptableObject.UpdateTranslatableString (index, updatedText);
        }
    
        public void SetTranslationID (int index, int lineID)
        {
            myScriptableObject.SetTranslationID (index, lineID);
        }
    
        public int GetNumTranslatables () => myScriptableObject.GetNumTranslatables ();
        public bool CanTranslate (int index) => myScriptableObject.CanTranslate (index);
        public bool HasExistingTranslation (int index) => myScriptableObject.HasExistingTranslation (index);
    
        public string GetOwner (int index) => myScriptableObject.GetOwner (index);
        public bool OwnerIsPlayer (int index) => myScriptableObject.OwnerIsPlayer (index);
        public AC_TextType GetTranslationType (int index) => myScriptableObject.GetTranslationType (index);
    
        #endif
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.