CLI tool for @svelte-i18n/core. Generates a TypeScript type definition file from a flat JSON translation file, giving you full type-safety and autocompletion on your translation keys.
npx @svelte-i18n/cli generate-types --input <path-or-url>Or install globally:
npm install -g @svelte-i18n/cli
svelte-i18n generate-types --input <path-or-url>Reads a flat JSON translation file (local or remote) and generates an I18nDictionary type containing all the translation keys.
svelte-i18n generate-types --input <path-or-url> [--output <path>]| Option | Description | Default |
|---|---|---|
--input <path> |
Path to a local JSON file or a URL | (required) |
--output <path> |
Path for the generated .d.ts file |
./i18n-types.d.ts |
Examples:
# From a local file
svelte-i18n generate-types --input src/locales/en.json
# From a URL (e.g. a dev server endpoint)
svelte-i18n generate-types --input https://example.com/api/locales/en --output src/i18n-types.d.tsExample output (i18n-types.d.ts):
export type I18nDictionary = {
Dashboard: string;
'Welcome, {firstName} {lastName}!': string;
// ...
};