# gt: General Translation CLI tool: PO / POT URL: https://generaltranslation.com/en-US/docs/cli/formats/po.mdx --- title: PO / POT description: How to automatically translate PO/POT files with General Translation --- ## Overview `gt` can be used to automatically translate your project's [PO (Portable Object)](https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html) and POT (PO Template) files. These are the standard file format used by [GNU gettext](https://www.gnu.org/software/gettext/), one of the oldest and most widely adopted internationalization systems. POT files contain the source strings extracted from your code, and PO files contain the translations for a specific locale. We will follow these 4 steps: Add your environment variables Install [`gt`](/docs/cli) Create a `gt.config.json` file Run [`gt translate`](/docs/cli/translate#translate) --- ## Step 1: Add your environment variables Add your production API key and project ID to your environment variables. This is necessary to use the `gt` tool. You get these from the [General Translation dashboard](https://generaltranslation.com/dashboard). ```bash title=".env" GT_API_KEY= GT_PROJECT_ID= ``` ## Step 2: Install `gt` Install the `gt` tool in your project. ```bash npm i gt ``` ```bash yarn add --dev gt ``` ```bash bun add --dev gt ``` ```bash pnpm add --save-dev gt ``` ## Step 3: Create a `gt.config.json` file Create a `gt.config.json` file in the root of your project. ```json title="gt.config.json" { "defaultLocale": "en", "locales": ["zh", "es", "ja"], "files": { "pot": { "include": ["locales/[locale]/*.pot"], "transformationFormat": "po" } } } ``` Feel free to customize the `gt.config.json` file to your needs. See the [configuration](/docs/cli/reference/config) docs for more information. Update the `pot` file format such that the `include` path matches your project structure. The `transformationFormat` option tells `gt` to output translated files as `.po` files instead of `.pot` files. This is the standard workflow: POT files are source templates, and PO files contain the actual translations for each locale. Translations will preserve the original PO/POT string syntax. ## Step 4: Add the `gt translate` command to your build process Add the `gt translate` command to your build or CI process before the build command to automatically add translations to your project. ```json title="package.json" { "scripts": { "translate": "npx gt translate", "build": "npm run translate && " } } ``` This will generate translations for all of your locales and save them to your project. If you want to commit these files to your repo, you can instead run this command before committing. You're done! Now your project will automatically update all of your translation PO/POT files any time your project changes. --- ## Notes - You can automatically add translations to your project with the [`gt translate`](/docs/cli/translate#translate) command. - If you want to commit your translation files, you should run the `gt translate` command before committing. - To configure the output path for your translations, see the [configuration](/docs/cli/reference/config) docs. - Both `pot` and `POT` are accepted as the config key in `gt.config.json`. ## Next steps - See the [translate command](/docs/cli/translate) for CLI usage details. - Learn about [keyed metadata](/docs/cli/reference/keyed-metadata) for per-key translation instructions.