@rivinia/i18n 0.5.0 → 0.6.0
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/CHANGELOG.md +28 -0
- package/README.md +27 -10
- package/fesm2022/rivinia-i18n.mjs +444 -331
- package/fesm2022/rivinia-i18n.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rivinia-i18n.d.ts +24 -100
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
Pre-1.0 policy: a minor bump may break, a patch is a bug fix.
|
|
4
4
|
|
|
5
|
+
## 0.6.0 (unreleased)
|
|
6
|
+
|
|
7
|
+
The core split (RIV-18) and the pre-release API cleanup. Breaking, as a pre-1.0 minor
|
|
8
|
+
may be: the library never had a released compatibility contract, so the transitional
|
|
9
|
+
names were removed instead of carried to 1.0.
|
|
10
|
+
|
|
11
|
+
- **RIV-18 (internal):** `RiviniaI18n` (915 lines, eight responsibilities) is now a
|
|
12
|
+
facade over five plain collaborators: `MessageFormatter` (ICU render + bounded
|
|
13
|
+
`Intl` memo), `MissingKeyReporter` (dedupe, microtask flush, `missingKeys`),
|
|
14
|
+
`LanguageStorage` (local/session/cookie, persist-after-switch, initial language),
|
|
15
|
+
`DocumentDirectionApplier` (`<html dir/lang>`, view transition) and
|
|
16
|
+
`DictionaryStore` (cache, shared in-flight fetch, generations, TransferState,
|
|
17
|
+
loading counter, fallback slot). None is exported; they take constructor
|
|
18
|
+
arguments instead of DI tokens, and each has direct unit tests.
|
|
19
|
+
- **`rvTranslate` replaces `rTranslate` (breaking):** `RvTranslatePipe` keeps the
|
|
20
|
+
package prefix (`angular.json` already sets `prefix: "rv"`). `RTranslatePipe` and
|
|
21
|
+
the `rTranslate` selector were removed — no alias, no deprecation window.
|
|
22
|
+
- **`languageChanged` removed (breaking):** it was the same signal as
|
|
23
|
+
`currentLanguage`.
|
|
24
|
+
- **`loadTranslations(id, { silent })` → `loadTranslations(id)` (breaking):** the
|
|
25
|
+
option was declared but never read; background loads are internal.
|
|
26
|
+
- **Unbounded map removed:** the `Intl` number/date memo is now a 40-entry LRU, the
|
|
27
|
+
same ceiling as the `formatIcu` caches; the emitted output is unchanged.
|
|
28
|
+
- **`loadedTranslations` is `readonly`:** a public `Signal` was assignable before;
|
|
29
|
+
no consumer can reasonably depend on writing it.
|
|
30
|
+
- **Behaviour:** none intended. The characterization test (`fallback-after-init`)
|
|
31
|
+
and the SSR smoke suite were added before the split and pass unchanged after it.
|
|
32
|
+
|
|
5
33
|
## 0.5.0
|
|
6
34
|
|
|
7
35
|
The 0.4.0 code-review set. 0.4.1 was never published, so its fixes ship here;
|
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
defineRiviniaI18n,
|
|
69
69
|
injectRiviniaI18n,
|
|
70
70
|
RiviniaI18n,
|
|
71
|
-
|
|
71
|
+
RvTranslatePipe,
|
|
72
72
|
jsonLoader,
|
|
73
73
|
httpLoader,
|
|
74
74
|
remoteLoader,
|
|
@@ -87,7 +87,7 @@ exist only so the package's own tests can import them; they may move to an
|
|
|
87
87
|
| ------------------------------------------------------------------------------------- | ---------------- | ------------ |
|
|
88
88
|
| `RiviniaI18n` | service | Stable |
|
|
89
89
|
| `provideRiviniaI18n`, `defineRiviniaI18n`, `injectRiviniaI18n` | providers | Stable |
|
|
90
|
-
| `
|
|
90
|
+
| `RvTranslatePipe` (`rvTranslate`) | pipe | Stable |
|
|
91
91
|
| `RiviniaI18nConfig` | type | Stable |
|
|
92
92
|
| `Language`, `Direction`, `Translation`, `TranslateParams`, `StorageStrategy`, `SwitchStrategy` | types | Stable |
|
|
93
93
|
| `RiviniaLoadError` | class | Stable |
|
|
@@ -102,8 +102,6 @@ exist only so the package's own tests can import them; they may move to an
|
|
|
102
102
|
| `parseCookie`, `serializeCookie` | cookie helpers | Internal |
|
|
103
103
|
| `browserLanguages`, `detectBrowserLanguage` | helpers | Internal |
|
|
104
104
|
|
|
105
|
-
`languageChanged` is deprecated: `currentLanguage` is the same signal.
|
|
106
|
-
|
|
107
105
|
## Quick start
|
|
108
106
|
|
|
109
107
|
```ts
|
|
@@ -133,15 +131,15 @@ export const appConfig: ApplicationConfig = {
|
|
|
133
131
|
```ts
|
|
134
132
|
// src/app/header.ts
|
|
135
133
|
import { Component } from '@angular/core';
|
|
136
|
-
import {
|
|
134
|
+
import { RvTranslatePipe } from '@rivinia/i18n';
|
|
137
135
|
import { i18n } from './i18n.config';
|
|
138
136
|
|
|
139
137
|
@Component({
|
|
140
138
|
selector: 'app-header',
|
|
141
|
-
imports: [
|
|
139
|
+
imports: [RvTranslatePipe],
|
|
142
140
|
template: `
|
|
143
141
|
<h1>{{ title() }}</h1>
|
|
144
|
-
<p>{{ 'booking.seats' |
|
|
142
|
+
<p>{{ 'booking.seats' | rvTranslate: { count: seats } }}</p>
|
|
145
143
|
<button type="button" (click)="use('en')">English</button>
|
|
146
144
|
`,
|
|
147
145
|
})
|
|
@@ -247,7 +245,6 @@ browser; `<base href>` resolved against the request on the server). `isServer` m
|
|
|
247
245
|
| ----------------------- | ----------------------------------- | -------------------------------------------------------------- |
|
|
248
246
|
| `currentLanguage` | `Signal<L>` | Active language id. |
|
|
249
247
|
| `currentLanguageObject` | `Signal<Language<L>>` | The active language entry. |
|
|
250
|
-
| `languageChanged` | `Signal<L>` | **Deprecated** — same signal as `currentLanguage`. |
|
|
251
248
|
| `languages` | `Signal<readonly Language<L>[]>` | Supported languages. |
|
|
252
249
|
| `dir` / `isRtl` | `Signal<Direction>` / `Signal<boolean>` | Document direction. |
|
|
253
250
|
| `locale` | `Signal<string>` | BCP-47 locale driving `Intl` and plural rules. |
|
|
@@ -268,7 +265,7 @@ browser; `<base href>` resolved against the request on the server). `isServer` m
|
|
|
268
265
|
| `t(key, params?)` | `Signal<string>` | Same chain as a `computed`; params may be a function of signals. |
|
|
269
266
|
| `setLanguage(id)` / `setLanguageAsync(id)` | `void` / `Promise<void>` | Follows `switchStrategy`. |
|
|
270
267
|
| `toggle()` / `next()` / `previous()` | `void` | `toggle()` flips the first two languages (dev warning with more); `next()`/`previous()` cycle. |
|
|
271
|
-
| `loadTranslations(id
|
|
268
|
+
| `loadTranslations(id)` | `Promise<Record<…>>` | Preload without switching. |
|
|
272
269
|
| `reload(language?)` | `Promise<boolean>` | Invalidate + refetch; never rejects. |
|
|
273
270
|
| `formatNumber(value, options?)` | `string` | `Intl.NumberFormat` bound to `locale`. |
|
|
274
271
|
| `formatDate(value, options?)` | `string` | `Intl.DateTimeFormat` bound to `locale`. |
|
|
@@ -277,7 +274,7 @@ browser; `<base href>` resolved against the request on the server). `isServer` m
|
|
|
277
274
|
| `clearMissingKeys()` | `void` | Reset the missing-key report. |
|
|
278
275
|
| `clearMissingParams()` | `void` | Reset the missing-parameter dedupe. |
|
|
279
276
|
|
|
280
|
-
`
|
|
277
|
+
`RvTranslatePipe` (`rvTranslate`) delegates to `translate()`. It is impure by necessity —
|
|
281
278
|
the service reads signals on every call — so prefer `t()` or component code for long
|
|
282
279
|
lists.
|
|
283
280
|
|
|
@@ -482,6 +479,26 @@ A complete, runnable host lives in `projects/i18n-e2e` (`node:http` +
|
|
|
482
479
|
`renderApplication`, no Express), with `e2e/ssr-smoke.mjs` asserting the raw HTML, the
|
|
483
480
|
server log, the transfer payload, the absence of a client refetch, and hydration.
|
|
484
481
|
|
|
482
|
+
## Migration: 0.5.0 → 0.6.0
|
|
483
|
+
|
|
484
|
+
0.6.0 is a breaking minor (the pre-1.0 policy allows it). The core split (RIV-18) is
|
|
485
|
+
internal — no signature changed — but three compatibility names are gone:
|
|
486
|
+
|
|
487
|
+
1. **The pipe is `rvTranslate`.** `RTranslatePipe` (`rTranslate`) was removed; the
|
|
488
|
+
package prefix is `rv`, and there is no alias to keep:
|
|
489
|
+
|
|
490
|
+
```html
|
|
491
|
+
<!-- before -->
|
|
492
|
+
{{ 'booking.seats' | rTranslate: { count: seats } }}
|
|
493
|
+
<!-- after -->
|
|
494
|
+
{{ 'booking.seats' | rvTranslate: { count: seats } }}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
2. **`languageChanged` is gone.** It was the same signal as `currentLanguage`; switch
|
|
498
|
+
your reads to `currentLanguage`.
|
|
499
|
+
3. **`loadTranslations(id, { silent })` is now `loadTranslations(id)`.** `silent` never
|
|
500
|
+
did anything — background loads are an internal concern.
|
|
501
|
+
|
|
485
502
|
## Migration: 0.3.3 → 0.4.0
|
|
486
503
|
|
|
487
504
|
Everything below is additive; no export was removed and no import path changed. Two
|