Skip to content
An i18n string extractor CLI for @cosmic-plus/i18n
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE
.eslintrc.json
.gitignore
.npmignore
AUTHORS
LICENSE
README.md
extractor.js
package.json

README.md

@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
You can’t perform that action at this time.