@docx-editor.dev/i18n 2.1.2 → 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 +15 -5
- package/dist/de.js +13 -529
- package/dist/de.mjs +13 -529
- package/dist/en.js +16 -532
- package/dist/en.mjs +16 -532
- package/dist/fr.js +13 -529
- package/dist/fr.mjs +13 -529
- package/dist/he.js +13 -529
- package/dist/he.mjs +13 -529
- package/dist/hi.js +13 -529
- package/dist/hi.mjs +13 -529
- package/dist/id.js +13 -529
- package/dist/id.mjs +13 -529
- package/dist/index.d.mts +21 -544
- package/dist/index.d.ts +21 -544
- package/dist/index.js +133 -5293
- package/dist/index.mjs +133 -5293
- package/dist/pl.js +13 -529
- package/dist/pl.mjs +13 -529
- package/dist/pt-BR.js +13 -529
- package/dist/pt-BR.mjs +13 -529
- package/dist/tr.js +13 -529
- package/dist/tr.mjs +13 -529
- package/dist/zh-CN.js +13 -529
- package/dist/zh-CN.mjs +13 -529
- package/package.json +1 -1
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
|
-
|
|
25
|
+
Hand the catalog to the editor:
|
|
26
26
|
|
|
27
27
|
```tsx
|
|
28
|
-
import { DocxEditor
|
|
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, // '
|
|
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('
|
|
127
|
-
t('
|
|
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).
|