@docx-editor.dev/i18n 2.1.3 → 2.2.0

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
@@ -22,13 +22,23 @@ Locale strings, types, and runtime helpers for the [docx-editor.dev](https://doc
22
22
  npm install @docx-editor.dev/i18n
23
23
  ```
24
24
 
25
- Wrap the editor in a `LocaleProvider`:
25
+ Hand the catalog to the editor:
26
26
 
27
27
  ```tsx
28
- import { DocxEditor, LocaleProvider } from '@docx-editor.dev/react';
28
+ import { DocxEditor } from '@docx-editor.dev/react';
29
29
  import { de } from '@docx-editor.dev/i18n';
30
30
 
31
+ <DocxEditor document={bytes} i18n={de} />;
32
+ ```
33
+
34
+ For several editors, or for chrome parts you compose yourself, put it in context once with
35
+ `LocaleProvider` instead:
36
+
37
+ ```tsx
38
+ import { DocxEditor, LocaleProvider } from '@docx-editor.dev/react';
39
+
31
40
  <LocaleProvider i18n={de}>
41
+ <DocxEditor.Toolbar />
32
42
  <DocxEditor document={bytes} />
33
43
  </LocaleProvider>;
34
44
  ```
@@ -108,7 +118,7 @@ import type {
108
118
  LocaleStrings, // shape of `en`, the full source of truth
109
119
  PartialLocaleStrings, // shape of a community partial (null falls back)
110
120
  Translations, // alias for PartialLocaleStrings
111
- TranslationKey, // 'toolbar.bold' | 'dialogs.findReplace.title' | ...
121
+ TranslationKey, // 'formattingBar.bold' | 'navigation.find.counter' | ...
112
122
  LocaleCode, // 'en' | 'de' | 'pt-BR' | ...
113
123
  TFunction, // signature of the `t()` callback
114
124
  } from '@docx-editor.dev/i18n';
@@ -123,8 +133,8 @@ import { createT, deepMerge, en, de, type LocaleStrings } from '@docx-editor.dev
123
133
 
124
134
  const merged = deepMerge(en, de) as LocaleStrings;
125
135
  const t = createT(merged, 'de');
126
- t('toolbar.bold'); // 'Fett'
127
- t('dialogs.findReplace.matchCount', { current: 3, total: 15 }); // ICU plurals
136
+ t('formattingBar.bold'); // 'Fett'
137
+ t('navigation.find.total', { total: 15 }); // ICU plurals
128
138
  ```
129
139
 
130
140
  `en.json` is the source of truth. Add keys there, then run `bun run i18n:fix` from the repo root to sync community locales (new keys land as `null`). Full guide: [docs/i18n.md](https://github.com/eigenpal/docx-editor/blob/main/docs/i18n.md).