Chord OMS
...
Next.js
SDK Reference
useTranslate
4 min
this page's documentation only applies to chord's next js starter prior to the release of the react docid\ ewxkrz0jhh0zpphikkcri the next js starter now uses the react sdk and does not use the methods documented on this page check out the react sdk reference for complete documentation, and the react sdk migration guide docid\ qmilhjfpz9wbjyzbe50ku for details on how to upgrade 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' // inside a function component const translate = 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 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 // /src/intl/en us json { "site" { "title" "my site" } }