Back

gt@2.13.0

Ernest McCarter avatarErnest McCarter
gtderivet-functiondx

Overview

The t() function now automatically derives dynamic content — no more wrapping variables in derive(). This is enabled by default and works out of the box with the GT CLI.

This is the latest step in a series of derive() improvements. First, gt-react@10.15.0 brought derive() support to the t tagged template literal. Then gt@2.12.0 extended derive() to resolve values from objects and arrays. Now, gt@2.13.0 removes the need to call derive() at all when using t().

Before & after

Previously, dynamic values in t() required an explicit derive() call:

const noun = cond ? "boy" : "girl"
const result = t("The " + derive(noun))

Now, just use the variable directly:

const noun = cond ? "boy" : "girl"
const result = t("The " + noun)

The CLI handles derivation automatically when it parses your t() calls — it detects variables with a finite set of possible string values and derives them behind the scenes.

Configuration

Auto-derive is enabled by default. To disable it, set autoDerive to false in your gt.config.json:

{
  "files": {
    "gt": {
      "parsingFlags": {
        "autoDerive": false
      }
    }
  }
}

Note: This applies only to the t() function. The t tagged template macro is unaffected — it already handles derivation through the template literal syntax introduced in gt-react@10.15.0.