@scoutello/i18n-magic
Version:
Intelligent CLI toolkit that automates internationalization workflows with AI-powered translations for JavaScript/TypeScript projects
53 lines • 2.76 kB
TypeScript
import type OpenAI from "openai";
import type { Configuration, GlobPatternConfig } from "./types";
export declare const loadConfig: ({ configPath, }: {
configPath: string;
}) => any;
export declare function removeDuplicatesFromArray<T>(arr: T[]): T[];
export declare const translateKey: ({ inputLanguage, context, object, openai, outputLanguage, model, }: {
object: Record<string, string>;
context: string;
inputLanguage: string;
outputLanguage: string;
model: string;
openai: OpenAI;
}) => Promise<Record<string, string>>;
export declare const loadLocalesFile: (loadPath: string | ((locale: string, namespace: string) => Promise<Record<string, string>>), locale: string, namespace: string) => Promise<Record<string, string>>;
export declare const writeLocalesFile: (savePath: string | ((locale: string, namespace: string, data: Record<string, string>) => Promise<void>), locale: string, namespace: string, data: Record<string, string>) => Promise<void>;
export declare const getPureKey: (key: string, namespace?: string, isDefault?: boolean) => string;
/**
* Extracts all glob patterns from the configuration, handling both string and object formats
*/
export declare const extractGlobPatterns: (globPatterns: (string | GlobPatternConfig)[]) => string[];
/**
* Gets the namespaces associated with a specific file path based on glob pattern configuration
*/
export declare const getNamespacesForFile: (filePath: string, globPatterns: (string | {
pattern: string;
namespaces: string[];
})[], defaultNamespace: string) => string[];
/**
* Gets all glob patterns that should be used for a specific namespace
*/
export declare const getGlobPatternsForNamespace: (namespace: string, globPatterns: (string | {
pattern: string;
namespaces: string[];
})[]) => string[];
/**
* Extracts keys with their associated namespaces based on the files they're found in
*/
export declare const getKeysWithNamespaces: ({ globPatterns, defaultNamespace, }: Pick<Configuration, "globPatterns" | "defaultNamespace">) => Promise<{
key: string;
namespaces: string[];
file: string;
}[]>;
export declare const getMissingKeys: ({ globPatterns, namespaces, defaultNamespace, defaultLocale, loadPath, }: Configuration) => Promise<any[]>;
export declare const getTextInput: (prompt: string) => Promise<string>;
export declare const checkAllKeysExist: ({ namespaces, defaultLocale, loadPath, locales, context, openai, savePath, disableTranslation, model, }: Configuration) => Promise<void>;
export declare class TranslationError extends Error {
locale?: string;
namespace?: string;
cause?: Error;
constructor(message: string, locale?: string, namespace?: string, cause?: Error);
}
//# sourceMappingURL=utils.d.ts.map