gtx-cli
raw JSON → 2.14.19 verified Sat Apr 25 auth: no javascript
CLI tool for AI-powered i18n (wrapper for gt). Current stable version: 2.14.19. Active development. Key differentiators: leverages General Translation's AI for automated localization workflows. Alternative to manual i18n tooling, integrates with gt ecosystem.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/gtx-cli/index.mjs not supported. ↓
cause Using CommonJS `require()` on an ESM-only package.
fix
Switch to
import { gtx } from 'gtx-cli' and set "type": "module" in your package.json, or use dynamic import(). error TypeError: gtx is not a function ↓
cause Default import of package that only exports named exports.
fix
Use
import { gtx } from 'gtx-cli' instead of import gtx from 'gtx-cli'. Warnings
breaking In v2.x, the API changed from default export to named export. Use `import { gtx } from 'gtx-cli'` instead of `import gtx from 'gtx-cli'`. ↓
fix Update import to named export: import { gtx } from 'gtx-cli'
deprecated The `cli` function is deprecated in favor of `runGtx`. ↓
fix Replace `cli` with `runGtx`
gotcha The package is ESM-only and does not support CommonJS `require()`. ↓
fix Use `import` syntax and ensure your project supports ESM.
Install
npm install gtx-cli yarn add gtx-cli pnpm add gtx-cli Imports
- gtx wrong
const gtx = require('gtx-cli')correctimport { gtx } from 'gtx-cli' - cli
import { cli } from 'gtx-cli' - runGtx wrong
import runGtx from 'gtx-cli'correctimport { runGtx } from 'gtx-cli'
Quickstart
import { gtx } from 'gtx-cli';
const result = await gtx({
source: './src/locales',
target: './dist/locales',
apiKey: process.env.GT_API_KEY ?? '',
});
console.log('Translation completed:', result);