@rivinia/i18n 0.3.3 → 0.5.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 +103 -0
- package/README.md +440 -153
- package/cli/rivinia-i18n-keys.mjs +400 -0
- package/fesm2022/rivinia-i18n-http-loader.impl-sLjTazQZ.mjs +20 -0
- package/fesm2022/rivinia-i18n-http-loader.impl-sLjTazQZ.mjs.map +1 -0
- package/fesm2022/rivinia-i18n-remote-loader.impl-DE90KQn_.mjs +19 -0
- package/fesm2022/rivinia-i18n-remote-loader.impl-DE90KQn_.mjs.map +1 -0
- package/fesm2022/rivinia-i18n.mjs +781 -169
- package/fesm2022/rivinia-i18n.mjs.map +1 -1
- package/package.json +26 -2
- package/types/rivinia-i18n.d.ts +327 -53
- package/fesm2022/rivinia-i18n-http-loader.impl-DVlKmSDL.mjs +0 -15
- package/fesm2022/rivinia-i18n-http-loader.impl-DVlKmSDL.mjs.map +0 -1
- package/fesm2022/rivinia-i18n-json-loader.impl-VXwAmyWL.mjs +0 -16
- package/fesm2022/rivinia-i18n-json-loader.impl-VXwAmyWL.mjs.map +0 -1
- package/fesm2022/rivinia-i18n-remote-loader.impl-XKqdLHoJ.mjs +0 -15
- package/fesm2022/rivinia-i18n-remote-loader.impl-XKqdLHoJ.mjs.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @rivinia/i18n
|
|
2
|
+
|
|
3
|
+
Pre-1.0 policy: a minor bump may break, a patch is a bug fix.
|
|
4
|
+
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
The 0.4.0 code-review set. 0.4.1 was never published, so its fixes ship here;
|
|
8
|
+
RIV-18 (the internal split) moves to 0.6.0.
|
|
9
|
+
|
|
10
|
+
- **RIV-01 (fix):** compact ICU templates parse. `one{# item}` (no space
|
|
11
|
+
before `{`) was read as the selector `one{# item`, so translation-tool
|
|
12
|
+
output was returned raw. Plural, select, selectordinal and exact `=N` are
|
|
13
|
+
covered, including the Arabic six forms.
|
|
14
|
+
- **RIV-02 (fix):** an in-flight load shares the FETCH, not the decision to
|
|
15
|
+
apply it. A background fallback load joined by an explicit language switch
|
|
16
|
+
used to finish silently and never reach the UI; the dictionary is now
|
|
17
|
+
applied against the state at resolution time. `loadingState` follows a
|
|
18
|
+
counter of non-background loads, and `onLoadError` fires once per failed
|
|
19
|
+
fetch.
|
|
20
|
+
- **RIV-03 (packaging):** `@angular-devkit/schematics` is an OPTIONAL peer
|
|
21
|
+
(`peerDependenciesMeta`). `ng add` still requires it — the Angular CLI
|
|
22
|
+
provides it — but a plain install no longer warns.
|
|
23
|
+
- **RIV-04 (performance):** the default `jsonLoader` and its URL helper ship in
|
|
24
|
+
the main bundle. The app initializer used to fetch two extra chunks before
|
|
25
|
+
the first dictionary; `httpLoader`/`remoteLoader` stay lazy.
|
|
26
|
+
- **RIV-05 (fix):** `onMissingKey` runs from the deferred missing-key flush,
|
|
27
|
+
not inside `t()`'s computed. A handler that writes a signal no longer
|
|
28
|
+
throws NG0600; once-per-key dedupe and lookup order are unchanged.
|
|
29
|
+
- **RIV-06 (performance):** ICU templates compile once into a cached AST.
|
|
30
|
+
Rendering the same plural 100k times is ~13x faster; output is unchanged.
|
|
31
|
+
- **RIV-07 (feature):** loader failures throw `RiviniaLoadError`
|
|
32
|
+
(`url`, `status`, `language`) with the message
|
|
33
|
+
`[rivinia/i18n] Failed to load 'URL' (HTTP STATUS)`. HTTP/2 leaves
|
|
34
|
+
`statusText` empty, so the numeric status is always present.
|
|
35
|
+
- **RIV-08 (feature, behavior change):** ICU apostrophe quoting. `''` renders
|
|
36
|
+
one apostrophe (it previously rendered two), and `'{'`…`'}'` quotes literal
|
|
37
|
+
braces.
|
|
38
|
+
- **RIV-09 (DX):** missing message arguments are reported via `onMissingParam`
|
|
39
|
+
(once per key/param, from a microtask) with a dev-mode warning controlled by
|
|
40
|
+
`warnOnMissingParam`. Output keeps the placeholder.
|
|
41
|
+
- **RIV-10 (feature):** `date` arguments accept strict ISO-8601 strings.
|
|
42
|
+
Invalid strings still render raw.
|
|
43
|
+
- **RIV-11 (behavior change):** `<html lang>` now uses the language `locale`
|
|
44
|
+
when configured (`ar` + `ar-EG` → `lang="ar-EG"`); without a locale the id is
|
|
45
|
+
used, as before.
|
|
46
|
+
- **RIV-12 (feature):** dictionaries may keep dotted keys flat
|
|
47
|
+
(`{ "app.title": "…" }`). A flat key wins over a nested path on collision, and
|
|
48
|
+
the CLI warns.
|
|
49
|
+
- **RIV-13 (DX):** `toggle()` is documented as a two-language flip and warns in
|
|
50
|
+
dev mode when more than two languages are configured.
|
|
51
|
+
- **RIV-14 (packaging):** `repository`, `homepage`, `bugs`, `author`,
|
|
52
|
+
`engines` (Angular 22's supported Node range), `publishConfig.access`, and
|
|
53
|
+
this changelog are part of the published tarball.
|
|
54
|
+
- **RIV-15 (API):** every export is classified Stable/Experimental/Internal in
|
|
55
|
+
the README; internal helpers carry `@internal`; `languageChanged` is
|
|
56
|
+
deprecated in favour of `currentLanguage`.
|
|
57
|
+
- **RIV-16 (feature):** `rivinia-i18n-keys --parity --dir public/i18n --base en`
|
|
58
|
+
reports missing keys, extra keys and placeholder mismatches (including
|
|
59
|
+
arguments nested in plural/select branches), and exits 1 for CI.
|
|
60
|
+
- **RIV-17 (privacy):** the language is persisted only after an explicit
|
|
61
|
+
switch, never on first load; writes already reflected in storage are skipped.
|
|
62
|
+
`persist: false` disables persistence.
|
|
63
|
+
- **Fix:** switching to a cached language after a failed load left
|
|
64
|
+
`loadingState` at `'error'`; it now returns to `'idle'`.
|
|
65
|
+
|
|
66
|
+
## 0.4.0
|
|
67
|
+
|
|
68
|
+
The production-hardening release. Additive API; two behaviour changes.
|
|
69
|
+
|
|
70
|
+
- **SSR-safe loaders.** `LoaderContext` (`baseUrl`, `isServer`) built from
|
|
71
|
+
`REQUEST` + `<base href>` on the server and `document.baseURI` in the
|
|
72
|
+
browser. The built-in loaders absolutize only on the server, so a custom SSR
|
|
73
|
+
host must provide `REQUEST`.
|
|
74
|
+
- **`fallbackLanguage`.** Lookup is current → fallback → `defaultValue` → key.
|
|
75
|
+
Fallback text renders with the fallback locale's plural rules, loads in
|
|
76
|
+
parallel and silently, and is transferred to the client.
|
|
77
|
+
- **Missing-key reporting.** `onMissingKey(event)`, a `missingKeys` signal and
|
|
78
|
+
`clearMissingKeys()`, once per key per session and only after the current
|
|
79
|
+
language has a dictionary.
|
|
80
|
+
- **`reload(language?)`.** Stale-while-revalidate with per-language
|
|
81
|
+
generations; a response in flight when `reload()` runs is discarded.
|
|
82
|
+
- **ICU additions.** `selectordinal`, `offset:`, `{n, number}` with
|
|
83
|
+
`percent`/`integer`/`::currency/XXX`, `{d, date}` with
|
|
84
|
+
`short|medium|long|full`, and `Date` in `TranslateParams`.
|
|
85
|
+
- **`t(key, params?)` returns `Signal<string>`.** Function params are tracked.
|
|
86
|
+
- **Typed keys.** Augmentable `RiviniaI18nKeyRegistry`; the
|
|
87
|
+
`rivinia-i18n-keys` CLI generates it, with `--check` for CI.
|
|
88
|
+
|
|
89
|
+
Behaviour changes: `#` inside a plural uses the locale's digits
|
|
90
|
+
(`ar-EG`: `٣`), and an unresolved key warns once per session in dev mode.
|
|
91
|
+
|
|
92
|
+
## 0.3.0
|
|
93
|
+
|
|
94
|
+
- **Breaking:** the default `jsonLoader()` path is `i18n` (files in
|
|
95
|
+
`public/i18n/`), not `assets/i18n`. Pin the old layout with
|
|
96
|
+
`jsonLoader({ path: 'assets/i18n' })`.
|
|
97
|
+
- The language cookie gets `Secure` automatically on `https:` (never on
|
|
98
|
+
`localhost`); the server never sets cookies.
|
|
99
|
+
|
|
100
|
+
## 0.2.0
|
|
101
|
+
|
|
102
|
+
- ICU select/plural, locale-aware number and date formatting, browser language
|
|
103
|
+
detection, RTL direction, and the `rTranslate` pipe.
|