andola-i18n-generator
v1.0.7
Published
i18n translation generator with automatic unwrapping support and error recovery.
Readme
i18n Generator
i18n translation generator with automatic unwrapping support and error recovery.
Installation
npm install --save-dev andola-i18n-generatorUsage
Basic usage (generates with metadata)
i18n-generator --source en.json --target generatedLanguages/or.json --lang orWith automatic unwrap (for React apps)
i18n-generator --source public/locales/en/translation.json --target i18n/generated/or.json --lang or --unwrap public/locales/or/translation.jsonIn package.json (single language)
{
"scripts": {
"translate:or": "i18n-generator --source public/locales/en/translation.json --target i18n/generated/or.json --lang or --unwrap public/locales/or/translation.json",
"translate:hi": "i18n-generator --source public/locales/en/translation.json --target i18n/generated/hi.json --lang hi --unwrap public/locales/hi/translation.json"
}
}In package.json (dynamic language - pass language as argument)
{
"scripts": {
"translate": "bash -c 'LANG=${1:-or}; i18n-generator --source public/locales/en/translation.json --target i18n/generated/$LANG.json --lang $LANG --unwrap public/locales/$LANG/translation.json' bash"
}
}Then run with any language code:
npm run translate or
npm run translate hi
npm run translate esFeatures
✅ Automatic unwrapping - Generates both metadata version (for resuming) and clean version (for React)
✅ Error recovery - Saves partial translations on rate limit errors
✅ Resume capability - Continue from where it stopped when re-run
✅ Incremental updates - Only translates new or missing keys
Parameters
--source: Path to source English JSON file (required)--target: Path to save generated translation with metadata (required)--lang: Target language code - e.g.,or,hi,es,fr,de(required)--unwrap: Path to save unwrapped plain translation for React/i18next (optional)
How It Works
- Generates with metadata: Creates a file with
{ value: "translation", is_generated: true }structure - Saves incrementally: After each successful translation, saves progress to file
- Handles errors: On rate limit or network errors, keeps partial data
- Auto unwraps: If
--unwrapis provided, creates a clean JSON file ready for React - Resumes work: Re-running continues from where it left off
Error Handling
When rate limited or network errors occur:
- ✅ Partial translations are saved to the target file
- ✅ Unwrapped version is created from partial data
- 💡 Wait a few minutes and re-run to continue
For Publishing to NPM
Before publishing new update:
- Update
"version": "1.0.7"in package.json - Run:
npm publish
