无法使用 t 函数解析翻译,但它适用于 getResourceBundle

问题描述 投票:0回答:0

我正在使用

i18next-locize-backend
包从 Locize 加载命名空间。使用调试标志,我看到我所有的密钥都被正确加载:
i18next::backendConnector: loaded namespace translation for language en {...}

但是,我无法使用以下方法获取翻译后的值:

i18next.init({
    backend: {...}
    ns: 'translation',
    lng: 'en',
    debug: true,
}, (err, t) => {
    t('myKey')
    t('translation:myKey')
    t('myKey', {lng: 'en', ns: 'translation'})
})

但是它可以使用

i18next.getResourceBundle('en', 'translation')['myKey']

我错过了什么吗?

i18next
© www.soinside.com 2019 - 2024. All rights reserved.