1.0.2 ā¢ Published 6 years ago
next-i18n-keys v1.0.2
Auto generate next.js page's i18n keys
š Homepage
Install
yarn install
Configuration
// next.config.js
const NextI18nKeysWebpackPlugin = require('next-i18n-keys');
// ...
config.plugins.push(
// ...
new NextI18nKeysWebpackPlugin({
// RegExp of placeholder in source file
matchReg: /'\^__I18N_KEYS__\$'/,
funcList: ['i18next.t', 'i18n.t'],
}),
// ...
);
// ...
// pages/*.js
Page.getInitialProps = async () => {
// a object of i18n data
const data = await fetch('https://...');
// placeholder of keys, will be replaced by plugin
const keys = '^__I18N_KEYS__$';
const i18n = keys.reduce((obj, key) => (obj[key] = data[key], obj), {});
return {
i18n,
};
}
Author
š¤ Sora Liu 475212506@qq.com
- Github: @lovesora
š¤ Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page.
Show your support
Give a āļø if this project helped you!
š License
Copyright Ā© 2019 Sora Liu <475212506@qq.com>. This project is MIT licensed.