vue-generate-i18n
v0.1.2
Published
webpack i18n loader
Downloads
2
Readme
yarn add vue-generate-i18n
配置 webpack
。
module: {
strictExportPresence: true,
rules: [
{
test: /\.(vue)$/,
exclude: /node_module/,
loader: require.resolve("vue-generate-i18n"),
}
]
}
配置完成,可以开始愉快的玩耍了 😊
yarn start
项目启动后,可以看到 src
目录下自动生成了一个 i18n
文件夹:
├─src
| ├─i18n
| | ├─i18n.js
| | ├─zh
| | | └data.json
i18n.js
用来引入和切换资源文件:
import zh from './zh/data.json'
function i18n(lang) {
window._i18n_tr_ = zh
window._i18n_tr_._lang_ = lang
}
i18n('en')