@owlmeans/i18n 0.1.15 → 0.1.16
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
|
@@ -57,10 +57,9 @@ The global translation store. Read by platform-specific i18n adapters (e.g. `@ow
|
|
|
57
57
|
<!-- owlmeans:agent-guidance:start -->
|
|
58
58
|
## Agent guidance
|
|
59
59
|
|
|
60
|
-
This package ships embedded
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(`.claude/skills/` and `.github/instructions/`):
|
|
60
|
+
This package ships embedded agent skills under `agent-meta/`. After installing your
|
|
61
|
+
`@owlmeans/*` packages, run the OwlMeans agent-skills installer to place them into
|
|
62
|
+
your project's skill store (`.agents/skills/`):
|
|
64
63
|
|
|
65
64
|
```sh
|
|
66
65
|
npx @owlmeans/agent-skills
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/i18n",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"generatedAt": "2026-08-
|
|
4
|
+
"version": "0.1.16",
|
|
5
|
+
"generatedAt": "2026-08-14T10:14:48.845Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -10,28 +10,14 @@
|
|
|
10
10
|
"name": "localization",
|
|
11
11
|
"category": "multi-package",
|
|
12
12
|
"file": "skills/localization/SKILL.md",
|
|
13
|
-
"canonicalPath": ".
|
|
13
|
+
"canonicalPath": ".agents/skills/localization/SKILL.md"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"kind": "skill",
|
|
17
17
|
"name": "i18n",
|
|
18
18
|
"category": "package-specific",
|
|
19
19
|
"file": "skills/i18n/SKILL.md",
|
|
20
|
-
"canonicalPath": ".
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"kind": "instruction",
|
|
24
|
-
"name": "localization",
|
|
25
|
-
"category": "multi-package",
|
|
26
|
-
"file": "instructions/localization.instructions.md",
|
|
27
|
-
"canonicalPath": ".github/instructions/localization.instructions.md"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"kind": "instruction",
|
|
31
|
-
"name": "i18n",
|
|
32
|
-
"category": "package-specific",
|
|
33
|
-
"file": "instructions/i18n.instructions.md",
|
|
34
|
-
"canonicalPath": ".github/instructions/i18n.instructions.md"
|
|
20
|
+
"canonicalPath": ".agents/skills/i18n/SKILL.md"
|
|
35
21
|
}
|
|
36
22
|
]
|
|
37
23
|
}
|
package/package.json
CHANGED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "How to use @owlmeans/i18n — the core localization registry. Use when adding translatable strings to a library package or importing from this package."
|
|
3
|
-
applyTo: "**/*.ts, **/*.tsx"
|
|
4
|
-
---
|
|
5
|
-
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
-
|
|
7
|
-
# @owlmeans/i18n
|
|
8
|
-
|
|
9
|
-
**Layer:** Core (no runtime deps)
|
|
10
|
-
**Version:** `"@owlmeans/i18n": "^0.1.15"`
|
|
11
|
-
|
|
12
|
-
## Key exports
|
|
13
|
-
|
|
14
|
-
| Export | Description |
|
|
15
|
-
|--------|-------------|
|
|
16
|
-
| `addI18nLib(lng, resource, data, opts?)` | Register library strings (ns=`'lib'`) |
|
|
17
|
-
| `addI18nApp(lng, resource, data, opts?)` | Register app strings (ns=resource name) |
|
|
18
|
-
| `initI18nResource(lng, resource, ns?)` | Drain bundles for a language (internal use by client-i18n) |
|
|
19
|
-
| `SUPPORTED_LNGS` | `['en','pl','ru','be','uk','es','de']` |
|
|
20
|
-
| `I18nTier` | `Library \| App` |
|
|
21
|
-
| `I18nConfig` | `{ defaultLng?, defaultNs?, fallbackLng?, supportedLngs? }` |
|
|
22
|
-
|
|
23
|
-
## Per-package i18n registration pattern
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
// src/i18n.ts
|
|
27
|
-
import { addI18nLib } from '@owlmeans/i18n'
|
|
28
|
-
import en from './i18n/en.json' with { type: 'json' }
|
|
29
|
-
import pl from './i18n/pl.json' with { type: 'json' }
|
|
30
|
-
// … ru, be, uk, es, de
|
|
31
|
-
addI18nLib('en', 'my-package', en)
|
|
32
|
-
addI18nLib('pl', 'my-package', pl)
|
|
33
|
-
// … all 7 languages
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Export from `src/index.ts`: `export * from './i18n.js'`
|
|
37
|
-
|
|
38
|
-
## Invariants
|
|
39
|
-
|
|
40
|
-
- **All 7 languages required**: never add a key to `en.json` without adding it to pl/ru/be/uk/es/de in the same commit.
|
|
41
|
-
- Library packages use `addI18nLib`; apps use `addI18nApp`.
|
|
42
|
-
- Custom namespace via `opts.ns` only when keys must live outside `'lib'` (e.g. DID's `{ ns: 'did' }`).
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "OwlMeans localization conventions — tiered namespace model, compound-prefix keys, 7-language requirement, override pattern. Apply whenever adding UI strings, JSON translation files, or i18n hooks to any package."
|
|
3
|
-
applyTo: "**/*.ts, **/*.tsx, **/i18n/**"
|
|
4
|
-
---
|
|
5
|
-
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
-
|
|
7
|
-
# OwlMeans Localization Conventions
|
|
8
|
-
|
|
9
|
-
## Canonical languages
|
|
10
|
-
|
|
11
|
-
`SUPPORTED_LNGS` from `@owlmeans/i18n`:
|
|
12
|
-
```
|
|
13
|
-
en pl ru be uk es de
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
**Every new translation key must exist in all 7 language files in the same commit.**
|
|
17
|
-
|
|
18
|
-
## Tiered namespace model
|
|
19
|
-
|
|
20
|
-
| Package type | Register with | namespace | key path |
|
|
21
|
-
|---|---|---|---|
|
|
22
|
-
| `@owlmeans/*` library | `addI18nLib` | `'lib'` | `resource.prefix.key` |
|
|
23
|
-
| App / shared project | `addI18nApp` | resource name | `resource.prefix.key` |
|
|
24
|
-
|
|
25
|
-
App tier overrides Library tier for the same key.
|
|
26
|
-
|
|
27
|
-
## Compound prefix keys
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
t('title') via useI18nLib('errors', 'form')
|
|
31
|
-
→ namespace='lib', key='errors.form.title'
|
|
32
|
-
→ resolves errors.json → form.title
|
|
33
|
-
|
|
34
|
-
t('title') via useI18nApp(undefined, 'home-screen')
|
|
35
|
-
→ namespace='my-app', key='my-app.home-screen.title'
|
|
36
|
-
→ resolves my-app i18n data → home-screen.title
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Context-based prefix switching
|
|
40
|
-
|
|
41
|
-
`PanelContext` (from `@owlmeans/client-panel`) injects `{ resource, ns, prefix }` into a React subtree. Children call `usePanelI18n()` / `useFormI18n()` which inherit the context.
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
<PanelContext resource="wl-manager" ns="lib" prefix="wl-dns">
|
|
45
|
-
<DnsSection />
|
|
46
|
-
</PanelContext>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Hook selection guide
|
|
50
|
-
|
|
51
|
-
| Where | Hook |
|
|
52
|
-
|---|---|
|
|
53
|
-
| `@owlmeans/*` library component | `useI18nLib('resource', 'prefix')` |
|
|
54
|
-
| App / project component | `useI18nApp(undefined, 'prefix')` |
|
|
55
|
-
| Inside panel/form context | `usePanelI18n('name')` / `useFormI18n()` |
|
|
56
|
-
| ns ≠ resource (rare) | `useI18n('resource', 'ns', 'prefix')` |
|
|
57
|
-
|
|
58
|
-
## Adding a new translatable string — checklist
|
|
59
|
-
|
|
60
|
-
1. Add key to `en.json`
|
|
61
|
-
2. Add the same key (with translation) to `pl.json`, `ru.json`, `be.json`, `uk.json`, `es.json`, `de.json`
|
|
62
|
-
3. Use a hook in the component — never hardcode the string
|
|
63
|
-
|
|
64
|
-
## Language switcher
|
|
65
|
-
|
|
66
|
-
```tsx
|
|
67
|
-
import { useLanguage } from '@owlmeans/client-i18n'
|
|
68
|
-
import { SUPPORTED_LNGS } from '@owlmeans/i18n'
|
|
69
|
-
|
|
70
|
-
const [lng, setLng] = useLanguage()
|
|
71
|
-
// persisted to localStorage automatically
|
|
72
|
-
```
|