ai-i18n-tools 1.0.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/LICENSE +21 -0
- package/README.md +157 -0
- package/dist/api/openrouter.d.ts +115 -0
- package/dist/api/openrouter.d.ts.map +1 -0
- package/dist/api/openrouter.js +399 -0
- package/dist/api/openrouter.js.map +1 -0
- package/dist/cli/doc-translate.d.ts +90 -0
- package/dist/cli/doc-translate.d.ts.map +1 -0
- package/dist/cli/doc-translate.js +1153 -0
- package/dist/cli/doc-translate.js.map +1 -0
- package/dist/cli/export-ui-xliff.d.ts +32 -0
- package/dist/cli/export-ui-xliff.d.ts.map +1 -0
- package/dist/cli/export-ui-xliff.js +153 -0
- package/dist/cli/export-ui-xliff.js.map +1 -0
- package/dist/cli/extract-strings.d.ts +12 -0
- package/dist/cli/extract-strings.d.ts.map +1 -0
- package/dist/cli/extract-strings.js +80 -0
- package/dist/cli/extract-strings.js.map +1 -0
- package/dist/cli/file-utils.d.ts +10 -0
- package/dist/cli/file-utils.d.ts.map +1 -0
- package/dist/cli/file-utils.js +77 -0
- package/dist/cli/file-utils.js.map +1 -0
- package/dist/cli/format.d.ts +21 -0
- package/dist/cli/format.d.ts.map +1 -0
- package/dist/cli/format.js +75 -0
- package/dist/cli/format.js.map +1 -0
- package/dist/cli/helpers.d.ts +27 -0
- package/dist/cli/helpers.d.ts.map +1 -0
- package/dist/cli/helpers.js +84 -0
- package/dist/cli/helpers.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +772 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/log-output.d.ts +13 -0
- package/dist/cli/log-output.d.ts.map +1 -0
- package/dist/cli/log-output.js +75 -0
- package/dist/cli/log-output.js.map +1 -0
- package/dist/cli/translate-svg.d.ts +7 -0
- package/dist/cli/translate-svg.d.ts.map +1 -0
- package/dist/cli/translate-svg.js +167 -0
- package/dist/cli/translate-svg.js.map +1 -0
- package/dist/cli/translate-ui-strings.d.ts +27 -0
- package/dist/cli/translate-ui-strings.d.ts.map +1 -0
- package/dist/cli/translate-ui-strings.js +357 -0
- package/dist/cli/translate-ui-strings.js.map +1 -0
- package/dist/core/cache-tracking-keys.d.ts +12 -0
- package/dist/core/cache-tracking-keys.d.ts.map +1 -0
- package/dist/core/cache-tracking-keys.js +20 -0
- package/dist/core/cache-tracking-keys.js.map +1 -0
- package/dist/core/cache.d.ts +153 -0
- package/dist/core/cache.d.ts.map +1 -0
- package/dist/core/cache.js +546 -0
- package/dist/core/cache.js.map +1 -0
- package/dist/core/config.d.ts +58 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +392 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/doc-file-tracking.d.ts +8 -0
- package/dist/core/doc-file-tracking.d.ts.map +1 -0
- package/dist/core/doc-file-tracking.js +27 -0
- package/dist/core/doc-file-tracking.js.map +1 -0
- package/dist/core/errors.d.ts +19 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +23 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/locale-utils.d.ts +20 -0
- package/dist/core/locale-utils.d.ts.map +1 -0
- package/dist/core/locale-utils.js +75 -0
- package/dist/core/locale-utils.js.map +1 -0
- package/dist/core/output-paths.d.ts +22 -0
- package/dist/core/output-paths.d.ts.map +1 -0
- package/dist/core/output-paths.js +130 -0
- package/dist/core/output-paths.js.map +1 -0
- package/dist/core/prompt-builder.d.ts +62 -0
- package/dist/core/prompt-builder.d.ts.map +1 -0
- package/dist/core/prompt-builder.js +232 -0
- package/dist/core/prompt-builder.js.map +1 -0
- package/dist/core/prompts.d.ts +27 -0
- package/dist/core/prompts.d.ts.map +1 -0
- package/dist/core/prompts.js +57 -0
- package/dist/core/prompts.js.map +1 -0
- package/dist/core/svg-asset-paths.d.ts +40 -0
- package/dist/core/svg-asset-paths.d.ts.map +1 -0
- package/dist/core/svg-asset-paths.js +107 -0
- package/dist/core/svg-asset-paths.js.map +1 -0
- package/dist/core/types.d.ts +388 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +265 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/ui-languages.d.ts +66 -0
- package/dist/core/ui-languages.d.ts.map +1 -0
- package/dist/core/ui-languages.js +277 -0
- package/dist/core/ui-languages.js.map +1 -0
- package/dist/core/user-edited-model.d.ts +3 -0
- package/dist/core/user-edited-model.d.ts.map +1 -0
- package/dist/core/user-edited-model.js +3 -0
- package/dist/core/user-edited-model.js.map +1 -0
- package/dist/edit-cache-app/app.js +1326 -0
- package/dist/edit-cache-app/index.html +287 -0
- package/dist/edit-cache-app/styles.css +664 -0
- package/dist/extractors/base-extractor.d.ts +15 -0
- package/dist/extractors/base-extractor.d.ts.map +1 -0
- package/dist/extractors/base-extractor.js +23 -0
- package/dist/extractors/base-extractor.js.map +1 -0
- package/dist/extractors/classify-segment.d.ts +6 -0
- package/dist/extractors/classify-segment.d.ts.map +1 -0
- package/dist/extractors/classify-segment.js +20 -0
- package/dist/extractors/classify-segment.js.map +1 -0
- package/dist/extractors/json-extractor.d.ts +16 -0
- package/dist/extractors/json-extractor.d.ts.map +1 -0
- package/dist/extractors/json-extractor.js +128 -0
- package/dist/extractors/json-extractor.js.map +1 -0
- package/dist/extractors/markdown-extractor.d.ts +15 -0
- package/dist/extractors/markdown-extractor.d.ts.map +1 -0
- package/dist/extractors/markdown-extractor.js +205 -0
- package/dist/extractors/markdown-extractor.js.map +1 -0
- package/dist/extractors/svg-extractor.d.ts +19 -0
- package/dist/extractors/svg-extractor.d.ts.map +1 -0
- package/dist/extractors/svg-extractor.js +132 -0
- package/dist/extractors/svg-extractor.js.map +1 -0
- package/dist/extractors/ui-string-extractor.d.ts +40 -0
- package/dist/extractors/ui-string-extractor.d.ts.map +1 -0
- package/dist/extractors/ui-string-extractor.js +146 -0
- package/dist/extractors/ui-string-extractor.js.map +1 -0
- package/dist/extractors/ui-string-locations.d.ts +23 -0
- package/dist/extractors/ui-string-locations.d.ts.map +1 -0
- package/dist/extractors/ui-string-locations.js +138 -0
- package/dist/extractors/ui-string-locations.js.map +1 -0
- package/dist/glossary/glossary.d.ts +34 -0
- package/dist/glossary/glossary.d.ts.map +1 -0
- package/dist/glossary/glossary.js +260 -0
- package/dist/glossary/glossary.js.map +1 -0
- package/dist/glossary/matcher.d.ts +10 -0
- package/dist/glossary/matcher.d.ts.map +1 -0
- package/dist/glossary/matcher.js +12 -0
- package/dist/glossary/matcher.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/processors/admonition-placeholders.d.ts +8 -0
- package/dist/processors/admonition-placeholders.d.ts.map +1 -0
- package/dist/processors/admonition-placeholders.js +59 -0
- package/dist/processors/admonition-placeholders.js.map +1 -0
- package/dist/processors/anchor-placeholders.d.ts +8 -0
- package/dist/processors/anchor-placeholders.d.ts.map +1 -0
- package/dist/processors/anchor-placeholders.js +37 -0
- package/dist/processors/anchor-placeholders.js.map +1 -0
- package/dist/processors/batch-processor.d.ts +10 -0
- package/dist/processors/batch-processor.d.ts.map +1 -0
- package/dist/processors/batch-processor.js +33 -0
- package/dist/processors/batch-processor.js.map +1 -0
- package/dist/processors/bold-code-placeholders.d.ts +14 -0
- package/dist/processors/bold-code-placeholders.d.ts.map +1 -0
- package/dist/processors/bold-code-placeholders.js +116 -0
- package/dist/processors/bold-code-placeholders.js.map +1 -0
- package/dist/processors/doc-postprocess.d.ts +51 -0
- package/dist/processors/doc-postprocess.d.ts.map +1 -0
- package/dist/processors/doc-postprocess.js +215 -0
- package/dist/processors/doc-postprocess.js.map +1 -0
- package/dist/processors/emphasis-placeholders.d.ts +6 -0
- package/dist/processors/emphasis-placeholders.d.ts.map +1 -0
- package/dist/processors/emphasis-placeholders.js +262 -0
- package/dist/processors/emphasis-placeholders.js.map +1 -0
- package/dist/processors/flat-link-rewrite.d.ts +32 -0
- package/dist/processors/flat-link-rewrite.d.ts.map +1 -0
- package/dist/processors/flat-link-rewrite.js +90 -0
- package/dist/processors/flat-link-rewrite.js.map +1 -0
- package/dist/processors/glossary-force-placeholders.d.ts +12 -0
- package/dist/processors/glossary-force-placeholders.d.ts.map +1 -0
- package/dist/processors/glossary-force-placeholders.js +58 -0
- package/dist/processors/glossary-force-placeholders.js.map +1 -0
- package/dist/processors/inline-code-placeholders.d.ts +11 -0
- package/dist/processors/inline-code-placeholders.d.ts.map +1 -0
- package/dist/processors/inline-code-placeholders.js +87 -0
- package/dist/processors/inline-code-placeholders.js.map +1 -0
- package/dist/processors/placeholder-handler.d.ts +38 -0
- package/dist/processors/placeholder-handler.d.ts.map +1 -0
- package/dist/processors/placeholder-handler.js +55 -0
- package/dist/processors/placeholder-handler.js.map +1 -0
- package/dist/processors/translation-placeholder-leaks.d.ts +2 -0
- package/dist/processors/translation-placeholder-leaks.d.ts.map +1 -0
- package/dist/processors/translation-placeholder-leaks.js +9 -0
- package/dist/processors/translation-placeholder-leaks.js.map +1 -0
- package/dist/processors/url-placeholders.d.ts +10 -0
- package/dist/processors/url-placeholders.d.ts.map +1 -0
- package/dist/processors/url-placeholders.js +29 -0
- package/dist/processors/url-placeholders.js.map +1 -0
- package/dist/processors/validator.d.ts +23 -0
- package/dist/processors/validator.d.ts.map +1 -0
- package/dist/processors/validator.js +186 -0
- package/dist/processors/validator.js.map +1 -0
- package/dist/runtime/i18next-helpers.d.ts +146 -0
- package/dist/runtime/i18next-helpers.d.ts.map +1 -0
- package/dist/runtime/i18next-helpers.js +192 -0
- package/dist/runtime/i18next-helpers.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/template.d.ts +21 -0
- package/dist/runtime/template.d.ts.map +1 -0
- package/dist/runtime/template.js +28 -0
- package/dist/runtime/template.js.map +1 -0
- package/dist/runtime/ui-language-display.d.ts +16 -0
- package/dist/runtime/ui-language-display.d.ts.map +1 -0
- package/dist/runtime/ui-language-display.js +26 -0
- package/dist/runtime/ui-language-display.js.map +1 -0
- package/dist/server/translation-editor.d.ts +25 -0
- package/dist/server/translation-editor.d.ts.map +1 -0
- package/dist/server/translation-editor.js +583 -0
- package/dist/server/translation-editor.js.map +1 -0
- package/dist/utils/concurrency.d.ts +31 -0
- package/dist/utils/concurrency.d.ts.map +1 -0
- package/dist/utils/concurrency.js +103 -0
- package/dist/utils/concurrency.js.map +1 -0
- package/dist/utils/hash.d.ts +5 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +9 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/ignore-parser.d.ts +7 -0
- package/dist/utils/ignore-parser.d.ts.map +1 -0
- package/dist/utils/ignore-parser.js +26 -0
- package/dist/utils/ignore-parser.js.map +1 -0
- package/dist/utils/logger.d.ts +45 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +158 -0
- package/dist/utils/logger.js.map +1 -0
- package/docs/GETTING_STARTED.md +697 -0
- package/docs/PACKAGE_OVERVIEW.md +427 -0
- package/docs/ai-i18n-tools-context.md +481 -0
- package/package.json +117 -0
- package/translated-docs/README.de.md +157 -0
- package/translated-docs/README.es.md +157 -0
- package/translated-docs/README.fr.md +157 -0
- package/translated-docs/README.hi.md +157 -0
- package/translated-docs/README.ja.md +157 -0
- package/translated-docs/README.ko.md +157 -0
- package/translated-docs/README.pt-BR.md +157 -0
- package/translated-docs/README.zh-CN.md +157 -0
- package/translated-docs/README.zh-TW.md +157 -0
- package/translated-docs/docs/GETTING_STARTED.de.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.es.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.fr.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.hi.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.ja.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.ko.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.pt-BR.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.zh-CN.md +682 -0
- package/translated-docs/docs/GETTING_STARTED.zh-TW.md +682 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.de.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.es.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.fr.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.hi.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.ja.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.ko.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.pt-BR.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.zh-CN.md +428 -0
- package/translated-docs/docs/PACKAGE_OVERVIEW.zh-TW.md +428 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# ai-i18n-tools
|
|
2
|
+
|
|
3
|
+
CLI- und programmatisches Toolkit zur Internationalisierung von JavaScript/TypeScript-Anwendungen und Dokumentationsseiten. Extrahiert UI-Texte, übersetzt sie mithilfe von LLMs über OpenRouter und generiert sprachenspezifische JSON-Dateien für i18next sowie Pipelines für Markdown, Docusaurus-JSON und (über `features.translateSVG`, `translate-svg` und den `svg`-Block) eigenständige SVG-Ressourcen.
|
|
4
|
+
|
|
5
|
+
<small>**In anderen Sprachen lesen:** </small>
|
|
6
|
+
|
|
7
|
+
<small id="lang-list">[en-GB](../README.md) · [de](./README.de.md) · [es](./README.es.md) · [fr](./README.fr.md) · [hi](./README.hi.md) · [ja](./README.ja.md) · [ko](./README.ko.md) · [pt-BR](./README.pt-BR.md) · [zh-CN](./README.zh-CN.md) · [zh-TW](./README.zh-TW.md)</small>
|
|
8
|
+
|
|
9
|
+
## Zwei Kernarbeitsabläufe
|
|
10
|
+
|
|
11
|
+
**Arbeitsablauf 1 - UI-Übersetzung** (React, Next.js, Node.js, jedes i18next-Projekt)
|
|
12
|
+
|
|
13
|
+
Durchsucht Quell-Dateien nach `t("…")`-Aufrufen, erstellt einen Master-Katalog (`strings.json` mit optionalen **`models`**-Metadaten pro Locale), übersetzt fehlende Einträge pro Locale über OpenRouter und schreibt flache JSON-Dateien (`de.json`, `pt-BR.json`, …), die für i18next bereit sind.
|
|
14
|
+
|
|
15
|
+
**Arbeitsablauf 2 - Dokumentenübersetzung** (Markdown, Docusaurus JSON)
|
|
16
|
+
|
|
17
|
+
Übersetzt `.md`- und `.mdx`-Dateien aus den `contentPaths` jedes `documentations`-Blocks sowie JSON-Beschriftungsdateien aus dem `jsonSource` dieses Blocks, wenn aktiviert. Unterstützt Docusaurus-artige und flache, sprachcodesuffixierte Layouts pro Block (`documentations[].markdownOutput`). Ein gemeinsames Stammverzeichnis `cacheDir` enthält den SQLite-Cache, sodass nur neue oder geänderte Segmente an das LLM gesendet werden. **SVG:** Aktivieren Sie `features.translateSVG`, fügen Sie den `svg`-Block auf oberster Ebene hinzu und verwenden Sie anschließend `translate-svg` (wird auch über `sync` ausgeführt, wenn beide aktiviert sind).
|
|
18
|
+
|
|
19
|
+
Beide Workflows teilen sich eine einzige `ai-i18n-tools.config.json`-Datei und können unabhängig oder zusammen verwendet werden. Die eigenständige SVG-Übersetzung nutzt `features.translateSVG` zusammen mit dem `svg`-Block auf oberster Ebene und wird über `translate-svg` ausgeführt (oder über die SVG-Phase innerhalb von `sync`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Das veröffentlichte Paket ist **ESM-only** (`"type": "module"`). Verwende `import` aus Node.js, Bundlern oder `import()` — **`require('ai-i18n-tools')` wird nicht unterstützt.**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install ai-i18n-tools
|
|
29
|
+
# or
|
|
30
|
+
pnpm add ai-i18n-tools
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Setze deinen OpenRouter API-Schlüssel:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Schnellstart
|
|
42
|
+
|
|
43
|
+
### Arbeitsablauf 1 - UI-Strings
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. Create config
|
|
47
|
+
npx ai-i18n-tools init
|
|
48
|
+
|
|
49
|
+
# 2. Extract t("…") calls from source
|
|
50
|
+
npx ai-i18n-tools extract
|
|
51
|
+
|
|
52
|
+
# 3. Translate to all target locales
|
|
53
|
+
npx ai-i18n-tools translate-ui
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Integriere i18next in deiner App mithilfe der Helfer aus `'ai-i18n-tools/runtime'`:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import i18n from 'i18next';
|
|
60
|
+
import { initReactI18next } from 'react-i18next';
|
|
61
|
+
import uiLanguages from './locales/ui-languages.json';
|
|
62
|
+
import {
|
|
63
|
+
defaultI18nInitOptions,
|
|
64
|
+
wrapI18nWithKeyTrim,
|
|
65
|
+
makeLoadLocale,
|
|
66
|
+
applyDirection,
|
|
67
|
+
} from 'ai-i18n-tools/runtime';
|
|
68
|
+
|
|
69
|
+
// Must match sourceLocale in ai-i18n-tools.config.json
|
|
70
|
+
export const SOURCE_LOCALE = 'en-GB';
|
|
71
|
+
|
|
72
|
+
void i18n.use(initReactI18next).init(defaultI18nInitOptions(SOURCE_LOCALE));
|
|
73
|
+
wrapI18nWithKeyTrim(i18n);
|
|
74
|
+
i18n.on('languageChanged', applyDirection);
|
|
75
|
+
applyDirection(i18n.language);
|
|
76
|
+
|
|
77
|
+
const localeLoaders = Object.fromEntries(
|
|
78
|
+
uiLanguages
|
|
79
|
+
.filter(({ code }) => code !== SOURCE_LOCALE)
|
|
80
|
+
.map(({ code }) => [code, () => import(`./locales/${code}.json`)])
|
|
81
|
+
);
|
|
82
|
+
export const loadLocale = makeLoadLocale(i18n, localeLoaders, SOURCE_LOCALE);
|
|
83
|
+
export default i18n;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Arbeitsablauf 2 - Dokumentation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Create config for Docusaurus
|
|
90
|
+
npx ai-i18n-tools init -t ui-docusaurus
|
|
91
|
+
|
|
92
|
+
# 2. Translate all docs
|
|
93
|
+
npx ai-i18n-tools translate-docs
|
|
94
|
+
|
|
95
|
+
# 3. Check status
|
|
96
|
+
npx ai-i18n-tools status
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Beide Arbeitsabläufe
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx ai-i18n-tools sync # Extract UI strings, then translate UI strings, SVG, and docs
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Laufzeit-Helfer
|
|
108
|
+
|
|
109
|
+
Exportiert aus `'ai-i18n-tools/runtime'` - funktioniert in jeder JS-Umgebung, kein i18next-Import erforderlich:
|
|
110
|
+
|
|
111
|
+
| Helfer | Beschreibung |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `defaultI18nInitOptions(sourceLocale)` | Standard-i18next-Init-Optionen für Key-as-Default-Setups. |
|
|
114
|
+
| `wrapI18nWithKeyTrim(i18n)` | Wickelt `i18n.t` so, dass Schlüssel vor der Suche getrimmt werden. |
|
|
115
|
+
| `makeLoadLocale(i18n, loaders, sourceLocale)` | Fabrik für das asynchrone Laden von Locale-Dateien. |
|
|
116
|
+
| `getTextDirection(lng)` | Gibt `'ltr'` oder `'rtl'` für einen BCP-47-Code zurück. |
|
|
117
|
+
| `applyDirection(lng, element?)` | Setzt das `dir`-Attribut auf `document.documentElement`. |
|
|
118
|
+
| `getUILanguageLabel(lang, t)` | Anzeige-Label für eine Sprachmenüzeile (mit i18n). |
|
|
119
|
+
| `getUILanguageLabelNative(lang)` | Anzeige-Label ohne Aufruf von `t()` (Header-Stil). |
|
|
120
|
+
| `interpolateTemplate(str, vars)` | Niedrigstufige `{{var}}`-Substitution auf einem einfachen String (intern verwendet; Anwendungs-Code sollte stattdessen `t()` verwenden). |
|
|
121
|
+
| `flipUiArrowsForRtl(text, isRtl)` | Dreht `→` zu `←` für RTL-Layouts. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## CLI-Befehle
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
ai-i18n-tools init [-t ui-markdown|ui-docusaurus] Create config file
|
|
129
|
+
ai-i18n-tools extract Scan source for t("…") calls
|
|
130
|
+
ai-i18n-tools translate-docs [--locale <code>] Translate documentation (markdown, JSON); see docs for
|
|
131
|
+
--force-update, --force, --stats, --clear-cache,
|
|
132
|
+
--prompt-format (xml | json-array | json-object)
|
|
133
|
+
ai-i18n-tools translate-svg [--locale <code>] Standalone SVG assets (features.translateSVG + config.svg); see --no-cache
|
|
134
|
+
ai-i18n-tools translate-ui [--locale <code>] Translate UI strings only; see --force, --dry-run
|
|
135
|
+
ai-i18n-tools export-ui-xliff [--locale <code>] Export UI strings to XLIFF 2.0 (one file per locale); see --untranslated-only, -o
|
|
136
|
+
ai-i18n-tools sync Extract UI strings, then translate UI strings, SVG, and docs
|
|
137
|
+
ai-i18n-tools status Translation status per file × locale
|
|
138
|
+
ai-i18n-tools editor Open cache/glossary web editor
|
|
139
|
+
ai-i18n-tools cleanup [--dry-run] [--no-backup] [--backup <path>] Runs sync --force-update, then cleans stale + orphaned cache rows; backs up SQLite by default
|
|
140
|
+
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Alle Befehle akzeptieren `-c <config>` (Standard: `ai-i18n-tools.config.json`), `-v` (ausführlich) und optional `-w` / `--write-logs [path]`, um die Konsolenausgabe in eine Protokolldatei anzuhängen (Standard: im Verzeichnis des Übersetzungscaches).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Dokumentation
|
|
148
|
+
|
|
149
|
+
- [Erste Schritte](docs/GETTING_STARTED.de.md) - vollständige Einrichtungsanleitung für beide Workflows, alle CLI-Flags und Referenz der Konfigurationsfelder.
|
|
150
|
+
- [Paketübersicht](docs/PACKAGE_OVERVIEW.de.md) - Architektur, interne Abläufe, programmgesteuerte API und Erweiterungspunkte.
|
|
151
|
+
- [AI-Agent-Kontext](../docs/ai-i18n-tools-context.md) - prägnanter Projektkontext für Agenten und Wartende, die Code- oder Konfigurationsänderungen vornehmen.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Lizenz
|
|
156
|
+
|
|
157
|
+
MIT © [Waldemar Scudeller Jr.](https://github.com/wsj-br)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# herramientas-ai-i18n
|
|
2
|
+
|
|
3
|
+
Kit de herramientas CLI y programático para internacionalizar aplicaciones y sitios de documentación en JavaScript/TypeScript. Extrae cadenas de interfaz de usuario, las traduce con modelos de lenguaje grande (LLM) a través de OpenRouter y genera archivos JSON listos para cada idioma para i18next, además de pipelines para markdown, JSON de Docusaurus y (mediante `features.translateSVG`, `translate-svg` y el bloque `svg`) activos SVG independientes.
|
|
4
|
+
|
|
5
|
+
<small>**Leer en otros idiomas:** </small>
|
|
6
|
+
|
|
7
|
+
<small id="lang-list">[en-GB](../README.md) · [de](./README.de.md) · [es](./README.es.md) · [fr](./README.fr.md) · [hi](./README.hi.md) · [ja](./README.ja.md) · [ko](./README.ko.md) · [pt-BR](./README.pt-BR.md) · [zh-CN](./README.zh-CN.md) · [zh-TW](./README.zh-TW.md)</small>
|
|
8
|
+
|
|
9
|
+
## Dos flujos de trabajo principales
|
|
10
|
+
|
|
11
|
+
**Flujo de trabajo 1 - Traducción de UI** (React, Next.js, Node.js, cualquier proyecto i18next)
|
|
12
|
+
|
|
13
|
+
Escanea archivos fuente en busca de llamadas `t("…")`, construye un catálogo maestro (`strings.json` con metadatos **`models`** opcionales por localidad), traduce entradas faltantes por localidad a través de OpenRouter y escribe archivos JSON planos (`de.json`, `pt-BR.json`, …) listos para i18next.
|
|
14
|
+
|
|
15
|
+
**Flujo de trabajo 2 - Traducción de documentos** (Markdown, JSON de Docusaurus)
|
|
16
|
+
|
|
17
|
+
Traduce archivos `.md` y `.mdx` desde los `contentPaths` de cada bloque `documentations` y archivos JSON de etiquetas desde el `jsonSource` de ese bloque cuando está habilitado. Admite diseños con sufijo de idioma estilo Docusaurus y planos por bloque (`documentations[].markdownOutput`). El `cacheDir` raíz compartido contiene la caché SQLite para que solo se envíen al LLM segmentos nuevos o modificados. **SVG:** habilite `features.translateSVG`, agregue el bloque `svg` de nivel superior, luego use `translate-svg` (también se ejecuta desde `sync` cuando ambos están configurados).
|
|
18
|
+
|
|
19
|
+
Ambos flujos de trabajo comparten un único archivo `ai-i18n-tools.config.json` y pueden usarse de forma independiente o conjunta. La traducción independiente de SVG utiliza `features.translateSVG` junto con el bloque `svg` de nivel superior y se ejecuta mediante `translate-svg` (o la etapa SVG dentro de `sync`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Instalación
|
|
24
|
+
|
|
25
|
+
El paquete publicado es **solo ESM** (`"type": "module"`). Usa `import` desde Node.js, empaquetadores o `import()` — **`require('ai-i18n-tools')` no es compatible.**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install ai-i18n-tools
|
|
29
|
+
# or
|
|
30
|
+
pnpm add ai-i18n-tools
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Establece tu clave API de OpenRouter:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Inicio rápido
|
|
42
|
+
|
|
43
|
+
### Flujo de trabajo 1 - Cadenas de UI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. Create config
|
|
47
|
+
npx ai-i18n-tools init
|
|
48
|
+
|
|
49
|
+
# 2. Extract t("…") calls from source
|
|
50
|
+
npx ai-i18n-tools extract
|
|
51
|
+
|
|
52
|
+
# 3. Translate to all target locales
|
|
53
|
+
npx ai-i18n-tools translate-ui
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Conecta i18next en tu aplicación utilizando los ayudantes de `'ai-i18n-tools/runtime'`:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import i18n from 'i18next';
|
|
60
|
+
import { initReactI18next } from 'react-i18next';
|
|
61
|
+
import uiLanguages from './locales/ui-languages.json';
|
|
62
|
+
import {
|
|
63
|
+
defaultI18nInitOptions,
|
|
64
|
+
wrapI18nWithKeyTrim,
|
|
65
|
+
makeLoadLocale,
|
|
66
|
+
applyDirection,
|
|
67
|
+
} from 'ai-i18n-tools/runtime';
|
|
68
|
+
|
|
69
|
+
// Must match sourceLocale in ai-i18n-tools.config.json
|
|
70
|
+
export const SOURCE_LOCALE = 'en-GB';
|
|
71
|
+
|
|
72
|
+
void i18n.use(initReactI18next).init(defaultI18nInitOptions(SOURCE_LOCALE));
|
|
73
|
+
wrapI18nWithKeyTrim(i18n);
|
|
74
|
+
i18n.on('languageChanged', applyDirection);
|
|
75
|
+
applyDirection(i18n.language);
|
|
76
|
+
|
|
77
|
+
const localeLoaders = Object.fromEntries(
|
|
78
|
+
uiLanguages
|
|
79
|
+
.filter(({ code }) => code !== SOURCE_LOCALE)
|
|
80
|
+
.map(({ code }) => [code, () => import(`./locales/${code}.json`)])
|
|
81
|
+
);
|
|
82
|
+
export const loadLocale = makeLoadLocale(i18n, localeLoaders, SOURCE_LOCALE);
|
|
83
|
+
export default i18n;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Flujo de trabajo 2 - Documentación
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Create config for Docusaurus
|
|
90
|
+
npx ai-i18n-tools init -t ui-docusaurus
|
|
91
|
+
|
|
92
|
+
# 2. Translate all docs
|
|
93
|
+
npx ai-i18n-tools translate-docs
|
|
94
|
+
|
|
95
|
+
# 3. Check status
|
|
96
|
+
npx ai-i18n-tools status
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Ambos flujos de trabajo
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx ai-i18n-tools sync # Extract UI strings, then translate UI strings, SVG, and docs
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Ayudantes de tiempo de ejecución
|
|
108
|
+
|
|
109
|
+
Exportados de `'ai-i18n-tools/runtime'` - funcionan en cualquier entorno JS, no se requiere importación de i18next:
|
|
110
|
+
|
|
111
|
+
| Ayudante | Descripción |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `defaultI18nInitOptions(sourceLocale)` | Opciones de inicialización estándar de i18next para configuraciones de clave como predeterminadas. |
|
|
114
|
+
| `wrapI18nWithKeyTrim(i18n)` | Envuelve `i18n.t` para que las claves se recorten antes de la búsqueda. |
|
|
115
|
+
| `makeLoadLocale(i18n, loaders, sourceLocale)` | Fábrica para la carga asíncrona de archivos de localidad. |
|
|
116
|
+
| `getTextDirection(lng)` | Devuelve `'ltr'` o `'rtl'` para un código BCP-47. |
|
|
117
|
+
| `applyDirection(lng, element?)` | Establece el atributo `dir` en `document.documentElement`. |
|
|
118
|
+
| `getUILanguageLabel(lang, t)` | Etiqueta de visualización para una fila de menú de idioma (con i18n). |
|
|
119
|
+
| `getUILanguageLabelNative(lang)` | Etiqueta de visualización sin llamar a `t()` (estilo encabezado). |
|
|
120
|
+
| `interpolateTemplate(str, vars)` | Sustitución de bajo nivel `{{var}}` en una cadena simple (usado internamente; el código de la aplicación debe usar `t()` en su lugar). |
|
|
121
|
+
| `flipUiArrowsForRtl(text, isRtl)` | Invierte `→` a `←` para diseños RTL. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Comandos de CLI
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
ai-i18n-tools init [-t ui-markdown|ui-docusaurus] Create config file
|
|
129
|
+
ai-i18n-tools extract Scan source for t("…") calls
|
|
130
|
+
ai-i18n-tools translate-docs [--locale <code>] Translate documentation (markdown, JSON); see docs for
|
|
131
|
+
--force-update, --force, --stats, --clear-cache,
|
|
132
|
+
--prompt-format (xml | json-array | json-object)
|
|
133
|
+
ai-i18n-tools translate-svg [--locale <code>] Standalone SVG assets (features.translateSVG + config.svg); see --no-cache
|
|
134
|
+
ai-i18n-tools translate-ui [--locale <code>] Translate UI strings only; see --force, --dry-run
|
|
135
|
+
ai-i18n-tools export-ui-xliff [--locale <code>] Export UI strings to XLIFF 2.0 (one file per locale); see --untranslated-only, -o
|
|
136
|
+
ai-i18n-tools sync Extract UI strings, then translate UI strings, SVG, and docs
|
|
137
|
+
ai-i18n-tools status Translation status per file × locale
|
|
138
|
+
ai-i18n-tools editor Open cache/glossary web editor
|
|
139
|
+
ai-i18n-tools cleanup [--dry-run] [--no-backup] [--backup <path>] Runs sync --force-update, then cleans stale + orphaned cache rows; backs up SQLite by default
|
|
140
|
+
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Todos los comandos aceptan `-c <config>` (predeterminado: `ai-i18n-tools.config.json`), `-v` (detallado), y opcionalmente `-w` / `--write-logs [ruta]` para añadir la salida de la consola a un archivo de registro (predeterminado: en el directorio de caché de traducción).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Documentación
|
|
148
|
+
|
|
149
|
+
- [Introducción](docs/GETTING_STARTED.es.md) - guía completa de configuración para ambos flujos de trabajo, todas las banderas de CLI y referencia de campos de configuración.
|
|
150
|
+
- [Descripción del Paquete](docs/PACKAGE_OVERVIEW.es.md) - arquitectura, internos, API programática y puntos de extensión.
|
|
151
|
+
- [Contexto del Agente de IA](../docs/ai-i18n-tools-context.md) - contexto conciso del proyecto para agentes y mantenedores que realizan cambios en el código o la configuración.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Licencia
|
|
156
|
+
|
|
157
|
+
MIT © [Waldemar Scudeller Jr.](https://github.com/wsj-br)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# ai-i18n-tools
|
|
2
|
+
|
|
3
|
+
Outil en ligne de commande et programme pour l'internationalisation d'applications JavaScript/TypeScript et de sites de documentation. Extrait les chaînes d'interface utilisateur, les traduit à l'aide de modèles linguistiques (LLM) via OpenRouter, puis génère des fichiers JSON prêts pour les paramètres régionaux destinés à i18next, ainsi que des pipelines pour le markdown, le JSON Docusaurus et (via `features.translateSVG`, `translate-svg` et le bloc `svg`) des ressources SVG autonomes.
|
|
4
|
+
|
|
5
|
+
<small>**Lire dans d'autres langues :** </small>
|
|
6
|
+
|
|
7
|
+
<small id="lang-list">[en-GB](../README.md) · [de](./README.de.md) · [es](./README.es.md) · [fr](./README.fr.md) · [hi](./README.hi.md) · [ja](./README.ja.md) · [ko](./README.ko.md) · [pt-BR](./README.pt-BR.md) · [zh-CN](./README.zh-CN.md) · [zh-TW](./README.zh-TW.md)</small>
|
|
8
|
+
|
|
9
|
+
## Deux flux de travail principaux
|
|
10
|
+
|
|
11
|
+
**Flux de travail 1 - Traduction de l'UI** (React, Next.js, Node.js, tout projet i18next)
|
|
12
|
+
|
|
13
|
+
Analyse les fichiers source pour les appels `t("…")`, construit un catalogue maître (`strings.json` avec des métadonnées **`models`** optionnelles par locale), traduit les entrées manquantes par locale via OpenRouter, et écrit des fichiers JSON plats (`de.json`, `pt-BR.json`, …) prêts pour i18next.
|
|
14
|
+
|
|
15
|
+
**Flux de travail 2 - Traduction de documents** (Markdown, Docusaurus JSON)
|
|
16
|
+
|
|
17
|
+
Traduit les fichiers `.md` et `.mdx` à partir des `contentPaths` de chaque bloc `documentations` et les fichiers JSON d'étiquettes à partir du `jsonSource` de ce bloc lorsque cette fonction est activée. Prend en charge les structures de dossiers localisés au style Docusaurus ou plates, par bloc (`documentations[].markdownOutput`). Le `cacheDir` racine partagé contient le cache SQLite afin que seuls les segments nouveaux ou modifiés soient envoyés au LLM. **SVG :** activez `features.translateSVG`, ajoutez le bloc `svg` au niveau supérieur, puis utilisez `translate-svg` (également exécuté depuis `sync` lorsque les deux sont configurés).
|
|
18
|
+
|
|
19
|
+
Les deux flux de travail partagent un seul fichier `ai-i18n-tools.config.json` et peuvent être utilisés indépendamment ou conjointement. La traduction SVG autonome utilise `features.translateSVG` ainsi que le bloc `svg` au niveau supérieur et s'exécute via `translate-svg` (ou l'étape SVG à l'intérieur de `sync`).
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
Le package publié est **uniquement ESM** (`"type": "module"`). Utilisez `import` depuis Node.js, des bundlers, ou `import()` — **`require('ai-i18n-tools')` n'est pas pris en charge.**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install ai-i18n-tools
|
|
29
|
+
# or
|
|
30
|
+
pnpm add ai-i18n-tools
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Définissez votre clé API OpenRouter :
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Démarrage rapide
|
|
42
|
+
|
|
43
|
+
### Flux de travail 1 - Chaînes UI
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. Create config
|
|
47
|
+
npx ai-i18n-tools init
|
|
48
|
+
|
|
49
|
+
# 2. Extract t("…") calls from source
|
|
50
|
+
npx ai-i18n-tools extract
|
|
51
|
+
|
|
52
|
+
# 3. Translate to all target locales
|
|
53
|
+
npx ai-i18n-tools translate-ui
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Connectez i18next dans votre application en utilisant les helpers de `'ai-i18n-tools/runtime'` :
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import i18n from 'i18next';
|
|
60
|
+
import { initReactI18next } from 'react-i18next';
|
|
61
|
+
import uiLanguages from './locales/ui-languages.json';
|
|
62
|
+
import {
|
|
63
|
+
defaultI18nInitOptions,
|
|
64
|
+
wrapI18nWithKeyTrim,
|
|
65
|
+
makeLoadLocale,
|
|
66
|
+
applyDirection,
|
|
67
|
+
} from 'ai-i18n-tools/runtime';
|
|
68
|
+
|
|
69
|
+
// Must match sourceLocale in ai-i18n-tools.config.json
|
|
70
|
+
export const SOURCE_LOCALE = 'en-GB';
|
|
71
|
+
|
|
72
|
+
void i18n.use(initReactI18next).init(defaultI18nInitOptions(SOURCE_LOCALE));
|
|
73
|
+
wrapI18nWithKeyTrim(i18n);
|
|
74
|
+
i18n.on('languageChanged', applyDirection);
|
|
75
|
+
applyDirection(i18n.language);
|
|
76
|
+
|
|
77
|
+
const localeLoaders = Object.fromEntries(
|
|
78
|
+
uiLanguages
|
|
79
|
+
.filter(({ code }) => code !== SOURCE_LOCALE)
|
|
80
|
+
.map(({ code }) => [code, () => import(`./locales/${code}.json`)])
|
|
81
|
+
);
|
|
82
|
+
export const loadLocale = makeLoadLocale(i18n, localeLoaders, SOURCE_LOCALE);
|
|
83
|
+
export default i18n;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Flux de travail 2 - Documentation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Create config for Docusaurus
|
|
90
|
+
npx ai-i18n-tools init -t ui-docusaurus
|
|
91
|
+
|
|
92
|
+
# 2. Translate all docs
|
|
93
|
+
npx ai-i18n-tools translate-docs
|
|
94
|
+
|
|
95
|
+
# 3. Check status
|
|
96
|
+
npx ai-i18n-tools status
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Les deux flux de travail
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx ai-i18n-tools sync # Extract UI strings, then translate UI strings, SVG, and docs
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Helpers d'exécution
|
|
108
|
+
|
|
109
|
+
Exportés de `'ai-i18n-tools/runtime'` - fonctionnent dans n'importe quel environnement JS, aucune importation i18next requise :
|
|
110
|
+
|
|
111
|
+
| Helper | Description |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `defaultI18nInitOptions(sourceLocale)` | Options d'initialisation standard i18next pour les configurations clé-comme-par-défaut. |
|
|
114
|
+
| `wrapI18nWithKeyTrim(i18n)` | Enveloppe `i18n.t` afin que les clés soient tronquées avant la recherche. |
|
|
115
|
+
| `makeLoadLocale(i18n, loaders, sourceLocale)` | Fabrique pour le chargement asynchrone de fichiers de locale. |
|
|
116
|
+
| `getTextDirection(lng)` | Renvoie `'ltr'` ou `'rtl'` pour un code BCP-47. |
|
|
117
|
+
| `applyDirection(lng, element?)` | Définit l'attribut `dir` sur `document.documentElement`. |
|
|
118
|
+
| `getUILanguageLabel(lang, t)` | Étiquette d'affichage pour une ligne de menu de langue (avec i18n). |
|
|
119
|
+
| `getUILanguageLabelNative(lang)` | Étiquette d'affichage sans appeler `t()` (style en-tête). |
|
|
120
|
+
| `interpolateTemplate(str, vars)` | Substitution de bas niveau `{{var}}` sur une chaîne simple (utilisé en interne ; le code de l'application doit utiliser `t()` à la place). |
|
|
121
|
+
| `flipUiArrowsForRtl(text, isRtl)` | Retourne `→` à `←` pour les mises en page RTL. |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Commandes CLI
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
ai-i18n-tools init [-t ui-markdown|ui-docusaurus] Create config file
|
|
129
|
+
ai-i18n-tools extract Scan source for t("…") calls
|
|
130
|
+
ai-i18n-tools translate-docs [--locale <code>] Translate documentation (markdown, JSON); see docs for
|
|
131
|
+
--force-update, --force, --stats, --clear-cache,
|
|
132
|
+
--prompt-format (xml | json-array | json-object)
|
|
133
|
+
ai-i18n-tools translate-svg [--locale <code>] Standalone SVG assets (features.translateSVG + config.svg); see --no-cache
|
|
134
|
+
ai-i18n-tools translate-ui [--locale <code>] Translate UI strings only; see --force, --dry-run
|
|
135
|
+
ai-i18n-tools export-ui-xliff [--locale <code>] Export UI strings to XLIFF 2.0 (one file per locale); see --untranslated-only, -o
|
|
136
|
+
ai-i18n-tools sync Extract UI strings, then translate UI strings, SVG, and docs
|
|
137
|
+
ai-i18n-tools status Translation status per file × locale
|
|
138
|
+
ai-i18n-tools editor Open cache/glossary web editor
|
|
139
|
+
ai-i18n-tools cleanup [--dry-run] [--no-backup] [--backup <path>] Runs sync --force-update, then cleans stale + orphaned cache rows; backs up SQLite by default
|
|
140
|
+
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Toutes les commandes acceptent `-c <config>` (par défaut : `ai-i18n-tools.config.json`), `-v` (verbose), et l'optionnel `-w` / `--write-logs [path]` pour ajouter la sortie de la console à un fichier journal (par défaut : sous le répertoire de cache de traduction).
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Documentation
|
|
148
|
+
|
|
149
|
+
- [Commencer](docs/GETTING_STARTED.fr.md) - guide complet de configuration pour les deux flux de travail, tous les drapeaux CLI et référence des champs de configuration.
|
|
150
|
+
- [Aperçu du package](docs/PACKAGE_OVERVIEW.fr.md) - architecture, internes, API programmatique et points d'extension.
|
|
151
|
+
- [Contexte de l'agent IA](../docs/ai-i18n-tools-context.md) - contexte de projet concis pour les agents et les mainteneurs effectuant des modifications de code ou de configuration.
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Licence
|
|
156
|
+
|
|
157
|
+
MIT © [Waldemar Scudeller Jr.](https://github.com/wsj-br)
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# ai-i18n-tools
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript अनुप्रयोगों और दस्तावेज़ीकरण साइटों के लिए अंतरराष्ट्रीयकरण के लिए CLI और प्रोग्रामेटिक टूलकिट। UI स्ट्रिंग्स निकालता है, OpenRouter के माध्यम से LLMs के साथ उनका अनुवाद करता है, और i18next के लिए भाषा-तैयार JSON फ़ाइलें उत्पन्न करता है, साथ ही मार्कडाउन, डॉक्यूसॉरस JSON के लिए पाइपलाइन, और ( `features.translateSVG`, `translate-svg` और `svg` ब्लॉक के माध्यम से) स्वतंत्र SVG एसेट्स के लिए।
|
|
4
|
+
|
|
5
|
+
<small>**अन्य भाषाओं में पढ़ें:** </small>
|
|
6
|
+
|
|
7
|
+
<small id="lang-list">[en-GB](../README.md) · [de](./README.de.md) · [es](./README.es.md) · [fr](./README.fr.md) · [hi](./README.hi.md) · [ja](./README.ja.md) · [ko](./README.ko.md) · [pt-BR](./README.pt-BR.md) · [zh-CN](./README.zh-CN.md) · [zh-TW](./README.zh-TW.md)</small>
|
|
8
|
+
|
|
9
|
+
## दो मुख्य कार्यप्रवाह
|
|
10
|
+
|
|
11
|
+
**कार्यप्रवाह 1 - UI अनुवाद** (React, Next.js, Node.js, कोई भी i18next प्रोजेक्ट)
|
|
12
|
+
|
|
13
|
+
स्रोत फ़ाइलों में `t("…")` कॉल के लिए स्कैन करता है, एक मास्टर कैटलॉग (`strings.json` वैकल्पिक प्रति-स्थानीय **`models`** मेटाडेटा के साथ) बनाता है, OpenRouter के माध्यम से प्रति स्थानीयता गायब प्रविष्टियों का अनुवाद करता है, और i18next के लिए तैयार फ्लैट JSON फ़ाइलें (`de.json`, `pt-BR.json`, …) लिखता है।
|
|
14
|
+
|
|
15
|
+
**कार्यप्रवाह 2 - दस्तावेज़ अनुवाद** (Markdown, Docusaurus JSON)
|
|
16
|
+
|
|
17
|
+
जब सक्षम हो, तो प्रत्येक `documentations` ब्लॉक के `contentPaths` से `.md` और `.mdx` और उस ब्लॉक के `jsonSource` से JSON लेबल फ़ाइलों का अनुवाद करता है। प्रत्येक ब्लॉक के लिए Docusaurus-शैली और सपाट भाषा-उपसर्गित लेआउट का समर्थन करता है (`documentations[].markdownOutput`)। साझा मूल `cacheDir` में SQLite कैशे रखा जाता है ताकि केवल नए या बदले गए खंडों को LLM को भेजा जाए। **SVG:** `features.translateSVG` सक्षम करें, शीर्ष-स्तरीय `svg` ब्लॉक जोड़ें, फिर `translate-svg` का उपयोग करें (जब दोनों सेट हों तो `sync` से भी चलाएं)।
|
|
18
|
+
|
|
19
|
+
दोनों कार्यप्रवाह एकल `ai-i18n-tools.config.json` फ़ाइल साझा करते हैं और स्वतंत्र रूप से या एक साथ उपयोग किए जा सकते हैं। स्वतंत्र SVG अनुवाद `features.translateSVG` और शीर्ष-स्तरीय `svg` ब्लॉक का उपयोग करता है और `translate-svg` (या `sync` के भीतर SVG चरण) के माध्यम से चलता है।
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## स्थापना
|
|
24
|
+
|
|
25
|
+
प्रकाशित पैकेज **ESM-केवल** है (`"type": "module"`)। Node.js, बंडलर्स, या `import()` से `import` का उपयोग करें — **`require('ai-i18n-tools')` का समर्थन नहीं किया जाता है।**
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install ai-i18n-tools
|
|
29
|
+
# or
|
|
30
|
+
pnpm add ai-i18n-tools
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
अपनी OpenRouter API कुंजी सेट करें:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export OPENROUTER_API_KEY=sk-or-v1-your-key-here
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## त्वरित प्रारंभ
|
|
42
|
+
|
|
43
|
+
### कार्यप्रवाह 1 - UI स्ट्रिंग्स
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 1. Create config
|
|
47
|
+
npx ai-i18n-tools init
|
|
48
|
+
|
|
49
|
+
# 2. Extract t("…") calls from source
|
|
50
|
+
npx ai-i18n-tools extract
|
|
51
|
+
|
|
52
|
+
# 3. Translate to all target locales
|
|
53
|
+
npx ai-i18n-tools translate-ui
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
अपने ऐप में `'ai-i18n-tools/runtime'` से सहायक फ़ंक्शंस का उपयोग करके i18next को कनेक्ट करें:
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
import i18n from 'i18next';
|
|
60
|
+
import { initReactI18next } from 'react-i18next';
|
|
61
|
+
import uiLanguages from './locales/ui-languages.json';
|
|
62
|
+
import {
|
|
63
|
+
defaultI18nInitOptions,
|
|
64
|
+
wrapI18nWithKeyTrim,
|
|
65
|
+
makeLoadLocale,
|
|
66
|
+
applyDirection,
|
|
67
|
+
} from 'ai-i18n-tools/runtime';
|
|
68
|
+
|
|
69
|
+
// Must match sourceLocale in ai-i18n-tools.config.json
|
|
70
|
+
export const SOURCE_LOCALE = 'en-GB';
|
|
71
|
+
|
|
72
|
+
void i18n.use(initReactI18next).init(defaultI18nInitOptions(SOURCE_LOCALE));
|
|
73
|
+
wrapI18nWithKeyTrim(i18n);
|
|
74
|
+
i18n.on('languageChanged', applyDirection);
|
|
75
|
+
applyDirection(i18n.language);
|
|
76
|
+
|
|
77
|
+
const localeLoaders = Object.fromEntries(
|
|
78
|
+
uiLanguages
|
|
79
|
+
.filter(({ code }) => code !== SOURCE_LOCALE)
|
|
80
|
+
.map(({ code }) => [code, () => import(`./locales/${code}.json`)])
|
|
81
|
+
);
|
|
82
|
+
export const loadLocale = makeLoadLocale(i18n, localeLoaders, SOURCE_LOCALE);
|
|
83
|
+
export default i18n;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### कार्यप्रवाह 2 - दस्तावेज़ीकरण
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# 1. Create config for Docusaurus
|
|
90
|
+
npx ai-i18n-tools init -t ui-docusaurus
|
|
91
|
+
|
|
92
|
+
# 2. Translate all docs
|
|
93
|
+
npx ai-i18n-tools translate-docs
|
|
94
|
+
|
|
95
|
+
# 3. Check status
|
|
96
|
+
npx ai-i18n-tools status
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### दोनों कार्यप्रवाह
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npx ai-i18n-tools sync # Extract UI strings, then translate UI strings, SVG, and docs
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## रनटाइम सहायक
|
|
108
|
+
|
|
109
|
+
`'ai-i18n-tools/runtime'` से निर्यातित - किसी भी JS वातावरण में काम करता है, i18next आयात की आवश्यकता नहीं है:
|
|
110
|
+
|
|
111
|
+
| सहायक | विवरण |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `defaultI18nInitOptions(sourceLocale)` | कुंजी-के-डिफ़ॉल्ट सेटअप के लिए मानक i18next प्रारंभ विकल्प। |
|
|
114
|
+
| `wrapI18nWithKeyTrim(i18n)` | `i18n.t` को लपेटता है ताकि कुंजी खोज से पहले ट्रिम की जाए। |
|
|
115
|
+
| `makeLoadLocale(i18n, loaders, sourceLocale)` | असिंक्रोनस स्थानीय फ़ाइल लोडिंग के लिए फैक्ट्री। |
|
|
116
|
+
| `getTextDirection(lng)` | एक BCP-47 कोड के लिए `'ltr'` या `'rtl'` लौटाता है। |
|
|
117
|
+
| `applyDirection(lng, element?)` | `document.documentElement` पर `dir` विशेषता सेट करता है। |
|
|
118
|
+
| `getUILanguageLabel(lang, t)` | एक भाषा मेनू पंक्ति के लिए प्रदर्शित लेबल (i18n के साथ)। |
|
|
119
|
+
| `getUILanguageLabelNative(lang)` | `t()` को कॉल किए बिना प्रदर्शित लेबल (हेडर-शैली)। |
|
|
120
|
+
| `interpolateTemplate(str, vars)` | एक साधारण स्ट्रिंग पर निम्न-स्तरीय `{{var}}` प्रतिस्थापन (आंतरिक रूप से उपयोग किया जाता है; ऐप कोड को इसके बजाय `t()` का उपयोग करना चाहिए)। |
|
|
121
|
+
| `flipUiArrowsForRtl(text, isRtl)` | RTL लेआउट के लिए `→` को `←` में पलटता है। |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## CLI कमांड
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
ai-i18n-tools init [-t ui-markdown|ui-docusaurus] Create config file
|
|
129
|
+
ai-i18n-tools extract Scan source for t("…") calls
|
|
130
|
+
ai-i18n-tools translate-docs [--locale <code>] Translate documentation (markdown, JSON); see docs for
|
|
131
|
+
--force-update, --force, --stats, --clear-cache,
|
|
132
|
+
--prompt-format (xml | json-array | json-object)
|
|
133
|
+
ai-i18n-tools translate-svg [--locale <code>] Standalone SVG assets (features.translateSVG + config.svg); see --no-cache
|
|
134
|
+
ai-i18n-tools translate-ui [--locale <code>] Translate UI strings only; see --force, --dry-run
|
|
135
|
+
ai-i18n-tools export-ui-xliff [--locale <code>] Export UI strings to XLIFF 2.0 (one file per locale); see --untranslated-only, -o
|
|
136
|
+
ai-i18n-tools sync Extract UI strings, then translate UI strings, SVG, and docs
|
|
137
|
+
ai-i18n-tools status Translation status per file × locale
|
|
138
|
+
ai-i18n-tools editor Open cache/glossary web editor
|
|
139
|
+
ai-i18n-tools cleanup [--dry-run] [--no-backup] [--backup <path>] Runs sync --force-update, then cleans stale + orphaned cache rows; backs up SQLite by default
|
|
140
|
+
ai-i18n-tools glossary-generate Create empty glossary CSV template
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
सभी कमांड `-c <config>` (डिफ़ॉल्ट: `ai-i18n-tools.config.json`), `-v` (विस्तृत), और वैकल्पिक `-w` / `--write-logs [path]` को स्वीकार करते हैं ताकि कंसोल आउटपुट को लॉग फ़ाइल में जोड़ा जा सके (डिफ़ॉल्ट: अनुवाद कैश निर्देशिका के तहत)।
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## दस्तावेज़ीकरण
|
|
148
|
+
|
|
149
|
+
- [शुरुआत करना](docs/GETTING_STARTED.hi.md) - दोनों कार्यप्रवाहों के लिए पूर्ण सेटअप गाइड, सभी CLI फ्लैग, और कॉन्फ़िग फ़ील्ड संदर्भ।
|
|
150
|
+
- [पैकेज अवलोकन](docs/PACKAGE_OVERVIEW.hi.md) - आर्किटेक्चर, आंतरिक, प्रोग्रामेटिक API, और एक्सटेंशन पॉइंट्स।
|
|
151
|
+
- [AI एजेंट संदर्भ](../docs/ai-i18n-tools-context.md) - एजेंटों और रखरखाव करने वालों के लिए संक्षिप्त परियोजना संदर्भ जो कोड या कॉन्फ़िग परिवर्तन कर रहे हैं।
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## लाइसेंस
|
|
156
|
+
|
|
157
|
+
MIT © [वाल्डेमर स्कुडेलर जूनियर](https://github.com/wsj-br)
|