@softistx/alxia-i18n 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +262 -2
- package/dist/catalogue.d.ts +44 -0
- package/dist/catalogue.d.ts.map +1 -0
- package/dist/chain.d.ts +33 -0
- package/dist/chain.d.ts.map +1 -0
- package/dist/codes.d.ts +9 -0
- package/dist/codes.d.ts.map +1 -0
- package/dist/coverage.d.ts +17 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/i18n.d.ts +29 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +266 -0
- package/dist/index.js.map +16 -0
- package/dist/lookup.d.ts +18 -0
- package/dist/lookup.d.ts.map +1 -0
- package/dist/seeds.d.ts +35 -0
- package/dist/seeds.d.ts.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/docs/README.md +13 -0
- package/docs/guide.md +924 -0
- package/docs/roadmap.md +95 -0
- package/docs/troubleshooting.md +663 -0
- package/package.json +54 -5
package/docs/roadmap.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Roadmap
|
|
2
|
+
|
|
3
|
+
What `@softistx/alxia-i18n` gives an app, and what is coming. This page is a
|
|
4
|
+
direction, not a commitment: the version something shipped in is the only
|
|
5
|
+
number on it. Every release, with each change it made, is in
|
|
6
|
+
[`CHANGELOG.md`](https://github.com/softistx/alxia/blob/develop/packages/i18n/CHANGELOG.md).
|
|
7
|
+
|
|
8
|
+
## Now
|
|
9
|
+
|
|
10
|
+
- **Moving to the `@softistx` scope.** The package is now `@softistx/alxia-i18n` (it was `@alxia/i18n`). Same code and API; replace the dependency and the imports ([migration guide](https://github.com/softistx/alxia/blob/develop/packages/core/docs/guide/migrating-from-alxia-scope.md)). The old name is deprecated.
|
|
11
|
+
|
|
12
|
+
## Next
|
|
13
|
+
|
|
14
|
+
- **Hot reload of the catalogues.** `@softistx/i18n` gets a `CatalogueSource`,
|
|
15
|
+
`load()` for the catalogues and `version()` for a cheap version string,
|
|
16
|
+
and a watcher that polls `version()` and calls `onChange` when it moves;
|
|
17
|
+
`@softistx/alxia-i18n` then feeds the result to `setResources()`, so an app picks
|
|
18
|
+
up edited catalogues without a restart and a request in flight keeps the
|
|
19
|
+
ones it started with. Needs the `setResources()` of 0.4.0; the `version` of `resolveCatalogue()` (0.6.0) is the cheap string `version()` can return for a database-backed catalogue. Waits on
|
|
20
|
+
[softistx/nxgt-core#326](https://github.com/softistx/nxgt-core/issues/326).
|
|
21
|
+
|
|
22
|
+
## Later
|
|
23
|
+
|
|
24
|
+
Nothing scheduled yet.
|
|
25
|
+
|
|
26
|
+
## Not planned
|
|
27
|
+
|
|
28
|
+
- **A runtime dependency.** `@softistx/alxia-i18n` declares no dependency, only
|
|
29
|
+
peers — `@softistx/alxia`, `@softistx/alxia-language`, `@softistx/i18n` and `typescript`:
|
|
30
|
+
it is built on their public APIs and Node's `AsyncLocalStorage`.
|
|
31
|
+
|
|
32
|
+
## Shipped
|
|
33
|
+
|
|
34
|
+
### 0.6.0
|
|
35
|
+
|
|
36
|
+
- **A catalogue from database rows.** `catalogueOf` and `resolveCatalogue`
|
|
37
|
+
build a language's message tree, its fallback chain and a stable `version`
|
|
38
|
+
(the first 32 hex characters of the SHA-256 of the key-sorted JSON) from
|
|
39
|
+
`{ key, language, text }` rows, with no database client.
|
|
40
|
+
- **Codes and a load-time check.** `defineCodes(area, slugs)` gives typed
|
|
41
|
+
`<area>.errors.<slug>` literals; `assertCoverage` and `uncovered` refuse, or
|
|
42
|
+
report, a declared code with no text.
|
|
43
|
+
- **Migration seeds.** `seedsOf`, `upsertTexts`, `removeTexts` (codes the
|
|
44
|
+
migration created) and `restoreTexts` (a rewording) over a two-method
|
|
45
|
+
`TextStore`; texts go code first and a language-first map is refused.
|
|
46
|
+
- `has` and `messageAt` are exported.
|
|
47
|
+
|
|
48
|
+
### 0.5.0
|
|
49
|
+
|
|
50
|
+
- **On `@softistx/i18n` `^3.2.0`.** (now `^3.2.1`) The peer moved from `@nxgt/i18n`, which gets
|
|
51
|
+
no new version, to the `@softistx` scope on npmjs: replace
|
|
52
|
+
one by the other.
|
|
53
|
+
|
|
54
|
+
### 0.4.0
|
|
55
|
+
|
|
56
|
+
- **On `@softistx/i18n` 3 (breaking: bump it to `^3.0.0` everywhere).** The peer range is `^3.0.0`. `t()` walks the chain
|
|
57
|
+
alone and hands `@softistx/i18n` the language that holds the key, so its new
|
|
58
|
+
global fallback lookup (`setFallbackLanguage()`) never answers in place of
|
|
59
|
+
the chain, and a key no language holds still answers itself. A language is
|
|
60
|
+
any string; `@softistx/i18n` speaks a language added with `registerCatalogue()`.
|
|
61
|
+
- **A key-level fallback chain.** The `fallbacks` option, `i18n.fallBackTo()`
|
|
62
|
+
for one request and `i18n.chain()`: `t()` tries the request's language, the
|
|
63
|
+
request's steps, `fallbacks(language)`, then `fallback`, and answers the key
|
|
64
|
+
only when all miss.
|
|
65
|
+
- **Catalogues loaded at runtime, keys typed.** `createI18n<Key>({ fallback })`
|
|
66
|
+
names the keys, `i18n.setResources()` swaps the catalogues atomically,
|
|
67
|
+
`supported` follows, and a request keeps the ones it started with.
|
|
68
|
+
|
|
69
|
+
### 0.3.0
|
|
70
|
+
|
|
71
|
+
- **A middleware, not a plugin (0.4).** `app.use(createI18n({ ... }))` runs on every request, a 404 included; its `t()` works in every middleware after it and in the answer to an error. `app.plugin(i18n)`, the deprecated plugin form, was removed with alxia 0.5: give it to `use`.
|
|
72
|
+
|
|
73
|
+
### 0.1.0
|
|
74
|
+
|
|
75
|
+
- **Translations as one plugin.** `alxia().use(createI18n({ resources, fallback }))`
|
|
76
|
+
gives the routes after it `t`, bound to the request's language, and
|
|
77
|
+
`language`, typed as one of the catalogues' languages.
|
|
78
|
+
- **The request's language, found by `@alxia/language`.** The query, a
|
|
79
|
+
cookie, `Accept-Language`, then `fallback`; its options pass through.
|
|
80
|
+
- **A preference an earlier plugin knows.** Annotate `resolve`'s parameter —
|
|
81
|
+
`({ user }: BaseContext & { user: User }) => user.language` — and it reads
|
|
82
|
+
what an earlier plugin added; an app that does not give it cannot use the
|
|
83
|
+
plugin, and one annotated `any` is refused. The languages and keys stay
|
|
84
|
+
inferred from `resources` and `fallback`.
|
|
85
|
+
- **Keys typed by your catalogue.** `t` takes the dotted keys of the
|
|
86
|
+
fallback's catalogue, from a literal or a JSON file, and refuses a typo.
|
|
87
|
+
- **ICU messages.** Plurals, selects and numbers, formatted by `@softistx/i18n`
|
|
88
|
+
in the request's language; a missing key answers itself, a message that
|
|
89
|
+
cannot be formatted is logged and answered as it is.
|
|
90
|
+
- **`t()` anywhere a request runs.** The plugin's own `t()` and
|
|
91
|
+
`language()` follow the request through every `await` — a service, a
|
|
92
|
+
model — and answer in the fallback outside one.
|
|
93
|
+
- **`@softistx/i18n` speaks it too.** The request's language is registered as
|
|
94
|
+
one of `@softistx/i18n`'s sources, so its `getLanguage()` and `translate`
|
|
95
|
+
follow the alxia request.
|