@rivinia/i18n 0.6.0 → 0.7.2
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 +129 -1
- package/README.md +829 -118
- package/cli/rivinia-i18n-keys.mjs +402 -2
- package/fesm2022/rivinia-i18n-ui.mjs +366 -0
- package/fesm2022/rivinia-i18n-ui.mjs.map +1 -0
- package/fesm2022/rivinia-i18n.mjs +37 -9
- package/fesm2022/rivinia-i18n.mjs.map +1 -1
- package/package.json +5 -1
- package/types/rivinia-i18n-ui.d.ts +112 -0
- package/types/rivinia-i18n.d.ts +66 -11
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,135 @@
|
|
|
2
2
|
|
|
3
3
|
Pre-1.0 policy: a minor bump may break, a patch is a bug fix.
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.7.2 - 2026-10-30
|
|
6
|
+
|
|
7
|
+
- **Fixed: a view-transition switch kept the previous dictionary.** With
|
|
8
|
+
`viewTransition.enabled`, `applyLanguage()` started the dictionary load
|
|
9
|
+
before the transition callback changed `currentLanguage`. A cached
|
|
10
|
+
dictionary applies synchronously, and `DictionaryStore._apply()` publishes
|
|
11
|
+
only the dictionary whose language is current — so the new dictionary was
|
|
12
|
+
discarded and the UI stayed in the old language. The first switch worked
|
|
13
|
+
when `skipInitialTransition` ran it synchronously; every later switch did
|
|
14
|
+
not. The load and `ensureFallback()` now run inside the transition callback,
|
|
15
|
+
after `_currentLanguageId.set(id)`.
|
|
16
|
+
- Two regression tests hold the transition callback and switch twice — one
|
|
17
|
+
through `setLanguage()`, one through the preload-first `setLanguageAsync()`
|
|
18
|
+
path (`projects/i18n/tests/view-transition-switch.spec.ts`); both fail on
|
|
19
|
+
the pre-fix code. The packed build was
|
|
20
|
+
also exercised in the `rv-tailwind` demo with `viewTransition` enabled:
|
|
21
|
+
`ar → en → ar → en → ar → en`, with the heading, `<html lang>` and persisted
|
|
22
|
+
language correct on every step and no console errors. No API change.
|
|
23
|
+
|
|
24
|
+
## 0.7.1 - 2026-10-29
|
|
25
|
+
|
|
26
|
+
0.7.0 was never published; this release ships it unchanged and adds one option and one
|
|
27
|
+
documentation fix.
|
|
28
|
+
|
|
29
|
+
- **New `warnOnLoadError` option.** A dictionary that fails to load leaves every key
|
|
30
|
+
unresolved, so the page renders raw key names — until now in complete silence unless the
|
|
31
|
+
consumer configured `onLoadError`. The default now logs a `console.error` **once per
|
|
32
|
+
language per session** in dev mode (`isDevMode() && !onLoadError`), matching
|
|
33
|
+
`warnOnMissingKey`/`warnOnMissingParam`; `false` silences it, `true` keeps it in
|
|
34
|
+
production. A consumer `onLoadError` keeps owning reporting and still fires on every
|
|
35
|
+
failure (the warning is deduped, the handler is not). Additive — no signature changed.
|
|
36
|
+
- **Fixed:** the `provideRiviniaI18n` JSDoc example that hoisted `const AR`/`const EN` did
|
|
37
|
+
not type-check — without an annotation the literals widen to `string` and fail the
|
|
38
|
+
`Language` check. The example now uses `as const`, the form the package's own tests use.
|
|
39
|
+
Documentation only.
|
|
40
|
+
- **`defaultLanguage` is now optional.** Omitted, it resolves to the first entry of
|
|
41
|
+
`languages`, so the common config only lists the languages. An explicitly provided value
|
|
42
|
+
must be a non-empty id present in `languages`: `''`, whitespace, `null`, a non-string or
|
|
43
|
+
an unknown id now throws at construction with a named message instead of letting
|
|
44
|
+
`undefined` become the current language. Additive — existing configs that pass a valid
|
|
45
|
+
id behave exactly as before.
|
|
46
|
+
- **Duplicate or empty language ids now throw.** `languages` is validated once at
|
|
47
|
+
construction: the same id twice (`[AR, EN, AR]`) or an entry without a non-empty `id`
|
|
48
|
+
fails with a `[rivinia/i18n] …` error. Until now a duplicate passed silently and then
|
|
49
|
+
broke `find`, `next()`/`previous()` and every lookup by id, because only the first
|
|
50
|
+
matching entry is reachable.
|
|
51
|
+
- **New `init` command: languages are collected once, not typed as objects.**
|
|
52
|
+
`npx rivinia-i18n-keys init` asks for each language (id, native name, direction), asks
|
|
53
|
+
which one is the default, then writes `src/app/i18n/languages.ts` (a
|
|
54
|
+
`defineRiviniaI18n` module that also exports a typed `injectI18n`) and an empty
|
|
55
|
+
`public/i18n/<id>.json` per language. Ids, directions and duplicates are validated
|
|
56
|
+
before anything is written, existing dictionaries are kept, and a hand-written
|
|
57
|
+
`languages.ts` is never replaced without `--force`.
|
|
58
|
+
`--languages ar:العربية:rtl,en:English:ltr` runs the same thing non-interactively.
|
|
59
|
+
Additive: the binary keeps its key-generation and parity flags.
|
|
60
|
+
- **A duplicate id in an inline `languages` list is now a compile error too.**
|
|
61
|
+
`provideRiviniaI18n` / `defineRiviniaI18n` gained a conditional type parameter that scans
|
|
62
|
+
the literal tuple and demands a `duplicateLanguageId` property, so the same mistake is
|
|
63
|
+
caught while typing instead of at bootstrap. The scan needs the array literal: an
|
|
64
|
+
explicit `<L>` union or a hoisted list still compiles and is caught by the runtime check.
|
|
65
|
+
Call sites that already compiled are unaffected — the extra parameter is `const` and
|
|
66
|
+
defaulted, so inference is unchanged.
|
|
67
|
+
- **The README is organized in three levels.** _Start here_ (install, generate the list,
|
|
68
|
+
first translation), _Everyday use_ (translating, plurals, switching, dictionaries,
|
|
69
|
+
toggle, SSR) and _Reference_ (every option, loader, ICU rule, UI input, export tier and
|
|
70
|
+
migration). The new part teaches ICU pluralization from a wrong `count === 1` check
|
|
71
|
+
through the six Arabic categories and the difference between `=0` and `zero`; no
|
|
72
|
+
previous detail was dropped. Documentation only.
|
|
73
|
+
|
|
74
|
+
## 0.7.0 - 2026-10-29
|
|
75
|
+
|
|
76
|
+
The first UI in the package: a two-language toggle from the secondary entry point
|
|
77
|
+
`@rivinia/i18n/ui`. Additive — no core signature changed, so nothing is breaking this
|
|
78
|
+
time.
|
|
79
|
+
|
|
80
|
+
- **`@rivinia/i18n/ui` entry point.** Own FESM and types chunk, exported as
|
|
81
|
+
`exports["./ui"]`. No new peer dependencies: the UI imports `@angular/core` at
|
|
82
|
+
runtime and core **types only** (`import type { Direction }`) from `@rivinia/i18n`.
|
|
83
|
+
- **`RiviniaLanguageToggle` (`rv-language-toggle`).** One inner `<button>` that
|
|
84
|
+
switches to the other of exactly two languages. The button — not the host and not
|
|
85
|
+
`<html>` — carries the target's `lang` and `dir` (`dir="auto"` when the entry omits
|
|
86
|
+
it), so the accessible name is pronounced and laid out in the destination language.
|
|
87
|
+
Managed (`[manager]`, structurally satisfied by `RiviniaI18n`) or presentational
|
|
88
|
+
(`[languages]` + `[current]` + `[busy]`); a manager wins over the presentational
|
|
89
|
+
inputs.
|
|
90
|
+
- **`RiviniaLanguageTrigger` (`rvLanguageTrigger`).** An `<ng-template>` rendered
|
|
91
|
+
inside the button in place of the default name span, receiving
|
|
92
|
+
`{ $implicit, busy }`. Rendered through the view container, so `@angular/common` is
|
|
93
|
+
not a peer and `<ng-content>` is never used.
|
|
94
|
+
- **`RiviniaLanguageManager`, `LanguageLike`.** The four-member structural contract
|
|
95
|
+
the toggle drives, and the language entry it renders (`dir` optional).
|
|
96
|
+
- **The default icon.** The button leads with a globe drawn in `currentColor`,
|
|
97
|
+
`aria-hidden` and outside the accessible name. It is sized by
|
|
98
|
+
`--rv-i18n-toggle-icon-size` (`1.5em` — 21px at the shipped `0.875rem` type) inside a
|
|
99
|
+
stretched grid box, so the mark and a consumer icon are sized by layout rather than by
|
|
100
|
+
a descendant rule that view encapsulation cannot apply to consumer nodes. The artwork
|
|
101
|
+
is retuned for 21px: the source's latitudes are dropped and its meridian narrowed,
|
|
102
|
+
because they fill in below ~22px at a legible stroke weight.
|
|
103
|
+
- **`[icon]`.** A `TemplateRef` that replaces the default globe. Rendered through a view
|
|
104
|
+
container in a view hook — the same path as the trigger template — so the nodes stay
|
|
105
|
+
consumer-owned and `@angular/common` stays out of the peer list.
|
|
106
|
+
- **Behaviour.** Three or more languages: `aria-disabled="true"` plus one dev-mode
|
|
107
|
+
warning per instance, never silent cycling through the first two. Busy:
|
|
108
|
+
`aria-busy="true"` only, a `progress` cursor, activation ignored in the handler and
|
|
109
|
+
never queued. `languageChange` fires only after `setLanguageAsync` resolves **and**
|
|
110
|
+
the manager's current language is the target; a failed load emits nothing and leaves
|
|
111
|
+
the UI untouched. `[disabled]` sets the native attribute.
|
|
112
|
+
- **Styling.** `--rv-i18n-toggle-*` tokens falling back to the `--rv-*` semantics,
|
|
113
|
+
logical properties and `rem` only, plus `--rv-i18n-toggle-icon-size`; `data-busy`,
|
|
114
|
+
`data-disabled` and `data-languages="2" | "many"` on the host, plus the documented
|
|
115
|
+
class hooks. Hover and active are 8% and 16% of `currentColor` mixed **over** the
|
|
116
|
+
button's own fill — as bare ink the pressed state was invisible (4/255 from hover),
|
|
117
|
+
and as a `background` shorthand the base fill was dropped, which made a dark button
|
|
118
|
+
turn see-through.
|
|
119
|
+
- **Experimental tier.** Every export of `@rivinia/i18n/ui` is Experimental in this
|
|
120
|
+
release (decision 2 of `SPEC-0.6-ui.md`, closed 2026-10-29): members may change
|
|
121
|
+
without a deprecation cycle until the entry point is promoted to Stable.
|
|
122
|
+
- **Tested.** Unit specs for the component, the manager contract, the trigger
|
|
123
|
+
template, the icon surface, the name lookup and the export surface; Playwright on
|
|
124
|
+
chromium, chrome and firefox (no WebKit, D39) for keyboard activation, focus
|
|
125
|
+
retention, the direction matrix, the painted icon size and the token, and a trigger
|
|
126
|
+
template's foreign-language fragment; SSR smoke for the server HTML and clean
|
|
127
|
+
hydration. WebKit 27.2 was driven by hand for the icon pass, which is what found the
|
|
128
|
+
consumer-icon sizing defect; it is not part of the recorded matrix.
|
|
129
|
+
- **Docs.** README section for the entry point, including the WCAG 2.5.3 warning for
|
|
130
|
+
trigger templates and the `switchStrategy` caveat: the toggle always calls
|
|
131
|
+
`setLanguageAsync()`, which preloads first even in an `'instant'` app.
|
|
132
|
+
|
|
133
|
+
## 0.6.0
|
|
6
134
|
|
|
7
135
|
The core split (RIV-18) and the pre-release API cleanup. Breaking, as a pre-1.0 minor
|
|
8
136
|
may be: the library never had a released compatibility contract, so the transitional
|