Skip to content

Commit

Permalink
docs(readme): update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomej committed Sep 20, 2022
1 parent bda0524 commit 42476e1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

48 changes: 36 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
If this tool saves you time, please consider making a donation towards the continued maintainence and development: https://donate.biesbjerg.com
This is a fork of a great library by Biesbjerg.
(But the original Beisbjerg's library is unfortunately no longer being developed)

[![Donate](images/donate-badge.png)](https://donate.biesbjerg.com)
This library adds compatibility for **Angular 13** and **Angular 14**...

# ngx-translate-extract

> Angular translations extractor (plugin for [@ngx-translate](https://github.com/ngx-translate/core))
> _Angular 14, Ivy and Angular Universal (SSR) compatible_
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 @bartholomej/ngx-translate-extract --save-dev`
```bash
npm install @bartholomej/ngx-translate-extract --save-dev
# yarn add @bartholomej/ngx-translate-extract --dev
```

Choose the version corresponding to your Angular version:

| Angular | ngx-translate-extract |
| ------------- | --------------------- |
| 13 (IVY only) | 8.x+ |
| 8.x – 12.x | 7.x |
| Angular | ngx-translate-extract |
| ---------- | ------------------------------------------------------------------------------------------ |
| 14 | 8.x+ |
| 13 | 8.x+ |
| 8.x – 12.x | [@biesbjerg/ngx-translate-extract](https://github.com/biesbjerg/ngx-translate-extract) 7.x |

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

Expand All @@ -37,30 +46,41 @@ You can now run `npm run i18n:extract` and it will extract strings from your pro

**Extract from dir and save to file**

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

**Extract from multiple dirs**

`ngx-translate-extract --input ./src-a ./src-b --output ./src/assets/i18n/strings.json`
```bash
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`
```bash
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 ' '`
```bash
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:
`npm install @biesbjerg/ngx-translate-extract-marker`

```bash
npm install @biesbjerg/ngx-translate-extract-marker
```

```ts
import { marker } from '@biesbjerg/ngx-translate-extract-marker';
Expand Down Expand Up @@ -119,3 +139,7 @@ Examples:
## Note for GetText users

Please pay attention of which version of `gettext-parser` you actually use in your project. For instance, `gettext-parser:1.2.2` does not support HTML tags in translation keys.

## Credits

- Original library, idea and code: [@biesbjerg/ngx-translate-extract](https://github.com/biesbjerg/ngx-translate-extract) ❤️
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@biesbjerg/ngx-translate-extract",
"name": "@bartholomej/ngx-translate-extract",
"version": "8.0.2",
"description": "Extract strings from projects using ngx-translate",
"main": "dist/index.js",
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/biesbjerg/ngx-translate-extract.git"
"url": "https://github.com/bartholomej/ngx-translate-extract.git"
},
"keywords": [
"angular",
Expand All @@ -54,9 +54,9 @@
"author": "Kim Biesbjerg <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/biesbjerg/ngx-translate-extract/issues"
"url": "https://github.com/bartholomej/ngx-translate-extract/issues"
},
"homepage": "https://github.com/biesbjerg/ngx-translate-extract",
"homepage": "https://github.com/bartholomej/ngx-translate-extract",
"engines": {
"node": ">=12"
},
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PurgeObsoleteKeysPostProcessor } from '../post-processors/purge-obsolet
import { CompilerInterface } from '../compilers/compiler.interface.js';
import { CompilerFactory } from '../compilers/compiler.factory.js';
import { normalizePaths } from '../utils/fs-helpers.js';
import { donateMessage } from '../utils/donate.js';
// import { donateMessage } from '../utils/donate.js';

// First parsing pass to be able to access pattern argument for use input/output arguments
const y = yargs().option('patterns', {
Expand Down Expand Up @@ -154,7 +154,7 @@ extractTask.setCompiler(compiler);
try {
extractTask.execute();
console.log(green('\nDone.\n'));
console.log(donateMessage);
// console.log(donateMessage);
process.exit(0);
} catch (e) {
console.log(red(`\nAn error occurred: ${e}\n`));
Expand Down

0 comments on commit 42476e1

Please sign in to comment.