Automatic Translation

How to automatically translate your project using the General Translation CLI tool

npx gtx-cli@latest

Overview

The General Translation CLI tool (gtx-cli) lets you automatically translate your project into any of the supported languages.

It provides first-class support for gt-next and gt-react, allowing you to scan your project for translatable content, translate it, and generate translation data JSON files.

The CLI tool can also generate translations for third-party i18n libraries like next-intl or i18next.

Lastly, the CLI tool can translate JSON, Markdown, MDX, JS, and TS files.

A production API key is required for the translate command. Get one for free at generaltranslation.com!


There are two main commands to be aware of: init and translate.

  • The init command is used to set up your project. It provides a step-by-step wizard that will configure your project for internationalisation, including:
  • Setting up plugins and React providers
    • Generating API keys
    • Configuring your project’s locales and file structure
  • The translate command is intended to be added to your CI/CD pipeline. It scans your project for content to be translated. The content is then uploaded to a CDN or added to your app bundle for use at runtime.

Getting started

Depending on which i18n library your project uses, follow one of the tutorials below:

Usage

CommandDescription
npx gtx-cli initRun the GT setup wizard.
npx gtx-cli configureConfigure your project’s GT settings.
npx gtx-cli translateTranslate your project via the GT API.
npx gtx-cli authGenerate an API key and project ID for your project.
npx gtx-cli generateGenerate a new translation data JSON file. Use when working with the library standalone.

How is this guide?

Automatic Translation