# gt: General Translation CLI tool: Autoderive URL: https://generaltranslation.com/en-US/docs/cli/features/autoderive.mdx --- title: Autoderive description: Automatically derive interpolated values in translation functions and JSX components --- ## Overview When autoderive is enabled, interpolated values are parsed as if they were wrapped in [`derive()`](/docs/next/api/strings/derive). This generates separate translation entries for each possible value, preserving word agreement and conjugation across languages. Autoderive works in two contexts: - **Strings** — interpolated values in `t()`, `gt()`, and `msg()` calls - **JSX** — expressions inside `` components that reference const variable declarations Autoderive is **disabled by default**. ## Configuration Enable autoderive for both strings and JSX: ```json title="gt.config.json" { "files": { "gt": { "parsingFlags": { "autoderive": true } } } } ``` You can also enable autoderive selectively for just strings or just JSX: ```json title="gt.config.json" { "files": { "gt": { "parsingFlags": { "autoderive": { "jsx": true, "strings": false } } } } } ``` ## String example ```jsx const gt = useGT(); const role = isAdmin ? "admin" : "user"; // With autoderive enabled, this is parsed as derived: gt(`Welcome back, ${role}!`); // Generates: // "Welcome back, admin!" → "¡Bienvenido de nuevo, administrador!" // "Welcome back, user!" → "¡Bienvenido de nuevo, usuario!" ``` Without autoderive, you must explicitly use [`derive()`](/docs/next/api/strings/derive) to get the same behavior. ## JSX example ```jsx const label = condition ? "boy" : "girl"; Hello, {label} // Generates two translation entries: // "Hello, boy" → "Hola, chico" // "Hello, girl" → "Hola, chica" ``` JSX autoderive resolves `const` variable declarations referenced inside `` components. It supports: - Ternary expressions (`const x = cond ? "a" : "b"`) - Nested ternaries (`const x = a ? "small" : b ? "medium" : "large"`) - String, number, and boolean literals - String concatenation and template literals - Chained const references (`const alias = base`) **`const` only:** Only `const` declarations are supported. `let` and `var` variables produce a warning because they can be reassigned. Destructured variables (`const { x } = obj`) are not supported. **Note:** The `t` tagged template macro is unaffected — it handles derivation through its template literal syntax. ## Related - [`derive()` function reference](/docs/next/api/strings/derive) - [Auto JSX injection](/docs/cli/features/auto-jsx-injection) - [Release notes: gt@2.13.0](/devlog/gt_v2_13_0)