@crowdin/crowdin-api-client
Version:
JavaScript library for Crowdin API
108 lines (107 loc) • 3.94 kB
TypeScript
import { CrowdinApi, PaginationOptions, PatchRequest, ResponseList, ResponseObject } from '../core';
/**
* Machine Translation Engines (MTE) are the sources for pre-translations.
*
* Use API to add, update, and delete specific MTE.
*/
export declare class MachineTranslation extends CrowdinApi {
/**
* @param options optional parameters for the request
* @see https://developer.crowdin.com/api/v2/#operation/api.mts.getMany
*/
listMts(options?: MachineTranslationModel.ListMTsOptions): Promise<ResponseList<MachineTranslationModel.MachineTranslation>>;
/**
* @param groupId group identifier
* @param limit maximum number of items to retrieve (default 25)
* @param offset starting offset in the collection (default 0)
* @deprecated optional parameters should be passed through an object
* @see https://developer.crowdin.com/api/v2/#operation/api.mts.getMany
*/
listMts(groupId?: number, limit?: number, offset?: number): Promise<ResponseList<MachineTranslationModel.MachineTranslation>>;
/**
* @param request request body
* @see https://support.crowdin.com/enterprise/api/#operation/api.mts.post
*/
createMt(request: MachineTranslationModel.CreateMachineTranslationRequest): Promise<ResponseObject<MachineTranslationModel.MachineTranslation>>;
/**
* @param mtId mt identifier
* @see https://developer.crowdin.com/api/v2/#operation/api.mts.getMany
*/
getMt(mtId: number): Promise<ResponseObject<MachineTranslationModel.MachineTranslation>>;
/**
* @param mtId mt identifier
* @see https://support.crowdin.com/enterprise/api/#operation/api.mts.delete
*/
deleteMt(mtId: number): Promise<void>;
/**
* @param mtId mt identifier
* @param request request body
* @see https://support.crowdin.com/enterprise/api/#operation/api.mts.patch
*/
updateMt(mtId: number, request: PatchRequest[]): Promise<ResponseObject<MachineTranslationModel.MachineTranslation>>;
/**
* @param mtId mt identifier
* @param request request body
* @see https://developer.crowdin.com/api/v2/#operation/api.mts.translations.post
*/
translate(mtId: number, request: MachineTranslationModel.TranslateRequest): Promise<ResponseObject<MachineTranslationModel.TranslateResponse>>;
}
export declare namespace MachineTranslationModel {
interface MachineTranslation {
id: number;
groupId: number;
name: string;
type: number;
credentials: Credentials;
projectIds: number[];
supportedLanguageIds: string[];
supportedLanguagePairs: Record<string, string[]>;
enabledLanguageIds: string[];
enabledProjectIds: number[];
isEnabled: boolean;
}
type Credentials = {
apiKey: string;
} | {
credentials: string;
} | {
model: string;
apiKey: string;
} | {
isSystemCredentials: boolean;
apiKey: string;
} | {
endpoint: string;
apiKey: string;
} | {
url: string;
} | {
accessKey: string;
secretKey: string;
};
interface CreateMachineTranslationRequest {
name: string;
type: string;
credentials: Credentials;
groupId?: number;
enabledLanguageIds?: string[];
enabledProjectIds?: number[];
isEnabled?: boolean;
}
interface TranslateRequest {
languageRecognitionProvider?: LanguageRecognitionProvider;
sourceLanguageId?: string;
targetLanguageId: string;
strings?: string[];
}
interface TranslateResponse {
sourceLanguageId: string;
targetLanguageId: string;
strings: string[];
translations: string[];
}
type LanguageRecognitionProvider = 'crowdin' | 'engine';
interface ListMTsOptions extends PaginationOptions {
groupId?: number;
}
}