UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

113 lines 4.5 kB
import { Static } from "alepha"; import { ConsoleColorProvider } from "alepha/logger"; import { FileSystemProvider } from "alepha/system"; //#region ../../src/cli/i18n/atoms/i18nOptions.d.ts /** * i18n CLI configuration atom. * * Filled from the `i18n` plugin in `alepha.config.ts`. * Read by `I18nCommand` to drive `alepha i18n check`. */ declare const i18nOptions: import("alepha").Atom<import("zod").ZodOptional<import("zod").ZodObject<{ scan: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>; dynamicPrefixes: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>; exclude: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>; }, import("zod/v4/core").$strip>>, "alepha.cli.i18n.options">; /** * Type for i18n options. */ type I18nOptions = Static<typeof i18nOptions.schema>; //#endregion //#region ../../src/cli/i18n/services/I18nCheckService.d.ts interface I18nCheckOptions { root: string; scan: string[]; dynamicPrefixes: string[]; exclude: string[]; } interface I18nCheckResult { /** Total number of keys discovered across all dictionary files. */ totalKeys: number; /** Number of keys exempted via `dynamicPrefixes`. */ exemptKeys: number; /** Number of source files scanned for references. */ scannedFiles: number; /** Dictionary files that contributed keys. */ dictionaryFiles: string[]; /** Keys that have no quoted-literal reference anywhere in the scan. */ unused: string[]; } declare class I18nCheckService { protected readonly fs: FileSystemProvider; /** * Find unused translation keys. * * Discovery is fully static: we walk `scan` dirs, identify files * that import `$dictionary` (matched via the literal substring) plus * any per-language files they lazily `import(...)`, extract every * `"a.b.c": ...` property key declared across them, then grep the * remaining source files for a quoted-literal occurrence of each key. * Anything matching a `dynamicPrefixes` entry is exempted. */ check(options: I18nCheckOptions): Promise<I18nCheckResult>; /** * Resolve a relative `import("…")` specifier from `fromFile` to an absolute * path that was actually scanned. Returns `undefined` for bare/package * specifiers or targets outside the scan set. Extensionless specifiers are * probed against each supported source extension. */ protected resolveImport(fromFile: string, spec: string, files: Map<string, string>): string | undefined; } //#endregion //#region ../../src/cli/i18n/commands/I18nCommand.d.ts declare class I18nCommand { protected readonly log: import("alepha/logger").Logger; protected readonly options: Readonly<{ scan?: string[] | undefined; dynamicPrefixes?: string[] | undefined; exclude?: string[] | undefined; } | undefined>; protected readonly checkService: I18nCheckService; protected readonly color: ConsoleColorProvider; protected resolveOptions(): { scan: string[]; dynamicPrefixes: string[]; exclude: string[]; }; protected readonly check: import("alepha/command").CommandPrimitive<import("alepha").TObject, import("alepha").ZType, import("alepha").TObject>; readonly i18n: import("alepha/command").CommandPrimitive<import("alepha").TObject, import("alepha").ZType, import("alepha").TObject>; } //#endregion //#region ../../src/cli/i18n/index.d.ts /** * CLI plugin for finding unused translation keys. * * Statically scans the project for `$dictionary(...)` calls, extracts * every declared key, and reports the ones that have no quoted-literal * reference anywhere else in the source tree. Designed to be wired * into `yarn v` (or any verify pipeline) so dead i18n entries can't * pile up unnoticed when a feature is removed. * * Commands: * - `alepha i18n check` — report unused translation keys * * Configuration in `alepha.config.ts`: * * ```typescript * import { i18n } from "alepha/cli/i18n"; * * export default defineConfig({ * plugins: [ * i18n({ * scan: ["src", ".vendor/@alepha/ui"], * dynamicPrefixes: ["archive.type.", "petitions.filter."], * }), * ], * }); * ``` */ declare const AlephaCliI18nPlugin: import("alepha").Service<import("alepha").Module>; declare const i18n: (options?: I18nOptions) => () => void; //#endregion export { AlephaCliI18nPlugin, I18nCheckOptions, I18nCheckResult, I18nCheckService, I18nCommand, I18nOptions, i18n, i18nOptions }; //# sourceMappingURL=index.d.ts.map