带有index.js的i18n目录和本地化文件:es.js,it.js和en.js.
index.js内容:
export { default as es } from './es'
export { default as it } from './it'
export { default as en } from './en'
en.js内容文件(类似于es.js和it.js):
/*eslint-disable max-len,quotes*/
export default {
"about.h1": "This is the title from the about page",
...
}
我尝试加载本地化消息:
import * as i18n from 'i18n'
...
const intlData = {
locale: 'en',
messages: i18n['en']
}
但是消息变量未定义。
当我用:
检查控制台日志时window.console.log(i18n)
我未定义:
Object {__esMOdule: true}
es:undefined
get es: function get()
it: undefined
get it: function get()
en: undefined
get en: function get()
__proto__: Object
我应该得到类似的东西:
Object {__esMOdule: true}
es: Object
it: Object
en: Object
__proto__: Object