GT4T knowledge base

Translate .lua, .js, or .ts files

Jump to Section

GT4T File Translator can translate json files. You can specify keys that need to be translated.

Find files that need to be translated. Select them and drag and drop them to GT4T File Translator

Suppose you have a .lua file with the following content:


ItemList = {    
    ['weapon_dagger']                = {
        ['name'] = 'weapon_dagger',
        ['label'] = 'Dagger',
        ['weight'] = 1000,
        ['description'] = 'A short knife with a pointed and edged blade, used as a weapon'
    },
    ['weapon_bat']                   = {
        ['name'] = 'weapon_bat',
        ['label'] = 'Bat',
        ['weight'] = 1000,
        ['description'] = 'Used for hitting a ball in sports (or other things)'
    },
    ['weapon_bottle']                = {
        ['name'] = 'weapon_bottle',
        ['label'] = 'Broken Bottle',
        ['weight'] = 1000,
        ['description'] = 'A broken bottle'
    },

Or similar objects in typescript or javascript:


interface Item {
    name: string;
    label: string;
    weight: number;
    description: string;
}

const ItemList: Record<string, Item> = {
    weapon_dagger: {
        name: 'weapon_dagger',
        label: 'Dagger',
        weight: 1000,
        description: 'A short knife with a pointed and edged blade, used as a weapon'
    },
    weapon_bat: {
        name: 'weapon_bat',
        label: 'Bat',
        weight: 1000,
        description: 'Used for hitting a ball in sports (or other things)'
    },
    weapon_bottle: {
        name: 'weapon_bottle',
        label: 'Broken Bottle',
        weight: 1000,
        description: 'A broken bottle'
    }
};

You want to get all the values of key label and description translated.

  1. Left-click the GT4T icon at the bottom right corner of the screen to bring up GT4T quick menu and click File Translator on the menu to start the GT4T File Translator.

office_1

  1. First confirm if the language pair is correct, if there is an error, click on the location as shown to change it. English to Spanish translation is taken as an example here.

office_2

  1. Select the file to be translated, hold down the left mouse button on the selected file, drag the mouse to the GT4T drag-and-drop area, and then release the left mouse button.

office_3

  1. “Specify key names” dialog appears. For our example, type “name” and “description” in the box. office_5

Check “Translate all keys with text values” if you want to translate all text values. You can optionally provide keys that do not need to be translated.

  1. After the translation is finished, there will be an additional GT4T_translated_Spanish (Español) folder. The translated files are in that folder.

office_4

** Tips ** GT4T can translate folders. Drag and drop a folder into GT4T File Translator to translate all files of the selected type under that folder and subfolders.