Back

gt@2.11.0

Fernando Aviles avatarFernando Aviles
gt-clicdnpublishfilesjsonmdxyamli18n

Overview

The GT CLI can now publish any translated file type to the GT CDN. JSON, MDX, YAML, and all other supported file types can now be published directly from the translate, upload, and save-local commands.

Configuration

Global publish flag

Add --publish to any supported command:

npx gt translate --publish

Or set it in gt.config.json:

{
  "publish": true
}

This publishes all translated files (including GT JSON) to the CDN.

Per-file publish control

You can opt individual files in or out using the include pattern syntax. Instead of a plain glob string, use an object with a publish flag:

{
  "defaultLocale": "en",
  "locales": ["fr", "es"],
  "files": {
    "json": {
      "include": [
        { "pattern": "locales/[locale]/*.json", "publish": true },
        { "pattern": "locales/[locale]/internal/**/*.json", "publish": false }
      ]
    }
  }
}

In this example, all JSON files under locales/[locale]/ are published to the CDN, except files under the internal/ subdirectory.

GT JSON publish control

GT's internal format has its own publish flag under the gt key:

{
  "files": {
    "gt": {
      "output": "public/i18n/[locale].json",
      "publish": true
    }
  }
}

Resolution order

For any given file, the CLI resolves publish intent in this order:

  1. Explicit opt-out — file matches an include entry with "publish": false → not published or removed from the CDN
  2. Explicit opt-in — file matches an include entry with "publish": true → published to the CDN
  3. Global fallback — uses the top-level publish setting (defaults to false if unset)

If no publish configuration is set at any level, the publish step is skipped entirely — no API calls are made.

Commands that support publishing

CommandBehavior
gt translatePublishes after downloading translations
gt uploadPublishes after uploading source files
gt save-localPublishes after saving local edits