使用i18next的基本翻译功能,您可以指定一种语言,以便同时显示英语和另一种语言:
import { useTranslation } from 'react-i18next'
...
const { t } = useTranslation()
...
`${t('Official Ballot')}/${t('Official Ballot', { lng: 'es' })}` // Official Ballot/Boleta Oficial但是,<Trans>组件似乎没有lng属性/选项…或者真的是这样?
(忽略没有额外的html标记,这通常与<Trans />标记一起使用。这是一个简化的示例。)
import { Trans } from 'react-i18next'
...
<Trans i18nkey="Official Ballot" /> // Official Ballot ⬆如何为该标签设置"lng“?
发布于 2020-06-21 00:23:30
Trans组件有一个传递给t方法的tOptions属性。
<Trans
i18nKey={"message"}
tOptions={{ lng: "de" }} // <--
components={[<strong>placeholder</strong>]}
/>https://stackoverflow.com/questions/62464906
复制相似问题