一覧へ戻る
dotcore64/rollup-plugin-i18next-conv(新しいタブで開きます)
主要言語: JavaScript
Import po files with rollup
- star 数
- 5
- watcher 数
- 1
- fork 数
- 1
- issue 数
- 4
- 最終更新
- 2026/10/12
主要言語: JavaScript
Import po files with rollup
Import po files as i18next compatible json objects with rollup
$ npm install --save-dev rollup-plugin-i18next-conv i18next-conv
Note: i18next-conv is a peer dependency.
Given the following source file:
import i18next from 'i18next'; import en from '../../locale/en/LC_MESSAGES/messages.po'; import ja from '../../locale/ja/LC_MESSAGES/messages.po'; i18next.init({ resources: { en: { translation: en }, ja: { translation: ja }, }, });
Compile using:
// rollup.config.js import i18next from 'rollup-plugin-i18next-conv'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', }, format: 'iife', plugins: [ i18next({ // All PO files will be parsed by default, // but you can also specifically include/exclude files include: 'node_modules/**', exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ], // Customize the determineLocale function, which by default is: // const defDetermineLocale = filename => filename.split(path.sep).slice(-3)[0]; // (returns 'en' given a filename './locale/en/LC_MESSAGES/messages.po') determineDomain: filename => path.basename(filename, '.po'), // And any option supported by i18next-conv's gettextToI18next function, for example keyseparator: '$$', }) ] };