i18next-conv - gettext support for i18next

i18next-conv converts files from gettext (.mo/.po) to i18next's json format and vice versa.

All credits go to:

  1. andri9's node-gettextfor .mo and .po files parser
  2. TJ Holowaychuk's commander.jsfor console program

node.js:

npm install i18next-conv -g

using i18next-node backend instead:
more information

Setup

Setup

1. install node.js from nodejs.org

2. npm install i18next-conv -g

To use the program you should install the npm package globally (with -g flag).

If you get encounter any accessright errors try install with admin-rights (sudo).

Usage

convert gettext to i18next JSON

in your console type:
for help:
i18next-conv -h
to convert a .mo or .po file to json:
i18next-conv -l [domain] -s [sourcePath] -t [targetPath]
 
quiet mode
: i18next-conv -l [domain] -s [sourcePath] -t [targetPath] --quiet
 
eg
.: i18next-conv -l en -s ./locales/en.po -t ./locales/en/translation.json

if no target (-t) is specified, the file will be stored next to the source directory: [sourceDir]/[domain]/translation.json.

convert i18next JSON to gettext files

in your console type:
for help:
i18next-conv -h
to convert a json to .mo or .po file:
i18next-conv -l [domain] -s [sourcePath] -t [targetPath]
 
quiet mode
: i18next-conv -l [domain] -s [sourcePath] -t [targetPath] --quiet
 
eg
. for .mo file:
i18next
-conv -l en -s ./locales/en/translation.json -t ./locales/en/translation.mo
 
eg
. for .po file:
i18next
-conv -l en -s ./locales/en/translation.json -t ./locales/en/translation.po

if no target (-t) is specified, the file will be stored next to the source directory in .po format: [sourceDir]/[domain]/translation.po.