Skip to content

AWS.Translate reference

Source: src/AWS/Translate/DescribeTextTranslationJob.ts

Runtime binding for translate:DescribeTextTranslationJob — get the properties of an asynchronous batch translation job (status, language pair, input/output locations, document counts).

DescribeTextTranslationJob: Batch Translation Jobs

Section titled “DescribeTextTranslationJob: Batch Translation Jobs”
// init
const describeJob = yield* AWS.Translate.DescribeTextTranslationJob();
// runtime
const result = yield* describeJob({ JobId: job.JobId! });
// result.TextTranslationJobProperties?.JobStatus

Source: src/AWS/Translate/GetParallelData.ts

Runtime binding for translate:GetParallelData — retrieve a parallel data resource’s properties and a presigned download location for its input file.

// init
const getParallelData = yield* AWS.Translate.GetParallelData();
// runtime
const result = yield* getParallelData({ Name: examples.parallelDataName });
// result.ParallelDataProperties?.Status === "ACTIVE"

Source: src/AWS/Translate/GetTerminology.ts

Runtime binding for translate:GetTerminology — retrieve a custom terminology’s properties and a presigned download location for its term-pair file.

// init
const getTerminology = yield* AWS.Translate.GetTerminology();
// runtime
const result = yield* getTerminology({ Name: glossary.terminologyName });
// result.TerminologyProperties?.TermCount
// result.TerminologyDataLocation?.Location — presigned download URL

Source: src/AWS/Translate/ListLanguages.ts

Runtime binding for translate:ListLanguages — list the languages (RFC-5646 codes and display names) Amazon Translate supports.

// init
const listLanguages = yield* AWS.Translate.ListLanguages();
// runtime
const result = yield* listLanguages({ MaxResults: 100 });
// result.Languages -> [{ LanguageCode: "es", LanguageName: "Spanish" }, …]

Source: src/AWS/Translate/ListParallelData.ts

Runtime binding for translate:ListParallelData — list the parallel data resources in the account and region.

// init
const listParallelData = yield* AWS.Translate.ListParallelData();
// runtime
const result = yield* listParallelData({ MaxResults: 50 });
// result.ParallelDataPropertiesList -> [{ Name, Arn, Status, … }, …]

Source: src/AWS/Translate/ListTerminologies.ts

Runtime binding for translate:ListTerminologies — list the custom terminologies in the account and region.

// init
const listTerminologies = yield* AWS.Translate.ListTerminologies();
// runtime
const result = yield* listTerminologies({ MaxResults: 50 });
// result.TerminologyPropertiesList -> [{ Name, Arn, TermCount, … }, …]

Source: src/AWS/Translate/ListTextTranslationJobs.ts

Runtime binding for translate:ListTextTranslationJobs — list the batch translation jobs submitted in the account and region, optionally filtered by name, status, or submission time.

ListTextTranslationJobs: Batch Translation Jobs

Section titled “ListTextTranslationJobs: Batch Translation Jobs”
// init
const listJobs = yield* AWS.Translate.ListTextTranslationJobs();
// runtime
const result = yield* listJobs({
Filter: { JobStatus: "IN_PROGRESS" },
MaxResults: 25,
});
// result.TextTranslationJobPropertiesList -> [{ JobId, JobStatus, … }, …]

Source: src/AWS/Translate/ParallelData.ts

Amazon Translate parallel data — segment-aligned translation examples imported from S3 that steer the style, tone, and word choice of batch translation jobs (Active Custom Translation). The import is asynchronous: the resource waits for the parallel data to become ACTIVE.

Import parallel data from S3

const examples = yield* AWS.Translate.ParallelData("StyleExamples", {
s3Uri: "s3://my-bucket/style-examples.csv",
format: "CSV",
});

Use parallel data in a batch translation job

const startJob = yield* AWS.Translate.StartTextTranslationJob(dataAccessRole);
yield* startJob({
InputDataConfig: { S3Uri: "s3://my-bucket/input/", ContentType: "text/plain" },
OutputDataConfig: { S3Uri: "s3://my-bucket/output/" },
SourceLanguageCode: "en",
TargetLanguageCodes: ["es"],
ParallelDataNames: [examples.parallelDataName],
});

