Reference

Supported formats

TolkBot supports common i18n file formats and preserves your file structure during translation.


JSON

The primary format for most i18n frameworks. TolkBot handles both flat and nested JSON structures.

Flat JSON

{
    "welcome": "Welcome to our app",
    "login": "Log in",
    "signup": "Sign up"
}

Nested JSON

{
    "common": {
        "welcome": "Welcome to our app",
        "actions": {
            "login": "Log in",
            "signup": "Sign up"
        }
    }
}

Namespaced files

Some frameworks split translations across multiple files by namespace:

public/locales/en/common.json
public/locales/en/dashboard.json
public/locales/en/settings.json

TolkBot handles this pattern and translates each namespace file independently.


TypeScript / JavaScript

TolkBot can parse TypeScript and JavaScript files that export translation objects:

export default {
    welcome: "Welcome to our app",
    dashboard: {
        title: "Dashboard",
    },
};

export const en = {...} and module.exports = {...} work too, as do as const and satisfies annotations.

Where the CLI looks for them

Because any .ts file could hold an object literal, the CLI only looks for TypeScript translations inside the conventional locale directories — messages/, locales/, i18n/, translations/, lang/, and their src/, app/ and public/ variants. JSON translations are also searched for outside those directories.


Style preservation

When writing translations back to files, TolkBot preserves:

  • Key ordering — keys appear in the same order as the source file
  • Nesting structure — nested objects maintain their hierarchy
  • Indentation — follows the formatting of the original file
  • Placeholder syntax — ICU ({var}), Mustache ({{var}}), and simple placeholders are preserved exactly

Placeholder styles

TolkBot auto-detects the placeholder style used in your source strings:

StyleSyntaxExample
ICU{variable}{count, plural, one {1 item} other {# items}}
Mustache{{variable}}Hello {{name}}, welcome back
None—Plain text with no placeholders

Placeholders are validated after translation to ensure none are missing or modified.

Previous
Validate in CI