Use a Text Pool Technical Object for Script Translation

As a story developer, you can use a text pool technical object with related APIs to translate the texts in the scripts.

Prerequisites

To translate the texts used in the scripts, make sure to enable translation for the story. From the edit time toolbar, select (Story Settings)Start of the navigation path Next navigation step End of the navigation path Story Details. Then, switch on Enable translation.

Context

In the following script example to apply Hello World to a text widget, the text is static and won't be translated:

You can use a text pool technical object with related APIs, so that Hello World can be translated.

Procedure

  1. In the Scripting section of the Outline panel, select Start of the navigation path Next navigation step End of the navigation path Text Pool.

    You've added the text pool technical object, whose default ID is TextPool_1. You can change to another name if you want.

  2. In the Text Pool Values section of the Text Pool configuration panel, enter the texts to be used in the scripts and translated:
    1. Choose (Add) to add a text pool value.

      You've added a text pool value, whose default ID is Value_1. You can change the ID as you want, which is used in scripting and corresponds to the text.

    2. In the Text column, enter the corresponding source text for translation, for example, Hello World.
    3. You can add other text pool values in ID and text pair in the same way.
  3. To finish the configuration, choose Done.
  4. Use the getText API to get the text via the ID.
    For example, you can write the following script to apply the text configured in the text pool technical object TextPool_1, whose ID is Value_1, to the text widget Text_1:
  5. Translate the texts from the text pool technical object:
    1. From the navigation bar, choose (Translation).
    2. In the Translation dashboard, select the story and then (Edit Translations) from the toolbar.
    3. You can find the texts from the text pool technical object, and translate them to the target language.

    For more information about editing translations, refer to Edit Translations Manually.

Results

You've used the text pool technical object with related APIs to translate the texts in scripts to different languages. In view time, these texts can be dynamically changed with the data access language, based on the translated texts in the Translation dashboard.