Retrieves every translated string in a namespace.
Use it when you need several strings at once, such as to pass a set of labels to your own code. To
retrieve a single string with a fallback, use translate().
The strings can change while the page is open. Call it while a component renders, so the component updates when they change.
Don't change the returned map. Every component on the page reads the same map, so a change shows in all of them, and the site doesn't save it.
Namespace of the strings. Case-sensitive, and must match the namespace exactly.
Translated strings in the namespace.
An empty map when the namespace has no strings.
Retrieves a lookup function for the translated strings in a namespace.
Call the lookup function with a key to retrieve that key's string. When the namespace has no string for the key, it returns the fallback you specify, or the key itself when you don't specify one. A string that's empty in the namespace is returned as is, not replaced by the fallback.
To show your own default text when there's no string, specify it as the fallback, as in
t('nextButtonAriaLabel', 'Next product'). Without a fallback, the lookup function returns the key, so a
default you add with ?? or ||, as in t('nextButtonAriaLabel') ?? 'Next product', isn't used for a missing
string.
The lookup function reads the current strings each time you call it, so a lookup function you keep returns the current strings, even after they change. Call it while a component renders, so the component updates when the strings change.
To retrieve every string in a namespace at once, use getTranslations().
Namespace of the strings. Case-sensitive, and must match the namespace exactly.
Function that retrieves a translated string by its key. When the namespace has no string for the key, it returns the key itself, unless you specify a fallback.
Last updated: 21 October 2026