Source: src/AWS/Translate/StartTextTranslationJob.ts

Runtime binding for translate:StartTextTranslationJob — start an asynchronous batch translation job over a collection of documents in S3.

The binding is constructed with the data-access role (the IAM role Amazon Translate assumes to read the input documents and write results; its trust policy must allow translate.amazonaws.com). The role’s ARN is injected as DataAccessRoleArn on every runtime request and the host is granted iam:PassRole on it alongside translate:StartTextTranslationJob (which has no resource-level IAM). Track the job with DescribeTextTranslationJob and stop it with StopTextTranslationJob.

StartTextTranslationJob: Batch Translation Jobs

Section titled “StartTextTranslationJob: Batch Translation Jobs”
// deploy time — bind the Translate data-access role
const startJob = yield* AWS.Translate.StartTextTranslationJob(dataAccessRole);
// runtime
const job = yield* startJob({
InputDataConfig: { S3Uri: "s3://my-bucket/input/", ContentType: "text/plain" },
OutputDataConfig: { S3Uri: "s3://my-bucket/output/" },
SourceLanguageCode: "en",
TargetLanguageCodes: ["es"],
});
// job.JobId, job.JobStatus === "SUBMITTED"

Source: src/AWS/Translate/StopTextTranslationJob.ts

Runtime binding for translate:StopTextTranslationJob — stop an asynchronous batch translation job that is in progress. An IN_PROGRESS job is marked STOP_REQUESTED and later STOPPED; a job that completes first ends COMPLETED.

StopTextTranslationJob: Batch Translation Jobs

Section titled “StopTextTranslationJob: Batch Translation Jobs”
// init
const stopJob = yield* AWS.Translate.StopTextTranslationJob();
// runtime
const result = yield* stopJob({ JobId: job.JobId! });
// result.JobStatus === "STOP_REQUESTED"

Source: src/AWS/Translate/Terminology.ts

An Amazon Translate custom terminology — a glossary of term pairs (CSV, TMX, or TSV) that pins how specific words and phrases (brand names, product names, domain jargon) are translated. Reference it by name from TranslateText, TranslateDocument, or batch translation jobs.

Import a CSV terminology

const glossary = yield* AWS.Translate.Terminology("BrandGlossary", {
file: ["en,es", "Alchemy,Alquimia"].join("\n"),
format: "CSV",
});

Translate text with the terminology applied

const translateText = yield* AWS.Translate.TranslateText();
const result = yield* translateText({
Text: "Alchemy deploys infrastructure.",
SourceLanguageCode: "en",
TargetLanguageCode: "es",
TerminologyNames: [glossary.terminologyName],
});

Source: src/AWS/Translate/TranslateDocument.ts

Runtime binding for translate:TranslateDocument — synchronously translate a whole document (plain text, HTML, or Word) between a source and a target language.

One of the two language codes must be en (English). The document content and the translated result are sensitive blobs — the response’s TranslatedDocument.Content decodes as Redacted<Uint8Array>.

// init
const translateDocument = yield* AWS.Translate.TranslateDocument();
// runtime
const result = yield* translateDocument({
Document: {
Content: new TextEncoder().encode("Good morning!"),
ContentType: "text/plain",
},
SourceLanguageCode: "en",
TargetLanguageCode: "es",
});
const bytes = Redacted.value(result.TranslatedDocument.Content as Redacted.Redacted<Uint8Array>);
// new TextDecoder().decode(bytes) === "¡Buenos días!"

Source: src/AWS/Translate/TranslateText.ts

Runtime binding for translate:TranslateText — translate text between a source and a target language.

Translate is a pure pay-per-call service with no resource to manage: the binding takes no arguments and grants the function translate:TranslateText (the action has no resource-level IAM). Language codes follow RFC 5646 (en, es, de, …); pass auto as the source to let Translate detect the language (this additionally calls Comprehend under the hood).

// init
const translateText = yield* AWS.Translate.TranslateText();
// runtime
const result = yield* translateText({
Text: "Hello, world!",
SourceLanguageCode: "en",
TargetLanguageCode: "es",
});
// result.TranslatedText === "¡Hola, mundo!"