arml
Version:
Enjoy unlimited and free translation with our API.
46 lines (43 loc) • 1.4 kB
TypeScript
type TranslateOptions = {
source?: string;
target: string;
};
interface TranslationResponse {
original_text: string;
source_language: string;
target_language: string;
translated_text: string;
pronunciation: string | null;
passing_time: number;
}
interface BatchTranslation {
id: number;
uuid: string;
original_text: string;
source_language: string;
target_language: string;
translated_text: string;
}
interface BatchTranslationResponse {
translations: BatchTranslation[];
passing_time: number;
}
interface DetectTranslationResponse {
text: string;
detected_language: string;
confidence: string;
passing_time: number;
}
declare class Translator {
private apiKey;
constructor(apiKey: string);
translate(text: string, { source, target }: TranslateOptions): Promise<TranslationResponse | null>;
batchTranslate(texts: string[], { source, target }: TranslateOptions): Promise<BatchTranslationResponse | null>;
detect(text: string): Promise<DetectTranslationResponse | null>;
static quick({ text, apiKey, options, }: {
text: string;
apiKey: string;
options: TranslateOptions;
}): Promise<string | undefined>;
}
export { type BatchTranslation, type BatchTranslationResponse, type DetectTranslationResponse, type TranslateOptions, type TranslationResponse, Translator };