Chord OMS
...
SDK Reference 4.x
useTranslate
4 min
the usetranslate hook provides support for internationalization, powered by react intl https //formatjs io/docs/getting started/installation/ 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) trueleft unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type left unhandled content type 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" } }