Skip to main content
Hook to access the translation t() function. Must be used inside a component wrapped by withWeaverse or TranslationProvider. Keys are dot paths into the theme’s text (cart.title reads { "cart": { "title": "..." } }), and t() replaces {{name}} placeholders with the matching variables value. It does not handle plurals or number formatting. 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. The theme’s default copy (staticContent, from i18n.staticContent in the theme schema).
  5. The key itself.
Studio’s translations always win over the bundled default copy, so editing the theme’s default JSON does not change a key the merchant has already translated. withWeaverse reads staticContent and merchantOverrides from the root loader’s weaverseTheme (the loadThemeSettings() result). Throws when no TranslationProvider is above it.

Returns

TranslationValue