Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master , ng13 ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm run test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ npm-debug.log*
.DS_Store

# Compiled files
dist
src/**/*.js
tests/**/*.js
dist

# Extracted strings
strings.json
Expand Down
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ If this tool saves you time, please consider making a donation towards the conti
[![Donate](images/donate-badge.png)](https://donate.biesbjerg.com)

# ngx-translate-extract

Extract translatable (ngx-translate) strings and save as a JSON or Gettext pot file.
Merges with existing strings if the output file already exists.

## Install

Install the package in your project:

`npm install @biesbjerg/ngx-translate-extract --save-dev`

Choose the version corresponding to your Angular version:

| Angular | ngx-translate-extract |
| ------------- | --------------------- |
| 13 (IVY only) | 8.x+ |
| 8.x – 12.x | 7.x |

Add a script to your project's `package.json`:

```json
...
"scripts": {
Expand All @@ -20,6 +30,7 @@ Add a script to your project's `package.json`:
}
...
```

You can now run `npm run i18n:extract` and it will extract strings from your project.

## Usage
Expand All @@ -32,19 +43,20 @@ You can now run `npm run i18n:extract` and it will extract strings from your pro

`ngx-translate-extract --input ./src-a ./src-b --output ./src/assets/i18n/strings.json`


**Extract and save to multiple files using path expansion**

`ngx-translate-extract --input ./src --output ./src/i18n/{da,en}.json`

### JSON indentation

Tabs are used by default for indentation when saving extracted strings in json formats:

If you want to use spaces instead, you can do the following:

`ngx-translate-extract --input ./src --output ./src/i18n/en.json --format-indentation ' '`
`ngx-translate-extract --input ./src --output ./src/i18n/en.json --format-indentation ' '`

### Marker function

If you want to extract strings that are not passed directly to `TranslateService`'s `get()`/`instant()`/`stream()` methods, you can wrap them in a marker function to let `ngx-translate-extract` know you want to extract them.

Install marker function:
Expand All @@ -67,6 +79,7 @@ _('Extract me');
_Note: `ngx-translate-extract` will automatically detect the import name_

### Commandline arguments

```
Usage:
ngx-translate-extract [options]
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /usr/bin/env node

require('../dist/cli/cli');
import('../dist/cli/cli.js');
Loading