@ng-linguo/linguo 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,16 +99,34 @@ zero RxJS plumbing in your components.
|
|
|
99
99
|
|
|
100
100
|
## Install
|
|
101
101
|
|
|
102
|
+
ng-linguo is two packages that do two different jobs at two different times — so
|
|
103
|
+
you install both, once.
|
|
104
|
+
|
|
105
|
+
**The runtime** — what your app imports and ships to the browser:
|
|
106
|
+
|
|
102
107
|
```bash
|
|
103
108
|
npm i @ng-linguo/linguo @ngrx/signals
|
|
104
109
|
```
|
|
105
110
|
|
|
106
111
|
Requires **Angular 18+**. `@ngrx/signals` is a peer dependency — bring your own.
|
|
107
112
|
|
|
113
|
+
**The CLI** (`@ng-linguo/extract`) — the build-time tool that scans your source
|
|
114
|
+
and produces the translation files the runtime loads. It's pure Node with zero
|
|
115
|
+
Angular dependencies, so it installs as a dev dependency and never reaches the
|
|
116
|
+
browser:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npm i -D @ng-linguo/extract
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Its bin is `linguo-extract`; you run it with `npx linguo-extract …` (or from an
|
|
123
|
+
npm script). Neither package depends on the other, so each stays minimal — the
|
|
124
|
+
runtime renders translations in your app, the CLI generates them in your build.
|
|
125
|
+
|
|
108
126
|
## Getting started
|
|
109
127
|
|
|
110
128
|
The fastest path from an empty Angular app to a translated one. Steps 1–3 get
|
|
111
|
-
the runtime working; step 4
|
|
129
|
+
the runtime working; step 4 uses the CLI to generate the real translation files.
|
|
112
130
|
|
|
113
131
|
### 1. Configure the runtime
|
|
114
132
|
|
|
@@ -231,10 +249,11 @@ The strings above are also your source catalog. Use the
|
|
|
231
249
|
JSON your loader serves:
|
|
232
250
|
|
|
233
251
|
```bash
|
|
234
|
-
|
|
235
|
-
linguo-extract
|
|
236
|
-
linguo-extract
|
|
237
|
-
linguo-extract
|
|
252
|
+
npm i -D @ng-linguo/extract # one-time: install the CLI
|
|
253
|
+
npx linguo-extract init --locales en,pl,de # create linguo.config.json
|
|
254
|
+
npx linguo-extract extract # scan source → en/pl/de .po catalogs
|
|
255
|
+
npx linguo-extract translate --all # fill missing entries with AI (optional)
|
|
256
|
+
npx linguo-extract compile # .po → runtime JSON
|
|
238
257
|
```
|
|
239
258
|
|
|
240
259
|
That's the whole loop. See [Translation workflow](#translation-workflow) for the
|
|
@@ -275,13 +294,15 @@ they can render.
|
|
|
275
294
|
`@ng-linguo/extract` is a pure-Node CLI (no Angular dependency, so it never
|
|
276
295
|
drags the framework into your tooling) that turns your source into translation
|
|
277
296
|
files and back. It reads a `linguo.config.json` — auto-discovered — listing your
|
|
278
|
-
locales and paths.
|
|
297
|
+
locales and paths. Install it once as a dev dependency; its bin is
|
|
298
|
+
`linguo-extract`, so you invoke it with `npx` (or from an npm script):
|
|
279
299
|
|
|
280
300
|
```bash
|
|
281
|
-
linguo
|
|
282
|
-
linguo-extract
|
|
283
|
-
linguo-extract
|
|
284
|
-
linguo-extract
|
|
301
|
+
npm i -D @ng-linguo/extract # install once; the bin is `linguo-extract`
|
|
302
|
+
npx linguo-extract init # create/edit linguo.config.json
|
|
303
|
+
npx linguo-extract extract # scan source → <locale>.po catalogs (additive)
|
|
304
|
+
npx linguo-extract translate # fill missing entries with AI (needs a translator)
|
|
305
|
+
npx linguo-extract compile # .po catalogs → runtime <locale>.json
|
|
285
306
|
```
|
|
286
307
|
|
|
287
308
|
### The interactive menu
|
|
@@ -314,11 +335,11 @@ their source text plus `context`. Re-running it is safe and idempotent.
|
|
|
314
335
|
Adding a locale is a couple of steps — or a couple of clicks in the menu:
|
|
315
336
|
|
|
316
337
|
```bash
|
|
317
|
-
linguo-extract init --locales en,pl,de,fr # add `fr` to the config
|
|
318
|
-
linguo-extract extract
|
|
319
|
-
linguo-extract translate --locale fr
|
|
320
|
-
# …or: linguo-extract copyprompt fr
|
|
321
|
-
linguo-extract compile
|
|
338
|
+
npx linguo-extract init --locales en,pl,de,fr # add `fr` to the config
|
|
339
|
+
npx linguo-extract extract # seeds fr.po with the source strings
|
|
340
|
+
npx linguo-extract translate --locale fr # fill it in with AI…
|
|
341
|
+
# …or: npx linguo-extract copyprompt fr # …or copy a prompt for any chat model
|
|
342
|
+
npx linguo-extract compile # produce fr.json
|
|
322
343
|
```
|
|
323
344
|
|
|
324
345
|
### Translating with AI
|
|
@@ -328,8 +349,8 @@ has all the context it needs. ng-linguo writes a self-contained prompt that
|
|
|
328
349
|
teaches the model your `context` notes, slot tags, and plural rules, and only
|
|
329
350
|
ever sends entries that are still missing. Two ways to run it:
|
|
330
351
|
|
|
331
|
-
- **Clipboard (no key, no config):** `linguo-extract copyprompt pl` copies
|
|
332
|
-
prompt; paste it into any chat model and save the reply over `pl.po`.
|
|
352
|
+
- **Clipboard (no key, no config):** `npx linguo-extract copyprompt pl` copies
|
|
353
|
+
the prompt; paste it into any chat model and save the reply over `pl.po`.
|
|
333
354
|
- **Automatic:** point the `translator` config field at a small module that
|
|
334
355
|
calls your AI provider. ng-linguo builds the prompt and merges the reply; your
|
|
335
356
|
SDK and API key stay yours. See the
|
|
@@ -342,12 +363,12 @@ Every command runs non-interactively and deterministically, so the pipeline
|
|
|
342
363
|
drops into CI as-is:
|
|
343
364
|
|
|
344
365
|
```bash
|
|
345
|
-
linguo-extract extract
|
|
346
|
-
linguo-extract translate --all # optional: fill any gaps (needs a translator)
|
|
347
|
-
linguo-extract compile
|
|
366
|
+
npx linguo-extract extract # fails the build if it errors; idempotent otherwise
|
|
367
|
+
npx linguo-extract translate --all # optional: fill any gaps (needs a translator)
|
|
368
|
+
npx linguo-extract compile
|
|
348
369
|
```
|
|
349
370
|
|
|
350
|
-
`init` is scriptable too: `linguo-extract init --locales en,pl,de --out public/i18n`.
|
|
371
|
+
`init` is scriptable too: `npx linguo-extract init --locales en,pl,de --out public/i18n`.
|
|
351
372
|
|
|
352
373
|
## Configuration
|
|
353
374
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-linguo/linguo",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "A modern, signal-first i18n runtime for Angular 18+ — built on SignalStore, with a translator-safe slot syntax, ICU, and tree-shakeable HTTP loading.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "jmwierzbicki",
|