UNPKG

@crowdin/crowdin-api-client

Version:
306 lines (305 loc) 14 kB
import { BooleanInt, CrowdinApi, PaginationOptions, PatchRequest, ResponseList, ResponseObject } from '../core'; /** * Use API to add or remove strings translations, approvals, and votes. */ export declare class StringTranslations extends CrowdinApi { /** * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.getMany */ listTranslationApprovals(projectId: number, options?: StringTranslationsModel.ListTranslationApprovalsOptions): Promise<ResponseList<StringTranslationsModel.Approval>>; /** * @param projectId project identifier * @param stringId string identifier * @param languageId language identifier * @param translationId translation identifier * @param limit maximum number of items to retrieve (default 25) * @param offset starting offset in the collection (default 0) * @param fileId file identifier * @param labelIds label Identifiers * @param excludeLabelIds exclude label Identifiers * @deprecated optional parameters should be passed through an object * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.getMany */ listTranslationApprovals(projectId: number, stringId?: number, languageId?: string, translationId?: number, limit?: number, offset?: number, fileId?: number, labelIds?: string, excludeLabelIds?: string): Promise<ResponseList<StringTranslationsModel.Approval>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.post */ addApproval(projectId: number, request: StringTranslationsModel.AddApprovalRequest): Promise<ResponseObject<StringTranslationsModel.Approval>>; /** * @param projectId project identifier * @param stringId string identifier * @see https://support.crowdin.com/developer/api/v2/#tag/String-Translations/operation/api.projects.approvals.deleteMany */ removeStringApprovals(projectId: number, stringId: number): Promise<void>; /** * @param projectId project identifier * @param approvalId approval identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.get */ approvalInfo(projectId: number, approvalId: number): Promise<ResponseObject<StringTranslationsModel.Approval>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.patch */ approvalBatchOperations(projectId: number, request: PatchRequest[]): Promise<ResponseList<StringTranslationsModel.Approval>>; /** * @param projectId project identifier * @param approvalId approval identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.approvals.delete */ removeApproval(projectId: number, approvalId: number): Promise<void>; /** * @param projectId project identifier * @param languageId language identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.languages.translations.getMany */ listLanguageTranslations(projectId: number, languageId: string, options?: StringTranslationsModel.ListLanguageTranslationsOptions): Promise<ResponseList<StringTranslationsModel.PlainLanguageTranslation | StringTranslationsModel.PluralLanguageTranslation | StringTranslationsModel.IcuLanguageTranslation>>; /** * @param projectId project identifier * @param languageId language identifier * @param stringIds filter translations by stringIds * @param fileId filter translations by fileId * @param limit maximum number of items to retrieve (default 25) * @param offset starting offset in the collection (default 0) * @param labelIds filter translations by fileId * @param denormalizePlaceholders enable denormalize placeholders * @param croql filter translations by CroQL (Can't be used with `stringIds`, `labelIds` or `fileId` in same request) * @deprecated optional parameters should be passed through an object * @see https://developer.crowdin.com/api/v2/#operation/api.projects.languages.translations.getMany */ listLanguageTranslations(projectId: number, languageId: string, stringIds?: string, fileId?: number, limit?: number, offset?: number, labelIds?: string, denormalizePlaceholders?: BooleanInt, croql?: string): Promise<ResponseList<StringTranslationsModel.PlainLanguageTranslation | StringTranslationsModel.PluralLanguageTranslation | StringTranslationsModel.IcuLanguageTranslation>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.alignment.post */ translationAlignment(projectId: number, request: StringTranslationsModel.TranslationAlignmentRequest): Promise<ResponseObject<StringTranslationsModel.TranslationAlignmentResponse>>; /** * @param projectId project identifier * @param stringId string identifier * @param languageId language identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.getMany */ listStringTranslations(projectId: number, stringId: number, languageId: string, options?: StringTranslationsModel.ListStringTranslationsOptions): Promise<ResponseList<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param stringId string identifier * @param languageId language identifier * @param limit maximum number of items to retrieve (default 25) * @param offset starting offset in the collection (default 0) * @param denormalizePlaceholders enable denormalize placeholders * @deprecated optional parameters should be passed through an object * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.getMany */ listStringTranslations(projectId: number, stringId: number, languageId: string, limit?: number, offset?: number, denormalizePlaceholders?: BooleanInt): Promise<ResponseList<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.post */ addTranslation(projectId: number, request: StringTranslationsModel.AddStringTranslationRequest): Promise<ResponseObject<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param stringId string identifier * @param languageId language identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.deleteMany */ deleteAllTranslations(projectId: number, stringId: number, languageId?: string): Promise<void>; /** * @param projectId project identifier * @param translationId translation identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.get */ translationInfo(projectId: number, translationId: number): Promise<ResponseObject<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param translationId translation identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.put */ restoreTranslation(projectId: number, translationId: number): Promise<ResponseObject<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.patch */ translationBatchOperations(projectId: number, request: PatchRequest[]): Promise<ResponseList<StringTranslationsModel.StringTranslation>>; /** * @param projectId project identifier * @param translationId translation identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.translations.delete */ deleteTranslation(projectId: number, translationId: number): Promise<void>; /** * @param projectId project identifier * @param options optional parameters for the request * @see https://developer.crowdin.com/api/v2/#operation/api.projects.votes.getMany */ listTranslationVotes(projectId: number, options?: StringTranslationsModel.ListTranslationVotesOptions): Promise<ResponseList<StringTranslationsModel.Vote>>; /** * @param projectId project identifier * @param stringId string identifier * @param languageId language identifier * @param translationId translation identifier * @param labelIds label Identifiers * @param excludeLabelIds exclude label Identifiers * @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.projects.votes.getMany */ listTranslationVotes(projectId: number, stringId?: number, languageId?: string, translationId?: number, labelIds?: string, excludeLabelIds?: string, limit?: number, offset?: number): Promise<ResponseList<StringTranslationsModel.Vote>>; /** * @param projectId project identifier * @param request request body * @see https://developer.crowdin.com/api/v2/#operation/api.projects.votes.post */ addVote(projectId: number, request: StringTranslationsModel.AddVoteRequest): Promise<ResponseObject<StringTranslationsModel.Vote>>; /** * @param projectId project identifier * @param voteId vote identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.votes.get */ voteInfo(projectId: number, voteId: number): Promise<ResponseObject<StringTranslationsModel.Vote>>; /** * @param projectId project identifier * @param voteId vote identifier * @see https://developer.crowdin.com/api/v2/#operation/api.projects.votes.delete */ cancelVote(projectId: number, voteId: number): Promise<void>; } export declare namespace StringTranslationsModel { interface ListTranslationApprovalsOptions extends PaginationOptions { stringId?: number; languageId?: string; translationId?: number; fileId?: number; labelIds?: string; excludeLabelIds?: string; orderBy?: string; } interface Approval { id: number; user: User; translationId: number; stringId: number; languageId: string; createdAt: string; } interface AddApprovalRequest { translationId: number; } interface StringTranslation { id: number; text: string; pluralCategoryName: PluralCategoryName; user: User; rating: number; provider: string; isPreTranslated: boolean; createdAt: string; } interface ListLanguageTranslationsOptions extends PaginationOptions { stringIds?: string; fileId?: number; labelIds?: string; denormalizePlaceholders?: BooleanInt; croql?: string; approvedOnly?: BooleanInt; passedWorkflow?: BooleanInt; orderBy?: string; branchId?: number; minApprovalCount?: number; directoryId?: number; } interface PlainLanguageTranslation { stringId: number; contentType: string; translationId: number; text: string; user: User; createdAt: string; } interface PluralLanguageTranslation { stringId: number; contentType: string; plurals: Plural[]; } interface IcuLanguageTranslation { stringId: number; contentType: string; translationId: number; text: string; user: User; createdAt: string; } interface Plural { translationId: number; text: string; pluralForm: string; user: User; createdAt: string; } interface TranslationAlignmentRequest { sourceLanguageId: string; targetLanguageId: string; text: string; } interface TranslationAlignmentResponse { words: { text: string; alignments: { sourceWord: string; sourceLemma: string; targetWord: string; targetLemma: string; match: number; probability: number; }[]; }[]; } interface AddStringTranslationRequest { stringId: number; languageId: string; text: string; pluralCategoryName?: PluralCategoryName; addToTm?: boolean; } interface ListTranslationVotesOptions extends PaginationOptions { stringId?: number; languageId?: string; translationId?: number; fileId?: number; labelIds?: string; excludeLabelIds?: string; } interface Vote { id: number; user: User; translationId: number; votedAt: string; mark: Mark; } interface AddVoteRequest { mark: Mark; translationId: number; } interface User { id: number; username: string; fullName: string; avatarUrl: string; } type Mark = 'up' | 'down'; interface ListStringTranslationsOptions extends PaginationOptions { denormalizePlaceholders?: BooleanInt; orderBy?: string; } type PluralCategoryName = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'; }