@owlmeans/client-i18n 0.1.18-rc.13 → 0.1.18-rc.15
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/README.md
CHANGED
|
@@ -12,7 +12,7 @@ React i18next adapter that loads translations registered via `@owlmeans/i18n` in
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/client-i18n
|
|
15
|
+
bun add @owlmeans/client-i18n@^0.1.18-rc.14
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -68,7 +68,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
68
68
|
your project's skill store (`.agents/skills/`):
|
|
69
69
|
|
|
70
70
|
```sh
|
|
71
|
-
npx @owlmeans/agent-skills
|
|
71
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.12
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/client-i18n",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.15",
|
|
5
|
+
"generatedAt": "2026-09-04T22:43:25.445Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/client-i18n
|
|
9
9
|
|
|
10
10
|
**Layer:** Client (React)
|
|
11
|
-
**Install:** `"@owlmeans/client-i18n": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/client-i18n": "^0.1.18-rc.15"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Purpose
|
|
14
14
|
|
|
@@ -26,6 +26,32 @@ Wraps i18next + react-i18next, lazily loads registered bundles from `@owlmeans/i
|
|
|
26
26
|
| `composePrefix(parent?, child?)` | Canonical dot-join for prefix chaining; never call manually in panel code — used internally |
|
|
27
27
|
| `I18nBaseProps` | `{ resource?, ns?, prefix?, suppress? }` |
|
|
28
28
|
| `I18nProps` | `{ i18n?: I18nBaseProps }` |
|
|
29
|
+
| `I18nContextProps` | `{ config: ClientConfig }` — what the provider takes |
|
|
30
|
+
|
|
31
|
+
## Subpath: `./utils`
|
|
32
|
+
|
|
33
|
+
The instance itself, for a host that has to configure i18next before the tree renders.
|
|
34
|
+
|
|
35
|
+
| Export | Description |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `useI18nInstance(config)` | The i18next instance for this application, memoised for the mount |
|
|
38
|
+
| `getI18nInstance(config)` | The same instance outside React |
|
|
39
|
+
| `setLanguage(lng)` | Persist and switch, without a component — what `useLanguage`'s setter calls |
|
|
40
|
+
|
|
41
|
+
**There is exactly one instance per document**, created on first request and reused by every later
|
|
42
|
+
call whatever config is passed. So configuration is read once, at the first creation, and a plugin
|
|
43
|
+
is installed on the instance rather than passed to a second factory:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { useI18nInstance } from '@owlmeans/client-i18n/utils'
|
|
47
|
+
import detector from 'i18next-browser-languagedetector'
|
|
48
|
+
|
|
49
|
+
const instance = useI18nInstance(context.cfg)
|
|
50
|
+
instance.use(detector)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`@owlmeans/web-panel`'s `render` already does exactly this, so an application on the panel family
|
|
54
|
+
needs none of it.
|
|
29
55
|
|
|
30
56
|
## Setup (app root)
|
|
31
57
|
|
|
@@ -45,7 +71,10 @@ function App() {
|
|
|
45
71
|
|
|
46
72
|
## Language persistence
|
|
47
73
|
|
|
48
|
-
The active language is persisted in `localStorage` under `owlmeans-lng` and restored on init
|
|
74
|
+
The active language is persisted in `localStorage` under `owlmeans-lng` and restored on init — but
|
|
75
|
+
only when it is in `supportedLngs`, so a stored value that a later release dropped falls back to
|
|
76
|
+
`fallbackLng` instead of resolving nothing. Every storage access is guarded, so a browser that
|
|
77
|
+
refuses site data still renders.
|
|
49
78
|
|
|
50
79
|
```tsx
|
|
51
80
|
function LangSwitch() {
|
|
@@ -96,16 +125,24 @@ t('title') // → did:wallet.createKey.title
|
|
|
96
125
|
|
|
97
126
|
## App-level override of library strings
|
|
98
127
|
|
|
99
|
-
Import the library's i18n registration **and** register your own version at App tier
|
|
128
|
+
Import the library's i18n registration **and** register your own version at App tier **in the
|
|
129
|
+
library's namespace**:
|
|
100
130
|
```typescript
|
|
101
|
-
import '@owlmeans/error
|
|
102
|
-
import { addI18nApp } from '@owlmeans/i18n'
|
|
103
|
-
import myErrors from './i18n/en.json'
|
|
131
|
+
import '@owlmeans/error' // the library bundle, registered by side effect
|
|
132
|
+
import { addI18nApp, LIB_NAMESPACE } from '@owlmeans/i18n'
|
|
133
|
+
import myErrors from './i18n/en.json' with { type: 'json' }
|
|
104
134
|
|
|
105
|
-
// App tier
|
|
106
|
-
addI18nApp('en', 'errors', myErrors)
|
|
135
|
+
// App tier merges last within (ns, resource, lng) — these override the library's 'errors' strings
|
|
136
|
+
addI18nApp('en', 'errors', myErrors, { ns: LIB_NAMESPACE })
|
|
107
137
|
```
|
|
108
138
|
|
|
139
|
+
`{ ns: LIB_NAMESPACE }` is what makes it an override. `addI18nApp` defaults the namespace to the
|
|
140
|
+
**resource** name, so without it the bundle lands in namespace `errors` while `useI18nLib('errors')`
|
|
141
|
+
reads namespace `lib` — nothing errors, nothing merges, and the library strings keep rendering.
|
|
142
|
+
|
|
143
|
+
A package registers its strings from its own root: `src/i18n.ts` is re-exported by `src/index.ts`,
|
|
144
|
+
so importing the package is what loads them. No package publishes an `./i18n` subpath.
|
|
145
|
+
|
|
109
146
|
## Resource JSON format
|
|
110
147
|
|
|
111
148
|
The shared instance runs i18next's **v4** JSON format — `compatibilityJSON` is not set and must
|
|
@@ -120,5 +157,6 @@ misbehaves at runtime.
|
|
|
120
157
|
|
|
121
158
|
## Depends On
|
|
122
159
|
|
|
123
|
-
`@owlmeans/i18n`, `@owlmeans/client-context`, `i18next` (>= 26.2),
|
|
124
|
-
`react` (peer)
|
|
160
|
+
`@owlmeans/i18n`, `@owlmeans/client`, `@owlmeans/client-context`, `i18next` (>= 26.2),
|
|
161
|
+
`react-i18next` (>= 17), `react` (the one peer). `@owlmeans/client` is what `useI18nApp` reads the
|
|
162
|
+
current context from, to default the resource to `context.cfg.service`.
|
package/build/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAI3C,CAAA;AAEF,kGAAkG;AAClG,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKxC,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAI3C,CAAA;AAEF,kGAAkG;AAClG,eAAO,MAAM,aAAa,YAAa,MAAM,UAAU,MAAM,KAAG,MAK/D,CAAA;AAyCD;4FAC4F;AAC5F,eAAO,MAAM,OAAO,aAAc,MAAM,OAAO,MAAM,WAAW,MAAM,KAAG,SAExE,CAAA;AAED,eAAO,MAAM,UAAU,YAAa,MAAM,WAAW,MAAM,KAAG,SAE7D,CAAA;AAED,eAAO,MAAM,UAAU,aAAc,MAAM,WAAW,MAAM,KAAG,SAK9D,CAAA;AAED,eAAO,MAAM,WAAW,QAAO,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAU5D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/utils/instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAO5D,eAAO,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/utils/instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAO5D,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,IAItD,CAAA;AAED,eAAO,MAAM,eAAe,WAAY,YAAY,KAAG,IAC3B,CAAA;AAE5B,eAAO,MAAM,WAAW,QAAS,MAAM,KAAG,IAMzC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/client-i18n",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"typescript": "^7.0.2"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@owlmeans/client": "^0.1.18-rc.
|
|
41
|
-
"@owlmeans/client-context": "^0.1.18-rc.
|
|
42
|
-
"@owlmeans/i18n": "^0.1.18-rc.
|
|
40
|
+
"@owlmeans/client": "^0.1.18-rc.16",
|
|
41
|
+
"@owlmeans/client-context": "^0.1.18-rc.13",
|
|
42
|
+
"@owlmeans/i18n": "^0.1.18-rc.8",
|
|
43
43
|
"i18next": "^26.2.0",
|
|
44
44
|
"react-i18next": "^17.0.11"
|
|
45
45
|
},
|