README.md
July 29, 2026 · View on GitHub
ngx-i18n-extract-regex-cli
Extract Transloco and ngx-translate keys from Angular templates and TypeScript files.
Installation
Node.js 22.12 or newer is required to run the published CLI.
Install the CLI globally:
npm install --global ngx-i18n-extract-regex-cli
You can also run it without a global installation:
npx ngx-i18n-extract-regex-cli --help
Usage
From the root of an Angular project, run:
ngx-i18n-extract-regex-cli extract --library transloco
By default, the CLI:
- scans
src/app/**/*.tsandsrc/app/**/*.html; - reads language files matching
src/assets/i18n/*.json; - retains values for translation keys that already exist;
- adds missing values as
███; and - removes unused keys and writes the remaining keys in alphabetical order.
Use --dry-run to inspect the number of discovered keys without changing language files:
ngx-i18n-extract-regex-cli extract --library ngx-translate --dry-run
Custom paths
Paths are resolved relative to --cwd. Quote glob patterns so that the CLI, rather than your shell, expands them.
ngx-i18n-extract-regex-cli extract \
--library transloco \
--cwd projects/example/src \
--source 'app/**/*.ts' 'app/**/*.html' \
--langs 'assets/i18n/*.json' \
--default-value 'TODO'
Supported expressions
The extractor recognizes common static string usages, including:
{{ 'home.title' | transloco }} {{ 'home.title' | translate }}
transloco.translate('home.title');
translate.instant('home.title');
_('home.title');
Dynamic keys cannot be discovered reliably and should be added to your language files by another mechanism.
Options
| Option | Values | Default | Description |
|---|---|---|---|
--library | transloco, ngx-translate | transloco | Select the i18n library syntax to scan for. |
--cwd | path | src | Set the base directory for source and language globs. |
--source | one or more globs | app/**/*.ts app/**/*.html | Select source files to scan. |
--langs | one or more globs | assets/i18n/*.json | Select language JSON files to update. |
--default-value | string | ███ | Set the value assigned to newly discovered keys. |
--dry-run | flag | disabled | Scan without writing language files. |
--encoding | Node.js buffer encoding | utf-8 | Set the source and output file encoding. |
Run ngx-i18n-extract-regex-cli extract --help for the complete command help.
Development
Development uses the Node.js version declared in .nvmrc and the Bun version declared in package.json:
nvm install
nvm use
bun install
bun run lint
bun run build
bun run test:coverage
See CONTRIBUTING.md for contribution guidelines.
License
Copyright © 2024–2026 Dominik Hladík
Licensed under the MIT License.