@i18n-micro/types-generator
Type generator for i18n-micro translation keys
Entry points: @i18n-micro/types-generator, @i18n-micro/types-generator/nuxt.
@i18n-micro/types-generator
Components
I18nTypesPlugin
A Vite (and Rollup) plugin: generates at build start, and again in dev after a locale file changes.
function I18nTypesPlugin(options: GeneratorOptions): Plugin
See GeneratorOptions
Functions
formatKeyProperty
Emit a TS property name from a translation key. JSON.stringify covers quotes/newlines/null bytes; U+2028/U+2029 need an extra escape so the .d.ts stays safe when embedded in older JS tooling.
function formatKeyProperty(key: string): string
generateTypes
Generates TypeScript types for translation keys from JSON files. Writes the result to a file.
function generateTypes(options: GeneratorOptions): string
Returns — Path to the generated file
See GeneratorOptions
getTypesString
Generates a string with TypeScript types for translation keys. Does not write a file, only returns content.
function getTypesString(options: GeneratorOptions): string
Returns — String with .d.ts file content
See GeneratorOptions
Types
GeneratorOptions
interface GeneratorOptions
srcDir.{locale}.json count, as additionalTranslationDirs of the module.@i18n-micro/types-generator/nuxt
Functions
default
function default(
resolvedOptions: I18nTypesGeneratorOptions,
nuxt: Nuxt,
): ModuleSetupReturn
Types
I18nTypesGeneratorOptions
interface I18nTypesGeneratorOptions
nuxt-i18n-micro reads translations.Generated from the TypeScript sources and their JSDoc by pnpm run docs:generate.
Back to all packages · Integration guides