1.2.0 • Published 3 years ago

@cosmic-plus/i18n-extractor v1.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

@cosmic-plus/i18n-extractor

Licence Dependencies Vulnerabilities Size Downloads

Command-line interface that extract internationalized strings for translators. It is exclusively developed for @cosmic-plus/i18n.

Install

Locally

  • NPM: npm install --save-dev @cosmic-plus/i18n-extractor
  • Yarn: yarn add --dev @cosmic-plus/i18n-extractor

Globally

  • NPM: npm install -g @cosmic-plus/i18n-extractor
  • Yarn: yarn global add @cosmic-plus/i18n-extractor

Usage

i18n-extractor LANGUAGES|'all' SOURCE_DIR...

If LANGUAGES is provided, update/create translation files for LANGUAGES with internationalized strings extracted from SOURCE_DIR. If LANGUAGES is not provided, update any already existing translation files. LANGUAGES must be a comma-separated list of languages, such as cn,es,pt.

When no SOURCE_DIR is provided, uses ${project_root}/src. Translation files are created at ${project_root}/locales/${language}.json.

Add a new translation

i18n-extractor ${language} src

Update existing translations

i18n-extractor all src

Add as a script into your package.json

Add the following into your package scripts:

"scripts": {
  "i18n": "i18n-extractor all ./src"
}

You can now update translations files using:

npm run i18n