@verbatra/sdk 0.2.1 → 0.3.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 +4 -4
- package/dist/index.cjs +558 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +192 -58
- package/dist/index.d.ts +192 -58
- package/dist/index.js +554 -69
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -63,20 +63,20 @@ export default defineConfig({
|
|
|
63
63
|
provider: {
|
|
64
64
|
id: "anthropic",
|
|
65
65
|
options: {
|
|
66
|
-
model: "
|
|
66
|
+
model: "claude-sonnet-4-6", // replace with your provider's model id
|
|
67
67
|
maxTokens: 4096,
|
|
68
68
|
},
|
|
69
69
|
},
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
`files.pattern` must contain the `{locale}` token, and `targetLocales` must not include `sourceLocale`; both are enforced when the config is validated. The supported `format` values are `i18next-json`, `vue-i18n-json`, `next-intl-json`, and `ngx-translate-json`. The optional `glossary` (a term map) and `tone` (`"formal"`, `"informal"`, or `"neutral"`) refine the output. OpenAI and Gemini take `{ model, maxOutputTokens }`; DeepL takes `{}` (with an optional `glossaryId`). API keys are never part of the config. Each provider reads its own environment variable (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `DEEPL_API_KEY`).
|
|
73
|
+
`files.pattern` must contain the `{locale}` token, and `targetLocales` must not include `sourceLocale`; both are enforced when the config is validated. The supported `format` values are `i18next-json`, `vue-i18n-json`, `next-intl-json`, and `ngx-translate-json`. The optional `glossary` (a term map) and `tone` (`"formal"`, `"informal"`, or `"neutral"`) refine the output. The optional `prune` boolean (off by default) opts in to removing orphaned keys (present in a target file but absent from the source) from the written target files and the lock; the `translate --prune` flag overrides it per run. The optional `generatePlurals` boolean (off by default) opts in to synthesizing the CLDR plural forms a richer target language requires but the source lacks (i18next-JSON projects translated by an LLM provider only; DeepL, non-i18next formats, and unknown languages fall back to the per-locale plural warning and never fail); a per-run `generatePlurals` override on `translate` takes precedence, and generated keys are reported separately from translated keys on the summary. OpenAI and Gemini take `{ model, maxOutputTokens }`; DeepL takes `{}` (with an optional `glossaryId`). API keys are never part of the config. Each provider reads its own environment variable (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`, `DEEPL_API_KEY`).
|
|
74
74
|
|
|
75
75
|
## API reference
|
|
76
76
|
|
|
77
77
|
### `defineConfig(config)`
|
|
78
78
|
|
|
79
|
-
Returns the config unchanged. It exists purely for type inference and editor autocomplete when authoring a code-defined config.
|
|
79
|
+
Returns the config unchanged. It exists purely for type inference and editor autocomplete when authoring a code-defined config. The `model` field is restricted to the selected provider's known model IDs (sourced from that provider's own SDK), so a model from another provider is a type error at authoring time; the runtime still validates `model` only as a non-empty string, so an unlisted model runs even though the editor flags it.
|
|
80
80
|
|
|
81
81
|
### `loadConfig(options?): Promise<VerbatraConfig>`
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ Discovers and validates the configuration. With no arguments it searches upward
|
|
|
84
84
|
|
|
85
85
|
### `translate(input): Promise<RunSummary>`
|
|
86
86
|
|
|
87
|
-
Runs the one-shot read, diff, translate, write flow over every target locale. `input` is `{ config, cwd?, dryRun? }`. With `dryRun: true` it reads, diffs, and reports without calling the provider or writing anything. Resolves to a `RunSummary` (`dryRun`, `locales`, `succeeded`, and `failed`)
|
|
87
|
+
Runs the one-shot read, diff, translate, write flow over every target locale. `input` is `{ config, cwd?, dryRun?, prune?, generatePlurals? }`. With `dryRun: true` it reads, diffs, and reports without calling the provider or writing anything. `prune` and `generatePlurals` each override the matching config option for this run. Resolves to a `RunSummary` (`dryRun`, `locales`, `succeeded`, and `failed`); each locale summary lists `translated`, `generated`, `pruned`, `integrityMismatches`, and `notices`.
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
90
|
const preview = await translate({ config, dryRun: true });
|