Skip to content

Trans

Trans is the general-purpose Component Macro for translated markup content.

Use Trans when a translator needs to preserve links, emphasis, or other embedded structure. It can also be used for non-rich-text messages, but its clearest advantage shows up when the message is naturally authored as markup.

For the framework-agnostic Lingui semantics, see the official Trans reference.

Source
<p>
  <Trans>
    Say hello to <strong>{name}</strong>.
  </Trans>
</p>
Result

Say hello to Lingui.

Locale
Name
<script lang="ts">
import { Trans } from "lingui-for-svelte/macro";
</script>
<Trans>
Read the <a href="/docs">documentation</a>.
</Trans>
  • the translation includes links or emphasis
  • the structure matters to translators
  • the message reads more naturally as markup than as a string template