Skip to content

GCP.Translate reference

Source: src/GCP/Translate/AdaptiveMtDataset.ts

An Adaptive MT dataset of source/target sentence pairs used to customize Cloud Translation.

Without labels, ownership rests on the deterministic id: read reports a resource it finds without prior state as unowned (adopt it with --adopt). Adaptive MT datasets are location-scoped and have no labels field. Language pair, location, and display name are immutable — there is no patch RPC.

English to Spanish

const dataset = yield* GCP.Translate.AdaptiveMtDataset("EnEs", {
sourceLanguageCode: "en",
targetLanguageCode: "es",
});

Explicit id and location

const dataset = yield* GCP.Translate.AdaptiveMtDataset("EnEs", {
datasetId: "en-es-adaptive",
location: "us-central1",
sourceLanguageCode: "en",
targetLanguageCode: "es",
displayName: "enes",
});

Source: src/GCP/Translate/AdaptiveMtTranslate.ts

Runtime binding for Cloud Translation adaptiveMtTranslate.

Bind this operation to an AdaptiveMtDataset in a Function/Action init phase. Provide AdaptiveMtTranslateHttp.

AdaptiveMtTranslate: Translating with Adaptive MT

Section titled “AdaptiveMtTranslate: Translating with Adaptive MT”
const translateText = yield* GCP.Translate.AdaptiveMtTranslate(dataset);
const result = yield* translateText({
body: { content: ["Hello, world"] },
});

Source: src/GCP/Translate/AdaptiveMtTranslateHttp.ts Kind: Layer · Provides: GCP.Translate.AdaptiveMtTranslate

HTTP implementation of AdaptiveMtTranslate.

Source: src/GCP/Translate/GetAdaptiveMtDataset.ts

Runtime binding for Cloud Translation adaptiveMtDatasets.get.

Bind this operation to an AdaptiveMtDataset in a Function/Action init phase. Provide GetAdaptiveMtDatasetHttp.

const getDataset = yield* GCP.Translate.GetAdaptiveMtDataset(dataset);
const live = yield* getDataset();

Source: src/GCP/Translate/GetAdaptiveMtDatasetHttp.ts Kind: Layer · Provides: GCP.Translate.GetAdaptiveMtDataset

HTTP implementation of GetAdaptiveMtDataset.

Source: src/GCP/Translate/GetGlossariesGlossaryEntry.ts

Runtime binding for Cloud Translation glossaryEntries.get.

Bind this operation to a GlossariesGlossaryEntry in a Function/Action init phase. Provide GetGlossariesGlossaryEntryHttp.

GetGlossariesGlossaryEntry: Reading an Entry

Section titled “GetGlossariesGlossaryEntry: Reading an Entry”
const getEntry = yield* GCP.Translate.GetGlossariesGlossaryEntry(entry);
const live = yield* getEntry();

Source: src/GCP/Translate/GetGlossariesGlossaryEntryHttp.ts Kind: Layer · Provides: GCP.Translate.GetGlossariesGlossaryEntry

HTTP implementation of GetGlossariesGlossaryEntry.

Source: src/GCP/Translate/GetModel.ts

Runtime binding for Cloud Translation models.get.

Bind this operation to a Model in a Function/Action init phase. Provide GetModelHttp.

const getModel = yield* GCP.Translate.GetModel(model);
const live = yield* getModel();

Source: src/GCP/Translate/GetModelHttp.ts Kind: Layer · Provides: GCP.Translate.GetModel

HTTP implementation of GetModel.

Source: src/GCP/Translate/GlossariesGlossaryEntry.ts

A single Cloud Translation glossary entry under a parent glossary.

Without labels, ownership rests on the deterministic id: read reports a resource it finds without prior state as unowned (adopt it with --adopt). Entries are nested under a glossary and have no labels field. Term pair / term set and description update in place via patch. Parent glossary and entry id are identity — changing them replaces the entry.

GlossariesGlossaryEntry: Creating an Entry

Section titled “GlossariesGlossaryEntry: Creating an Entry”

Unidirectional term pair

const entry = yield* GCP.Translate.GlossariesGlossaryEntry("Hello", {
parent: glossary.name,
termsPair: {
sourceTerm: { languageCode: "en", text: "hello" },
targetTerm: { languageCode: "es", text: "hola" },
},
});

Description

const entry = yield* GCP.Translate.GlossariesGlossaryEntry("Hello", {
parent: glossary.name,
description: "greeting",
termsPair: {
sourceTerm: { languageCode: "en", text: "hello" },
targetTerm: { languageCode: "es", text: "hola" },
},
});

GlossariesGlossaryEntry: Updating an Entry

Section titled “GlossariesGlossaryEntry: Updating an Entry”
// Same logical id as before; only the changed props differ.
const entry = yield* GCP.Translate.GlossariesGlossaryEntry("Hello", {
parent: glossary.name,
termsPair: {
sourceTerm: { languageCode: "en", text: "hello" },
targetTerm: { languageCode: "es", text: "buenas" },
},
});

Source: src/GCP/Translate/Model.ts

A trained Cloud Translation AutoML model.

Model ids are assigned by Google and models have no labels, so Alchemy tracks a model only through the name recorded in state; read reports a model it finds without prior state as unowned (adopt it with --adopt). Models are trained from a Translation dataset in the same location. Create and delete are long-running operations. Dataset, location, and display name are immutable — there is no patch RPC. Training can take hours; tests skipIf-gate behind FAST.

Train from a dataset

const model = yield* GCP.Translate.Model("EnEs", {
dataset: dataset.name,
displayName: "enes",
});

Explicit location

const model = yield* GCP.Translate.Model("EnEs", {
location: "us-central1",
dataset: dataset.name,
});

Source: src/GCP/Translate/TranslateText.ts

Runtime binding for Cloud Translation translateText using a custom AutoML model.

Bind this operation to a Model in a Function/Action init phase. Provide TranslateTextHttp.

TranslateText: Translating with a Custom Model

Section titled “TranslateText: Translating with a Custom Model”
const translateText = yield* GCP.Translate.TranslateText(model);
const result = yield* translateText({
body: {
contents: ["Hello, world"],
targetLanguageCode: "es",
sourceLanguageCode: "en",
mimeType: "text/plain",
},
});

Source: src/GCP/Translate/TranslateTextHttp.ts Kind: Layer · Provides: GCP.Translate.TranslateText

HTTP implementation of TranslateText.