Skip to content

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.

Source
<p>
  {name ? $t`Hello ${name}` : $t`Hi there!`}
</p>
Result

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.

  • 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