@betteroffice/xlsx-i18n 0.0.7 → 0.1.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 +25 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,58 +1,53 @@
|
|
|
1
1
|
# @betteroffice/xlsx-i18n
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
UI locale strings, types, and runtime helpers for the
|
|
4
|
+
[`@betteroffice/xlsx-react`](https://www.npmjs.com/package/@betteroffice/xlsx-react)
|
|
5
|
+
editor. `en` is the source of truth; community locales mirror its shape and fall
|
|
6
|
+
back to English for any untranslated key.
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
> **Early (`0.0.x`).** The core surfaces — opening/saving documents, the editor
|
|
9
|
+
> components, collaboration — are settling and unlikely to change shape. Smaller
|
|
10
|
+
> APIs may still move between releases; breaking changes are always listed in
|
|
11
|
+
> the changelog.
|
|
6
12
|
|
|
7
13
|
```bash
|
|
8
|
-
|
|
14
|
+
bun add @betteroffice/xlsx-i18n
|
|
9
15
|
```
|
|
10
16
|
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
11
19
|
Pass a typed locale to the editor's `i18n` prop:
|
|
12
20
|
|
|
13
21
|
```tsx
|
|
14
22
|
import { de } from '@betteroffice/xlsx-i18n';
|
|
15
23
|
import { XlsxEditor } from '@betteroffice/xlsx-react';
|
|
16
24
|
|
|
17
|
-
<XlsxEditor file={file} i18n={de}
|
|
25
|
+
<XlsxEditor file={file} i18n={de} />;
|
|
18
26
|
```
|
|
19
27
|
|
|
20
|
-
Keys set to `null` fall back to English.
|
|
28
|
+
Keys set to `null` in any locale fall back to English.
|
|
21
29
|
|
|
22
|
-
##
|
|
30
|
+
## Locales
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
| `en` | `en` | English |
|
|
27
|
-
| `de` | `de` | German |
|
|
28
|
-
| `fr` | `fr` | French |
|
|
29
|
-
| `he` | `he` | Hebrew |
|
|
30
|
-
| `hi` | `hi` | Hindi |
|
|
31
|
-
| `id` | `id` | Indonesian |
|
|
32
|
-
| `pl` | `pl` | Polish |
|
|
33
|
-
| `pt-BR` | `ptBR` | Portuguese (Brazil) |
|
|
34
|
-
| `tr` | `tr` | Turkish |
|
|
35
|
-
| `zh-CN` | `zhCN` | Simplified Chinese |
|
|
32
|
+
`en` (source), `de`, `fr`, `he`, `hi`, `id`, `pl`, `pt-BR`, `tr`, `zh-CN`.
|
|
33
|
+
BCP-47 tags use camelCase identifiers (`ptBR`, `zhCN`).
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
35
|
+
Each locale also ships as its own subpath (`@betteroffice/xlsx-i18n/pl`) so an
|
|
36
|
+
app that picks the locale at runtime can code-split rather than bundle them all.
|
|
37
|
+
For lookup by tag, `import { locales } from '@betteroffice/xlsx-i18n'` (pulls
|
|
38
|
+
every locale into the bundle).
|
|
42
39
|
|
|
43
40
|
## Types and helpers
|
|
44
41
|
|
|
45
|
-
The package exports `LocaleStrings`, `PartialLocaleStrings`, `Translations`,
|
|
42
|
+
The package exports `LocaleStrings`, `PartialLocaleStrings`, `Translations`,
|
|
43
|
+
`TranslationKey`, `LocaleCode`, `TFunction`, `createT`, and `deepMerge`. For
|
|
44
|
+
non-React hosts, build a typed `t()` directly:
|
|
46
45
|
|
|
47
46
|
```ts
|
|
48
47
|
import { createT, deepMerge, en, de, type LocaleStrings } from '@betteroffice/xlsx-i18n';
|
|
49
48
|
|
|
50
|
-
const
|
|
51
|
-
const t = createT(strings, 'de');
|
|
49
|
+
const t = createT(deepMerge(en, de) as LocaleStrings, 'de');
|
|
52
50
|
t('toolbar.save');
|
|
53
51
|
```
|
|
54
52
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
> [!TIP]
|
|
58
|
-
> Questions or feature requests? Open an issue at **[github.com/openooxml/betteroffice](https://github.com/openooxml/betteroffice/issues)**.
|
|
53
|
+
Docs: https://betteroffice.dev · Apache-2.0.
|