Skip to main content

useTranslation

useTranslation returns a t() function that resolves your theme’s text keys for the active locale: Studio’s live edits, the merchant’s translations from the Translation Manager, then your theme’s default copy. TranslationProvider supplies it; withWeaverse mounts one for you.

Import

Type

useTranslation throws if no TranslationProvider is above it. In a theme, that means the root Layout isn’t wrapped with withWeaverse.

Usage

Keys are dot paths into your theme’s text, for example cart.title reads { "cart": { "title": "..." } }. t() replaces {{name}} placeholders with the matching variables value. It doesn’t handle plurals or number formatting; see i18next Integration for that.

Resolution Order

t(key) returns the first value it finds, highest priority first:
  1. The external t passed to withWeaverse(Layout, { t }) or TranslationProvider, unless it returns an empty string or the key unchanged
  2. Unsaved edits the merchant is making in Studio’s design mode
  3. The merchant’s translations for the active locale (merchantOverrides)
  4. Your theme’s default copy (staticContent)
  5. The key itself
Studio’s translations always win over the bundled default copy. Editing your theme’s default JSON doesn’t change a key the merchant has already translated in Studio.

Where the Data Comes From

withWeaverse reads weaverseTheme.staticContent and weaverseTheme.merchantOverrides from the root route’s loader data, so the root loader must return loadThemeSettings() as weaverseTheme:
app/root.tsx
staticContent comes from i18n.staticContent in your theme schema. See Translation Feature Guide to enable the Translation Manager.

TranslationProvider

withWeaverse already renders TranslationProvider, so themes rarely use it directly. Use it to provide t() to a tree that isn’t under the Weaverse root, such as a test or a standalone component preview.
useThemeText, ThemeTextProvider and the themeTextStore prop are deprecated aliases of useTranslation, TranslationProvider and translationStore.
The Next.js adapter exports useTranslation and TranslationProvider from @weaverse/hydrogen/next, where WeaverseNextRootProvider mounts the provider.
Last modified on November 23, 2026