website logo
Navigate through spaces
Chord Commerce
⌘K
Getting Started
CMS
Data
OMS
Integrations
👩‍💻Developer Tools
Shopify
Docs powered by archbee 

useTranslate

The useTranslate hook provides support for internationalization, powered by react-intl.

To localize the text in your React components, use the translate function returned by the useTranslate hook. translate will load the specified string from your language resource file.

We recommend using translate even if your site currently only supports one language. It's easier to edit your website text if it's all in a single configuration file, and it makes it trivial to add multi-language support in the future.

Example

useTranslate

Returns

The useTranslate hook returns a translate function:

translate

Arguments:

translate(id, values)

Argument

Type

Description

id

String

A key in your language resource file.

values?

Object

(Optional) Values for string interpolation.

Example:

translate

The component above assumes there is a file at /src/intl/<language>.json that looks like this:

en-US.json
Updated 14 Nov 2022
Did this page help you?
Yes
No
UP NEXT
useUser
Docs powered by archbee 
useTranslate