目前,我正在考虑以下选项:
我想使用“ t”
我亲自执行此操作,其中不包含任何组件的utils文件:
import { t } from 'i18next';
export async function generateMailBody(user, isContact) {
const yourMessage = isContact ? t('Your_message') : t('Problem_description');
...
}
如果您需要在React之外使用I18Next,请选择正确的方法:
✔在调用t()之前确保初始化(等待initpromise)。✔如果要保持反应性,请从反应中传递t()。
阅读有关它的更多信息