Forum rules - please read before posting.

Game Text Export Questions

Hi Chris,
I’m currently translating my game and have encountered a few issues that I’m hoping you can help me resolve:

1) I have several scenes where I’ve used "Quotes Text" in my game, each displaying text through a Canvas with TextMeshPro. However, when I gather the text using the "Speech - Game Text" tool, these scenes don’t appear in the exported sheet. How can I ensure they’re included in the exported sheet?
P.S. All of them are included in the Build Profile.
https://prnt.sc/dF6vkR5LTxv4
https://prnt.sc/PwZhDgYdvAxL

2) I’ve excluded hotspots from being gathered, but they still appear in the sheet. How can I completely remove them from the export process?
https://prnt.sc/c8OsCohmJ_lW

3) My inventory items are displaying both the “Name” and “Display Name,” which are identical. Is it safe to use “Speech - Game Text - Always Merge” to prevent duplication? Additionally, will the “Always Merge” option remove the duplicates from the game as well?
https://prnt.sc/Nhu28TLleGQe

Thank you

Comments

  • edited December 15

    1) Text from a Canvas will only be picked up automatically if it's linked to an AC Menu.

    To pull non-AC text into the Speech Manager, you'll need a custom script that implements ITranslatable. The Manual's "Custom translatables" chapter covers this in more detail, but a sample script that works with TextMeshPro is below.

    2) If the Hotspot text was gathered up before you opted to exclude it, you'll need to re-run the "Gather text" process to remove it.

    3) What's your AC version? An Item's Label (if not name) field ought to override its Display field - it shouldn't be gathering both. Can you share images of how they each appear in the Speech and Inventory Managers?

    When merging, it's important to note that the text's type (i.e. Hotspot, Menu Element) etc is not factored in - outside the case of Speech.

    using UnityEngine;
    using TMPro;
    using AC;
    
    public class CustomTMProText : MonoBehaviour, ITranslatable
    {
    
        public TextMeshProUGUI textBox;
        public int myCustomLineID = -1;
    
        void OnEnable()
        {
            EventManager.OnInitialiseScene += OnInitialiseScene;
            EventManager.OnChangeLanguage += OnChangeLanguage;
        }
    
        void OnDisable()
        {
            EventManager.OnInitialiseScene -= OnInitialiseScene;
            EventManager.OnChangeLanguage -= OnChangeLanguage;
        }
    
        void OnInitialiseScene()
        {
            OnChangeLanguage(Options.GetLanguage());
        }
    
        void OnChangeLanguage(int languageIndex)
        {
            textBox.text = KickStarter.runtimeLanguages.GetTranslatableText(this, 0);
        }
    
        public string GetTranslatableString (int index) => textBox.text;
        public int GetTranslationID (int index) => myCustomLineID;
    
    
        #if UNITY_EDITOR
    
        public int GetNumTranslatables () => 1;
        public bool CanTranslate (int index) => textBox && !string.IsNullOrEmpty (textBox.text);
        public bool HasExistingTranslation (int index) => myCustomLineID >= 0;
        public string GetOwner (int index) => string.Empty;
        public bool OwnerIsPlayer (int index) => false;
    
    
        public void UpdateTranslatableString (int index, string updatedText)
        {
            textBox.text = updatedText;
        }
    
    
        public void SetTranslationID (int index, int lineID)
        {
            myCustomLineID = lineID;
        }
    
    
        public AC_TextType GetTranslationType (int index)
        {
            // Return the type of translation, for sorting within the Speech Manager
            return AC_TextType.Custom;
        }
    
        #endif
    }
    
  • Thank you for sharing the script, Chris. Everything is working well now. The other double-inventory name issue hasn’t appeared again after gathering the text, so all good for now. Thanks again for your support!

  • Hi Chris, I have a question. When I translate the game to RTL languages like Arabic, will these custom Canvas scenes use RTL, or will they remain LTR?

  • The properties of the Canvas / Text box will remain unchanged - only the text will be replaced by the translation.

  • Thank you, Chris!

  • I have another question. If I translate my game into languages such as Chinese, German and Arabic, will the fonts work out of the box, or will I need to import them?

  • You'll need to supply Fonts that are capable of displaying the characters in your game's text - their display can't be automatic.

    However, if your Menus use Unity UI throughout, you can use the following script from the AC Wiki to dynamically swap out your Fonts based on the current language:

    https://adventure-creator.fandom.com/wiki/Per-language_Menus

  • Thank you, Chris. This script is very helpful. The script Wiki page mentioned that I need to attach it to the root of my Unity UI menu prefab. Does that mean I should attach it to every menu prefab in my game like subtitle, Pause, options etc?

  • Regarding the Language Index, is it just a number? For example, Japanese is 1 and Spanish - Spain is 2, etc. Is that correct?

    https://prnt.sc/0eDULsPxfQhN

  • Hi Chris, I'm experiencing an issue where the Canvas scenes are not displaying translations—they always show English text. I've attached the font script and assigned the appropriate font, but it still only displays English. Any idea why this might be happening?
    https://prnt.sc/a8ZTm0hxU8i5
    https://prnt.sc/NLOCtgWWaima

  • The Dynamic Font Language script won't affect what text is displayed - only what font is used to display it.

    I've updated the CustomTMProText script above to include replacement of text at runtime.

  • Thank you, Chris. The script giving me these red error:
    https://prnt.sc/llojhJ1_d3UK

    Any idea how to fix it?

  • Update the script you created for the first instance of the code - the errors suggest you've copy/pasted it into a second file named Translation_forced

  • Thank you, Chris. The script is working now, but I’ve encountered an issue: some Canvas scenes are displaying both the English text and the translated version simultaneously. These scenes are identical to the others that are functioning correctly, yet for some reason, they always show both languages. Could this be related to the script?

    https://prnt.sc/Fk8OWBUkEcVR
    https://prnt.sc/d_7Ds6HA44iA

    Working scene:
    https://prnt.sc/cpcuDcGRGEQc

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.