GCP.Translate reference
AdaptiveMtDataset
Section titled “AdaptiveMtDataset”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.
AdaptiveMtDataset: Creating a Dataset
Section titled “AdaptiveMtDataset: Creating a Dataset”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",});AdaptiveMtTranslate
Section titled “AdaptiveMtTranslate”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"] },});AdaptiveMtTranslateHttp
Section titled “AdaptiveMtTranslateHttp”Source:
src/GCP/Translate/AdaptiveMtTranslateHttp.tsKind: Layer · Provides:GCP.Translate.AdaptiveMtTranslate
HTTP implementation of AdaptiveMtTranslate.
GetAdaptiveMtDataset
Section titled “GetAdaptiveMtDataset”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.
GetAdaptiveMtDataset: Reading a Dataset
Section titled “GetAdaptiveMtDataset: Reading a Dataset”const getDataset = yield* GCP.Translate.GetAdaptiveMtDataset(dataset);const live = yield* getDataset();GetAdaptiveMtDatasetHttp
Section titled “GetAdaptiveMtDatasetHttp”Source:
src/GCP/Translate/GetAdaptiveMtDatasetHttp.tsKind: Layer · Provides:GCP.Translate.GetAdaptiveMtDataset
HTTP implementation of GetAdaptiveMtDataset.
GetGlossariesGlossaryEntry
Section titled “GetGlossariesGlossaryEntry”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();GetGlossariesGlossaryEntryHttp
Section titled “GetGlossariesGlossaryEntryHttp”Source:
src/GCP/Translate/GetGlossariesGlossaryEntryHttp.tsKind: Layer · Provides:GCP.Translate.GetGlossariesGlossaryEntry
HTTP implementation of GetGlossariesGlossaryEntry.
GetModel
Section titled “GetModel”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.
GetModel: Reading a Model
Section titled “GetModel: Reading a Model”const getModel = yield* GCP.Translate.GetModel(model);const live = yield* getModel();GetModelHttp
Section titled “GetModelHttp”Source:
src/GCP/Translate/GetModelHttp.tsKind: Layer · Provides:GCP.Translate.GetModel
HTTP implementation of GetModel.
GlossariesGlossaryEntry
Section titled “GlossariesGlossaryEntry”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.
Model: Creating a Model
Section titled “Model: Creating a Model”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,});TranslateText
Section titled “TranslateText”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", },});TranslateTextHttp
Section titled “TranslateTextHttp”Source:
src/GCP/Translate/TranslateTextHttp.tsKind: Layer · Provides:GCP.Translate.TranslateText
HTTP implementation of TranslateText.