# @opi_pib/node-translate

> Translation tools

Latest version **2.2.3** (published 2025-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install @opi_pib/node-translate
pnpm add @opi_pib/node-translate
yarn add @opi_pib/node-translate
bun add @opi_pib/node-translate
```

Provides the command `translate`.

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.3 |
| Published | 2025-11-27 |
| First published | 2022-09-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=24.0.0 |
| Dependencies | 6 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Dawid Lubowiecki |
| Maintainers | national-information-processing-institute-opi-pib, dlubowiecki, mpaduszynski |
| Keywords | node translation tools, node translation helpers |

## Links

- npm: https://www.npmjs.com/package/@opi_pib/node-translate
- Repository: https://github.com/OPI-PIB/node-translate
- Homepage: https://github.com/OPI-PIB/node-translate#readme
- Issues: https://github.com/OPI-PIB/node-translate/issues
- npm.io page: https://npm.io/package/@opi_pib/node-translate

## Dependencies (6)

- [ramda](https://npm.io/package/ramda.md) ^0.32.0
- [yargs](https://npm.io/package/yargs.md) ^18.0.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.0.0
- [fast-glob](https://npm.io/package/fast-glob.md) ^3.0.0
- [@opi_pib/ts-utility](https://npm.io/package/@opi_pib/ts-utility.md) ^2.0.0
- [@opi_pib/node-utility](https://npm.io/package/@opi_pib/node-utility.md) ^3.0.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 2.2.3 (latest) — 2025-11-27
- 2.2.2 — 2025-11-27
- 2.2.1 — 2025-06-24
- 2.2.0 — 2025-06-24
- 2.1.0 — 2024-11-29
- 2.0.0 — 2024-09-25
- 1.3.0 — 2024-06-24
- 1.2.7 — 2024-02-26
- 1.2.6 — 2023-11-14
- 1.2.5 — 2023-10-20
- 1.2.4 — 2023-10-19
- 1.2.3 — 2023-10-18
- 1.2.2 — 2023-10-18
- 1.2.1 — 2023-05-16
- 1.2.0 — 2023-04-12
- … 12 more at https://npm.io/package/@opi_pib/node-translate/versions

## README

# @opi_pib/node-translate

Helper tool for generating translation files that works with ngx-translate

-   [Install](#install)
-   [Generate translations](#generate-translations)
-   [Define translation keys](#define-translation-keys)
-   [Default config](#default-config)

## Install

```
npm install @opi_pib/node-translate
```

## Generate translations

Find all translation keys in 'app' and 'domain' folders and generate translation files

```console
translate build --source=\"./src/{app,domain}/**/*+(.ts|.html)\" --langs=pl --langs=en
```

## Define translation keys

### in TypeScript

Every translation key needs to match RegExp which means also that it needs to be used inside of methods translate\$ or instant

```
/[\s\t\[\(\{\.](?:t|translate\$|instant)\(:?\'\w+(:?.\w+)*/
```

If translate\$ or instant methods can't be used, wrap translation key in translation marker 't'

```typescript
const a = t("A.B.C");
```

### in HTML

Every translation key needs to match RegExp which means also that it needs to be passed through 'translate' pipe

```
/\'\w+(?:\.\w+)*\'\s(?:\|\s.+)*?\|\stranslate/
```

#### Example

```html
<div [value]="'J' | async | name | translate"></div>
<div value="{{ 'J.J' | getName: {a: '1'} | translate }}"></div>
<div value="{{ 'J.J.J' | translate: {name: 'Jan'} }}"></div>
```

## Default config

```json
{
	"source": "./src/app/**/*+(.ts|.html)",
	"dist": "./src/translations",
	"i18n": "./src/assets/i18n",
	"langs": ["pl"],
	"reportDuplicates": true
}
```

---
_Source: https://npm.io/package/@opi_pib/node-translate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
