Package Exports
- chrome-extension-i18n-plugin
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chrome-extension-i18n-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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 |