Chord OMS
...
Next.js
SDK Reference
useTranslate
4min
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 import { usetranslate } from ' /hooks/actions' export default () => { const { translate } = usetranslate() return \<h1>{translate('site title')}\</h1> } 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 import { usetranslate } from ' /hooks/actions' export default () => { const { translate } = usetranslate() return \<h1>{translate('site title')}\</h1> } the component above assumes there is a file at /src/intl/\<language> json that looks like this { "site" { "title" "my site" } }