next-i18n-keys

1.0.2 • Public • Published

Welcome to next-i18n-keys 👋

Version Documentation License: MIT

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

🤝 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.

Readme

Keywords

none

Package Sidebar

Install

npm i next-i18n-keys

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

6.09 kB

Total Files

4

Last publish

Collaborators

  • lovesora