UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

121 lines (120 loc) 4.11 kB
import ts from "typescript"; import { TranslationKey } from "../../../types/translation.types"; /** * Finds react-i18next translation keys used in source code with enhanced context */ export declare class ReactI18nextKeyFinder { private translationKeys; private analyzedFiles; private contextExtractor; constructor(); /** * Finds all react-i18next translation keys in source files * @param sourceFiles Map of source files to analyze * @returns Promise resolving when analysis is complete */ findAllTranslationKeys(sourceFiles: Map<string, ts.SourceFile>): Promise<void>; /** * Gets the collected translation keys * @returns Array of translation keys */ getTranslationKeys(): TranslationKey[]; /** * Analyzes a source file for react-i18next hooks and calls * @param sourceFile Source file to analyze * @param filePath Path to the source file * @returns Analysis results with hooks and keys */ private analyzeSourceFile; /** * Processes a react-i18next hook to find translation keys * @param hook React-i18next hook to process * @param sourceFile Source file * @param filePath File path * @returns Array of translation keys */ private processReactI18nextHook; /** * Processes a react-i18next translation call to create a translation key with usage context * @param call React-i18next translation call * @param hookNamespace Optional namespace from hook * @param componentName Component name * @param sourceFile Source file * @param filePath File path * @returns Translation key with usage context */ private processReactI18nextCall; /** * Groups translation keys by file path * @returns Map of file paths to arrays of translation keys */ groupKeysByFile(): Map<string, TranslationKey[]>; /** * Groups translation keys by namespace * @returns Map of namespaces to arrays of translation keys */ groupKeysByNamespace(): Map<string, TranslationKey[]>; /** * Finds keys that use namespace prefix pattern (namespace:key) * @returns Array of keys using namespace prefix */ findKeysWithNamespacePrefix(): TranslationKey[]; /** * Finds keys that use namespace from options object * @returns Array of keys using options namespace */ findKeysWithOptionsNamespace(): TranslationKey[]; /** * Finds files with the most translation keys * @param limit Maximum number of files to return * @returns Array of files sorted by key count */ findFilesWithMostKeys(limit?: number): Array<{ filePath: string; keyCount: number; keys: TranslationKey[]; }>; /** * Finds translation keys in JSX context * @returns Array of keys used in JSX */ findKeysInJSX(): TranslationKey[]; /** * Finds translation keys in conditional rendering * @returns Array of keys used in conditional rendering */ findKeysInConditionals(): TranslationKey[]; /** * Finds translation keys in event handlers * @returns Array of keys used in event handlers */ findKeysInEventHandlers(): TranslationKey[]; /** * Groups translation keys by component * @returns Map of component names to arrays of translation keys */ groupKeysByComponent(): Map<string, TranslationKey[]>; /** * Finds components that use multiple namespaces * @returns Array of components with multiple namespaces */ findComponentsWithMultipleNamespaces(): Array<{ componentName: string; namespaces: string[]; keyCount: number; }>; /** * Gets statistics about key usage patterns * @returns Object with usage statistics */ getUsageStatistics(): { totalKeys: number; uniqueKeys: number; namespacesUsed: number; filesAnalyzed: number; componentsAnalyzed: number; jsxUsage: number; conditionalUsage: number; eventHandlerUsage: number; }; }