Handling text translation

We do not currently support text translation natively. However, we can still accomplish translation with the assistance of JavaScript. The followings are the steps:

Step 1: SettingsUser Defined Functions(Javascript)

Step 2: Copy and paste the following Javascript into the User Defined Functions

let translations=[
  {id: "lblhello", en: "hello", zh:"哈咯", jp:"こんにちは"},
  {id: "lblworld", en: "world", zh:"世界", jp:"世の中"}

window.$tt = function(id){
    let e = translations.find((e)=>e.id==id);
    return e==null?id:e[fx.data.lang||"en"];
    return id;

This above code defines a variable called "translations" which stores translations for different languages. The translations are organized in an object where each language is represented by a key, and the value is an array of translation objects.

The code also defines a function called "$tt" that can be used to retrieve translations based on a given ID. The function takes an "id" parameter and tries to find the corresponding translation based on the current language stored in "fx.data.lang". If the translation is found, the function returns the translated text. If the translation is not found or if an error occurs, it returns the original ID.

Step 3: To use the translation in the Designer tab.

The function uses the current language to determine which translation to return. If the translation is not found, it returns the ID itself.

The following is the expression:

{{ $tt("lblhello") }}

Step 4: To change the language, simply change the lang field in your JSON.