在React-I18Next中呼叫CDN?
我正在尝试使用I18next-resources-backend和I18next-chared-backend使用此处推荐的框架来访问我本地化应用的资源: https://www.i18next.com/how-to/backend-fallback ,关键区别是我试图从CDN访问资源,而不是一个地方文件。
.init({
fallbackLng: 'en',
namespace: 'resources'
)}
backend: {
backends: [
HttpBackend,
resourcesToBackend((language, namespace, callback) => {
import(`./${language}/${namespace}.json`)
.then(resources => {
callback(null, resources)
})
.catch(error => {
callback(error, null)
})
})
]
},
backendOptions: [
{
loadPath: 'https://url/domain/link/dir/{language}}/{{namespace}}.json'
}
]
它无法正常工作,我在控制台中遇到此错误:
object {错误:错误}:错误:错误:无法找到模块'./es/translation.json'
有人有这个问题的经验吗?
I am attempting to access the resources for my localized app using i18next-resources-to-backend and i18next-chained-backend using the framework recommended here: https://www.i18next.com/how-to/backend-fallback, with the key difference being I am attempting to access the resources from a CDN, not a locale file.
.init({
fallbackLng: 'en',
namespace: 'resources'
)}
backend: {
backends: [
HttpBackend,
resourcesToBackend((language, namespace, callback) => {
import(`./${language}/${namespace}.json`)
.then(resources => {
callback(null, resources)
})
.catch(error => {
callback(error, null)
})
})
]
},
backendOptions: [
{
loadPath: 'https://url/domain/link/dir/{language}}/{{namespace}}.json'
}
]
It is not working and I am getting this error in the console:
Object { error: Error }: error: Error: Cannot find module './es/translation.json'
Anyone have experience with this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论