UNPKG

@translated/lara

Version:

Official Lara SDK for JavaScript and Node.js

43 lines (42 loc) 2.16 kB
import { Credentials } from "../credentials"; import { LaraClient } from "../net"; import { Memory, MemoryImport, TextBlock, TextResult } from "./models"; import { MultiPartFile } from "../net/client"; export type TranslatorOptions = { serverUrl?: string; }; export type MemoryImportCallback = (memoryImport: MemoryImport) => void; export declare class Memories { private readonly client; private readonly pollingInterval; constructor(client: LaraClient); list(): Promise<Memory[]>; create(name: string, externalId?: string): Promise<Memory>; get(id: string): Promise<Memory | null>; delete(id: string): Promise<Memory>; update(id: string, name: string): Promise<Memory>; connect<T extends string | string[]>(ids: T): Promise<T extends string ? Memory : Memory[]>; importTmx(id: string, tmx: MultiPartFile, gzip?: boolean): Promise<MemoryImport>; addTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string): Promise<MemoryImport>; deleteTranslation(id: string | string[], source: string, target: string, sentence: string, translation: string, tuid?: string, sentenceBefore?: string, sentenceAfter?: string): Promise<MemoryImport>; getImportStatus(id: string): Promise<MemoryImport>; waitForImport(mImport: MemoryImport, updateCallback?: MemoryImportCallback, maxWaitTime?: number): Promise<MemoryImport>; } export type TranslateOptions = { sourceHint?: string; adaptTo?: string[]; instructions?: string[]; contentType?: string; multiline?: boolean; timeoutInMillis?: number; priority?: "normal" | "background"; useCache?: boolean | "overwrite"; cacheTTLSeconds?: number; }; export declare class Translator { protected readonly client: LaraClient; readonly memories: Memories; constructor(credentials: Credentials, options?: TranslatorOptions); getLanguages(): Promise<string[]>; translate<T extends string | string[] | TextBlock[]>(text: T, source: string | null, target: string, options?: TranslateOptions): Promise<TextResult<T>>; }