@rivinia/i18n 0.6.0 → 0.7.1

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