t
t is Lingui’s primary string-producing macro. It translates a message at the call site and returns
the resulting string.
Use t when you want a translated label, heading, or piece of inline text and you do not need
embedded markup. For rich text with links or emphasis, use the Trans Component Macro instead.
For the framework-agnostic Lingui semantics, see the
official t reference.
<p>
{name ? $t`Hello ${name}` : $t`Hi there!`}
</p> Hello Lingui
Locale
Name
<script lang="ts"> import { t } from "lingui-for-svelte/macro";
let name = $state("Lingui");</script>
<p>{$t`Hello ${name}`}</p>In .svelte files, use $t. It re-evaluates automatically when the active locale changes. Bare
t (without $) is a compile-time error.
See Reactive Macros for how this works, when to use
$derived, and the t.eager escape hatch.
---import { t } from "lingui-for-astro/macro";
const name = "Lingui";---
<p>{t`Hello ${name}`}</p>In .astro, t is request-bound and non-reactive.
import { t } from "@lingui/core/macro";
const name = "Lingui";
const label = t`Hello ${name}`;// -> "Hello Lingui" or the equivalent in the active localeWhen t is a good fit
Section titled “When t is a good fit”- you want a translated string immediately
- the message is naturally authored as text or a string template
- rich text structure is not the main concern