chrome-extension-i18n-plugin
v0.0.2
Published
a webpack plugin for chrome extension i18n
Downloads
4
Maintainers
Readme
Chrome Extension i18n plugin
a webpack plugin that simplifies Chrome Extension i18n.
Install
npm i --save-dev chrome-extension-i18n-plugin
yarn add --dev chrome-extension-i18n-plugin
Usage
const path = require('path');
const webpack = require('webpack');
const chromeExtensionI18nPlugin = require('chrome-extension-i18n-plugin');
const config = {
entry: path.resolve(__dirname, './index.js'),
output: {
path: path.join(__dirname, '.'),
filename: 'bundle.js'
},
mode: 'development',
module: {
},
plugins: [
new chromeExtensionI18nPlugin({
i18ns: ['en', 'zh_CN'],
file: './i18n.json'
})
]
};
module.exports = config;
// i18n.json
{
"desc": {
"zh_CN": "中文描述",
"en": "english description"
},
"aaa": {
"zh_CN": "aaa 文案",
"en": "aaa text"
}
}
The following file structure will generated:
|- _locales
|- en
| messages.json
|- zh_CN
| messages.json
// en/messages.json
{
"desc": {
"message": "english description"
},
"aaa": {
"message": "aaa text"
}
}
// zh_CN/messages.json
{
"desc": {
"message": "中文描述"
},
"aaa": {
"message": "aaa 文案"
}
}
These structures adhere strictly to Chrome official doc.
Options
| Name | Type | Default | Description |
| ---- | ---- | ------- | --------- |
| file | {String} | ''
| i18n file path |
| i18ns | {Array} | []
| Chrome Extension support locale lang, check here |
| spaceNum | {Number} | 4 | json generated format |