Provides natural language translation operations. v3beta1
Package
@google-cloud/translateConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of TranslationServiceClient.
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof gax.fallback
: loaded instance of |
Properties
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
operationsClient
operationsClient: gax.OperationsClient;
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
translationServiceStub
translationServiceStub?: Promise<{
[name: string]: Function;
}>;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
batchTranslateDocument(request, options)
batchTranslateDocument(request?: protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Translates a large volume of documents in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.
This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Location to make a regional call.
* Format: `projects/{project-number-or-id}/locations/{location-id}`.
* The `global` location is not supported for batch translation.
* Only AutoML Translation models or glossaries within the same region (have
* the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
* error is returned.
*/
// const parent = 'abc123'
/**
* Required. The BCP-47 language code of the input document if known, for
* example, "en-US" or "sr-Latn". Supported language codes are listed in
* Language Support (https://cloud.google.com/translate/docs/languages).
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. The BCP-47 language code to use for translation of the input
* document. Specify up to 10 language codes here.
*/
// const targetLanguageCodes = 'abc123'
/**
* Required. Input configurations.
* The total number of files matched should be <= 100.="" *="" the="" total="" content="" size="" to="" translate="" should="" be=""><= 100m="" unicode="" codepoints.="" *="" the="" files="" must="" use="" utf-8="" encoding.="" */="" const="" inputconfigs="1234" *="" *="" required.="" output="" configuration.="" *="" if="" 2="" input="" configs="" match="" to="" the="" same="" file="" (that="" is,="" same="" input="" path),="" *="" we="" don't="" generate="" output="" for="" duplicate="" inputs.="" */="" const="" outputconfig="{}" *="" *="" optional.="" the="" models="" to="" use="" for="" translation.="" map's="" key="" is="" target="" language="" *="" code.="" map's="" value="" is="" the="" model="" name.="" value="" can="" be="" a="" built-in="" general="" model,="" *="" or="" an="" automl="" translation="" model.="" *="" the="" value="" format="" depends="" on="" model="" type:="" *="" -="" automl="" translation="" models:="" *="" `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`="" *="" -="" general="" (built-in)="" models:="" *="" `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,="" *="" if="" the="" map="" is="" empty="" or="" a="" specific="" model="" is="" not="" requested="" for="" a="" language="" *="" pair,="" then="" default="" google="" model="" (nmt)="" is="" used.="" */="" const="" models="1234" *="" *="" optional.="" glossaries="" to="" be="" applied.="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="1234" *="" *="" optional.="" file="" format="" conversion="" map="" to="" be="" applied="" to="" all="" input="" files.="" *="" map's="" key="" is="" the="" original="" mime_type.="" map's="" value="" is="" the="" target="" mime_type="" of="" *="" translated="" documents.="" *="" supported="" file="" format="" conversion="" includes:="" *="" -="" `application/pdf`="" to="" *="" `application/vnd.openxmlformats-officedocument.wordprocessingml.document`="" *="" if="" nothing="" specified,="" output="" files="" will="" be="" in="" the="" same="" format="" as="" the="" *="" original="" file.="" */="" const="" formatconversions="1234" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3beta1;" instantiates="" a="" client="" const="" translationclient="new" translationserviceclient();="" async="" function="" callbatchtranslatedocument()="" {="" construct="" request="" const="" request="{" parent,="" sourcelanguagecode,="" targetlanguagecodes,="" inputconfigs,="" outputconfig,="" };="" run="" request="" const="" [operation]="await" translationclient.batchtranslatedocument(request);="" const="" [response]="await" operation.promise();="" console.log(response);="" }="" callbatchtranslatedocument();="">
batchTranslateDocument(request, options, callback)
batchTranslateDocument(request: protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchTranslateDocument(request, callback)
batchTranslateDocument(request: protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentRequest
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchTranslateText(request, options)
batchTranslateText(request?: protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Translates a large volume of text in asynchronous batch mode. This function provides real-time output as the inputs are being processed. If caller cancels a request, the partial results (for an input file, it's all or nothing) may still be available on the specified output location.
This call returns immediately and you can use google.longrunning.Operation.name to poll the status of the call.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Location to make a call. Must refer to a caller's project.
* Format: `projects/{project-number-or-id}/locations/{location-id}`.
* The `global` location is not supported for batch translation.
* Only AutoML Translation models or glossaries within the same region (have
* the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
* error is returned.
*/
// const parent = 'abc123'
/**
* Required. Source language code.
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. Specify up to 10 language codes here.
*/
// const targetLanguageCodes = 'abc123'
/**
* Optional. The models to use for translation. Map's key is target language
* code. Map's value is model name. Value can be a built-in general model,
* or an AutoML Translation model.
* The value format depends on model type:
* - AutoML Translation models:
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* - General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* If the map is empty or a specific model is
* not requested for a language pair, then default google model (nmt) is used.
*/
// const models = 1234
/**
* Required. Input configurations.
* The total number of files matched should be <= 100.="" *="" the="" total="" content="" size="" should="" be=""><= 100m="" unicode="" codepoints.="" *="" the="" files="" must="" use="" utf-8="" encoding.="" */="" const="" inputconfigs="1234" *="" *="" required.="" output="" configuration.="" *="" if="" 2="" input="" configs="" match="" to="" the="" same="" file="" (that="" is,="" same="" input="" path),="" *="" we="" don't="" generate="" output="" for="" duplicate="" inputs.="" */="" const="" outputconfig="{}" *="" *="" optional.="" glossaries="" to="" be="" applied="" for="" translation.="" *="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="1234" *="" *="" optional.="" the="" labels="" with="" user-defined="" metadata="" for="" the="" request.="" *="" label="" keys="" and="" values="" can="" be="" no="" longer="" than="" 63="" characters="" *="" (unicode="" codepoints),="" can="" only="" contain="" lowercase="" letters,="" numeric="" *="" characters,="" underscores="" and="" dashes.="" international="" characters="" are="" allowed.="" *="" label="" values="" are="" optional.="" label="" keys="" must="" start="" with="" a="" letter.="" *="" see="" https://cloud.google.com/translate/docs/labels="" for="" more="" information.="" */="" const="" labels="1234" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3beta1;" instantiates="" a="" client="" const="" translationclient="new" translationserviceclient();="" async="" function="" callbatchtranslatetext()="" {="" construct="" request="" const="" request="{" parent,="" sourcelanguagecode,="" targetlanguagecodes,="" inputconfigs,="" outputconfig,="" };="" run="" request="" const="" [operation]="await" translationclient.batchtranslatetext(request);="" const="" [response]="await" operation.promise();="" console.log(response);="" }="" callbatchtranslatetext();="">
batchTranslateText(request, options, callback)
batchTranslateText(request: protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
batchTranslateText(request, callback)
batchTranslateText(request: protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IBatchTranslateResponse, protos.google.cloud.translation.v3beta1.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
checkBatchTranslateDocumentProgress(name)
checkBatchTranslateDocumentProgress(name: string): Promise<LROperation<protos.google.cloud.translation.v3beta1.BatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.BatchTranslateDocumentMetadata>>;
Check the status of the long running operation returned by batchTranslateDocument()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.cloud.translation.v3beta1.BatchTranslateDocumentResponse, protos.google.cloud.translation.v3beta1.BatchTranslateDocumentMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Location to make a regional call.
* Format: `projects/{project-number-or-id}/locations/{location-id}`.
* The `global` location is not supported for batch translation.
* Only AutoML Translation models or glossaries within the same region (have
* the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
* error is returned.
*/
// const parent = 'abc123'
/**
* Required. The BCP-47 language code of the input document if known, for
* example, "en-US" or "sr-Latn". Supported language codes are listed in
* Language Support (https://cloud.google.com/translate/docs/languages).
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. The BCP-47 language code to use for translation of the input
* document. Specify up to 10 language codes here.
*/
// const targetLanguageCodes = 'abc123'
/**
* Required. Input configurations.
* The total number of files matched should be <= 100.="" *="" the="" total="" content="" size="" to="" translate="" should="" be=""><= 100m="" unicode="" codepoints.="" *="" the="" files="" must="" use="" utf-8="" encoding.="" */="" const="" inputconfigs="1234" *="" *="" required.="" output="" configuration.="" *="" if="" 2="" input="" configs="" match="" to="" the="" same="" file="" (that="" is,="" same="" input="" path),="" *="" we="" don't="" generate="" output="" for="" duplicate="" inputs.="" */="" const="" outputconfig="{}" *="" *="" optional.="" the="" models="" to="" use="" for="" translation.="" map's="" key="" is="" target="" language="" *="" code.="" map's="" value="" is="" the="" model="" name.="" value="" can="" be="" a="" built-in="" general="" model,="" *="" or="" an="" automl="" translation="" model.="" *="" the="" value="" format="" depends="" on="" model="" type:="" *="" -="" automl="" translation="" models:="" *="" `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`="" *="" -="" general="" (built-in)="" models:="" *="" `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,="" *="" if="" the="" map="" is="" empty="" or="" a="" specific="" model="" is="" not="" requested="" for="" a="" language="" *="" pair,="" then="" default="" google="" model="" (nmt)="" is="" used.="" */="" const="" models="1234" *="" *="" optional.="" glossaries="" to="" be="" applied.="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="1234" *="" *="" optional.="" file="" format="" conversion="" map="" to="" be="" applied="" to="" all="" input="" files.="" *="" map's="" key="" is="" the="" original="" mime_type.="" map's="" value="" is="" the="" target="" mime_type="" of="" *="" translated="" documents.="" *="" supported="" file="" format="" conversion="" includes:="" *="" -="" `application/pdf`="" to="" *="" `application/vnd.openxmlformats-officedocument.wordprocessingml.document`="" *="" if="" nothing="" specified,="" output="" files="" will="" be="" in="" the="" same="" format="" as="" the="" *="" original="" file.="" */="" const="" formatconversions="1234" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3beta1;" instantiates="" a="" client="" const="" translationclient="new" translationserviceclient();="" async="" function="" callbatchtranslatedocument()="" {="" construct="" request="" const="" request="{" parent,="" sourcelanguagecode,="" targetlanguagecodes,="" inputconfigs,="" outputconfig,="" };="" run="" request="" const="" [operation]="await" translationclient.batchtranslatedocument(request);="" const="" [response]="await" operation.promise();="" console.log(response);="" }="" callbatchtranslatedocument();="">
checkBatchTranslateTextProgress(name)
checkBatchTranslateTextProgress(name: string): Promise<LROperation<protos.google.cloud.translation.v3beta1.BatchTranslateResponse, protos.google.cloud.translation.v3beta1.BatchTranslateMetadata>>;
Check the status of the long running operation returned by batchTranslateText()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.cloud.translation.v3beta1.BatchTranslateResponse, protos.google.cloud.translation.v3beta1.BatchTranslateMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Location to make a call. Must refer to a caller's project.
* Format: `projects/{project-number-or-id}/locations/{location-id}`.
* The `global` location is not supported for batch translation.
* Only AutoML Translation models or glossaries within the same region (have
* the same location-id) can be used, otherwise an INVALID_ARGUMENT (400)
* error is returned.
*/
// const parent = 'abc123'
/**
* Required. Source language code.
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. Specify up to 10 language codes here.
*/
// const targetLanguageCodes = 'abc123'
/**
* Optional. The models to use for translation. Map's key is target language
* code. Map's value is model name. Value can be a built-in general model,
* or an AutoML Translation model.
* The value format depends on model type:
* - AutoML Translation models:
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* - General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* If the map is empty or a specific model is
* not requested for a language pair, then default google model (nmt) is used.
*/
// const models = 1234
/**
* Required. Input configurations.
* The total number of files matched should be <= 100.="" *="" the="" total="" content="" size="" should="" be=""><= 100m="" unicode="" codepoints.="" *="" the="" files="" must="" use="" utf-8="" encoding.="" */="" const="" inputconfigs="1234" *="" *="" required.="" output="" configuration.="" *="" if="" 2="" input="" configs="" match="" to="" the="" same="" file="" (that="" is,="" same="" input="" path),="" *="" we="" don't="" generate="" output="" for="" duplicate="" inputs.="" */="" const="" outputconfig="{}" *="" *="" optional.="" glossaries="" to="" be="" applied="" for="" translation.="" *="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="1234" *="" *="" optional.="" the="" labels="" with="" user-defined="" metadata="" for="" the="" request.="" *="" label="" keys="" and="" values="" can="" be="" no="" longer="" than="" 63="" characters="" *="" (unicode="" codepoints),="" can="" only="" contain="" lowercase="" letters,="" numeric="" *="" characters,="" underscores="" and="" dashes.="" international="" characters="" are="" allowed.="" *="" label="" values="" are="" optional.="" label="" keys="" must="" start="" with="" a="" letter.="" *="" see="" https://cloud.google.com/translate/docs/labels="" for="" more="" information.="" */="" const="" labels="1234" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3beta1;" instantiates="" a="" client="" const="" translationclient="new" translationserviceclient();="" async="" function="" callbatchtranslatetext()="" {="" construct="" request="" const="" request="{" parent,="" sourcelanguagecode,="" targetlanguagecodes,="" inputconfigs,="" outputconfig,="" };="" run="" request="" const="" [operation]="await" translationclient.batchtranslatetext(request);="" const="" [response]="await" operation.promise();="" console.log(response);="" }="" callbatchtranslatetext();="">
checkCreateGlossaryProgress(name)
checkCreateGlossaryProgress(name: string): Promise<LROperation<protos.google.cloud.translation.v3beta1.Glossary, protos.google.cloud.translation.v3beta1.CreateGlossaryMetadata>>;
Check the status of the long running operation returned by createGlossary()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.cloud.translation.v3beta1.Glossary, protos.google.cloud.translation.v3beta1.CreateGlossaryMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The project name.
*/
// const parent = 'abc123'
/**
* Required. The glossary to create.
*/
// const glossary = {}
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callCreateGlossary() {
// Construct request
const request = {
parent,
glossary,
};
// Run request
const [operation] = await translationClient.createGlossary(request);
const [response] = await operation.promise();
console.log(response);
}
callCreateGlossary();
checkDeleteGlossaryProgress(name)
checkDeleteGlossaryProgress(name: string): Promise<LROperation<protos.google.cloud.translation.v3beta1.DeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.DeleteGlossaryMetadata>>;
Check the status of the long running operation returned by deleteGlossary()
.
Name | Description |
name |
string
The operation name that will be passed. |
Type | Description |
Promise<LROperation<protos.google.cloud.translation.v3beta1.DeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.DeleteGlossaryMetadata>> | {Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the glossary to delete.
*/
// const name = 'abc123'
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callDeleteGlossary() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await translationClient.deleteGlossary(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteGlossary();
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
createGlossary(request, options)
createGlossary(request?: protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The project name.
*/
// const parent = 'abc123'
/**
* Required. The glossary to create.
*/
// const glossary = {}
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callCreateGlossary() {
// Construct request
const request = {
parent,
glossary,
};
// Run request
const [operation] = await translationClient.createGlossary(request);
const [response] = await operation.promise();
console.log(response);
}
callCreateGlossary();
createGlossary(request, options, callback)
createGlossary(request: protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
createGlossary(request, callback)
createGlossary(request: protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteGlossary(request, options)
deleteGlossary(request?: protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest, options?: CallOptions): Promise<[
LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>,
protos.google.longrunning.IOperation | undefined,
{} | undefined
]>;
Deletes a glossary, or cancels glossary construction if the glossary isn't created yet. Returns NOT_FOUND, if the glossary doesn't exist.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the glossary to delete.
*/
// const name = 'abc123'
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callDeleteGlossary() {
// Construct request
const request = {
name,
};
// Run request
const [operation] = await translationClient.deleteGlossary(request);
const [response] = await operation.promise();
console.log(response);
}
callDeleteGlossary();
deleteGlossary(request, options, callback)
deleteGlossary(request: protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest
|
options |
CallOptions
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
deleteGlossary(request, callback)
deleteGlossary(request: protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest
|
callback |
Callback<LROperation<protos.google.cloud.translation.v3beta1.IDeleteGlossaryResponse, protos.google.cloud.translation.v3beta1.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
|
Type | Description |
void |
detectLanguage(request, options)
detectLanguage(request?: protos.google.cloud.translation.v3beta1.IDetectLanguageRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.IDetectLanguageResponse,
(protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | undefined),
{} | undefined
]>;
Detects the language of text within a request.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDetectLanguageRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, (protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | undefined), {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [DetectLanguageResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Project or location to make a call. Must refer to a caller's
* project.
* Format: `projects/{project-number-or-id}/locations/{location-id}` or
* `projects/{project-number-or-id}`.
* For global calls, use `projects/{project-number-or-id}/locations/global` or
* `projects/{project-number-or-id}`.
* Only models within the same region (has same location-id) can be used.
* Otherwise an INVALID_ARGUMENT (400) error is returned.
*/
// const parent = 'abc123'
/**
* Optional. The language detection model to be used.
* Format:
* `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/{model-id}`
* Only one language detection model is currently supported:
* `projects/{project-number-or-id}/locations/{location-id}/models/language-detection/default`.
* If not specified, the default model is used.
*/
// const model = 'abc123'
/**
* The content of the input stored as a string.
*/
// const content = 'abc123'
/**
* Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
*/
// const mimeType = 'abc123'
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
* (Unicode codepoints), can only contain lowercase letters, numeric
* characters, underscores and dashes. International characters are allowed.
* Label values are optional. Label keys must start with a letter.
* See https://cloud.google.com/translate/docs/labels for more information.
*/
// const labels = 1234
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callDetectLanguage() {
// Construct request
const request = {
parent,
};
// Run request
const response = await translationClient.detectLanguage(request);
console.log(response);
}
callDetectLanguage();
detectLanguage(request, options, callback)
detectLanguage(request: protos.google.cloud.translation.v3beta1.IDetectLanguageRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDetectLanguageRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
detectLanguage(request, callback)
detectLanguage(request: protos.google.cloud.translation.v3beta1.IDetectLanguageRequest, callback: Callback<protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IDetectLanguageRequest
|
callback |
Callback<protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, protos.google.cloud.translation.v3beta1.IDetectLanguageRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getGlossary(request, options)
getGlossary(request?: protos.google.cloud.translation.v3beta1.IGetGlossaryRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.IGlossary,
protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | undefined,
{} | undefined
]>;
Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetGlossaryRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [Glossary]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the glossary to retrieve.
*/
// const name = 'abc123'
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callGetGlossary() {
// Construct request
const request = {
name,
};
// Run request
const response = await translationClient.getGlossary(request);
console.log(response);
}
callGetGlossary();
getGlossary(request, options, callback)
getGlossary(request: protos.google.cloud.translation.v3beta1.IGetGlossaryRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetGlossaryRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getGlossary(request, callback)
getGlossary(request: protos.google.cloud.translation.v3beta1.IGetGlossaryRequest, callback: Callback<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetGlossaryRequest
|
callback |
Callback<protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getProjectId()
getProjectId(): Promise<string>;
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Type | Description |
void |
getSupportedLanguages(request, options)
getSupportedLanguages(request?: protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.ISupportedLanguages,
(protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | undefined),
{} | undefined
]>;
Returns a list of supported languages for translation.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.ISupportedLanguages, (protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | undefined), {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [SupportedLanguages]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Project or location to make a call. Must refer to a caller's
* project.
* Format: `projects/{project-number-or-id}` or
* `projects/{project-number-or-id}/locations/{location-id}`.
* For global calls, use `projects/{project-number-or-id}/locations/global` or
* `projects/{project-number-or-id}`.
* Non-global location is required for AutoML models.
* Only models within the same region (have same location-id) can be used,
* otherwise an INVALID_ARGUMENT (400) error is returned.
*/
// const parent = 'abc123'
/**
* Optional. The language to use to return localized, human readable names
* of supported languages. If missing, then display names are not returned
* in a response.
*/
// const displayLanguageCode = 'abc123'
/**
* Optional. Get supported languages of this model.
* The format depends on model type:
* - AutoML Translation models:
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* - General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* Returns languages supported by the specified model.
* If missing, we get supported languages of Google general NMT model.
*/
// const model = 'abc123'
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callGetSupportedLanguages() {
// Construct request
const request = {
parent,
};
// Run request
const response = await translationClient.getSupportedLanguages(request);
console.log(response);
}
callGetSupportedLanguages();
getSupportedLanguages(request, options, callback)
getSupportedLanguages(request: protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3beta1.ISupportedLanguages, protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ISupportedLanguages, protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
getSupportedLanguages(request, callback)
getSupportedLanguages(request: protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest, callback: Callback<protos.google.cloud.translation.v3beta1.ISupportedLanguages, protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ISupportedLanguages, protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
glossaryPath(project, location, glossary)
glossaryPath(project: string, location: string, glossary: string): string;
Return a fully-qualified glossary resource name string.
Name | Description |
project |
string
|
location |
string
|
glossary |
string
|
Type | Description |
string | {string} Resource name string. |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Type | Description |
Promise<{ [name: string]: Function; }> | {Promise} A promise that resolves to an authenticated service stub. |
listGlossaries(request, options)
listGlossaries(request?: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.IGlossary[],
protos.google.cloud.translation.v3beta1.IListGlossariesRequest | null,
protos.google.cloud.translation.v3beta1.IListGlossariesResponse
]>;
Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IListGlossariesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.IGlossary[], protos.google.cloud.translation.v3beta1.IListGlossariesRequest | null, protos.google.cloud.translation.v3beta1.IListGlossariesResponse ]> | {Promise} - The promise which resolves to an array. The first element of the array is Array of [Glossary]. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listGlossaries(request, options, callback)
listGlossaries(request: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.translation.v3beta1.IListGlossariesRequest, protos.google.cloud.translation.v3beta1.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3beta1.IGlossary>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IListGlossariesRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.cloud.translation.v3beta1.IListGlossariesRequest, protos.google.cloud.translation.v3beta1.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3beta1.IGlossary>
|
Type | Description |
void |
listGlossaries(request, callback)
listGlossaries(request: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, callback: PaginationCallback<protos.google.cloud.translation.v3beta1.IListGlossariesRequest, protos.google.cloud.translation.v3beta1.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3beta1.IGlossary>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IListGlossariesRequest
|
callback |
PaginationCallback<protos.google.cloud.translation.v3beta1.IListGlossariesRequest, protos.google.cloud.translation.v3beta1.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3beta1.IGlossary>
|
Type | Description |
void |
listGlossariesAsync(request, options)
listGlossariesAsync(request?: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.translation.v3beta1.IGlossary>;
Equivalent to listGlossaries
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IListGlossariesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
AsyncIterable<protos.google.cloud.translation.v3beta1.IGlossary> | {Object} An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). When you iterate the returned iterable, each element will be an object representing [Glossary]. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the project from which to list all of the glossaries.
*/
// const parent = 'abc123'
/**
* Optional. Requested page size. The server may return fewer glossaries than
* requested. If unspecified, the server picks an appropriate default.
*/
// const pageSize = 1234
/**
* Optional. A token identifying a page of results the server should return.
* Typically, this is the value of ListGlossariesResponse.next_page_token
* returned from the previous call to `ListGlossaries` method.
* The first page is returned if `page_token`is empty or missing.
*/
// const pageToken = 'abc123'
/**
* Optional. Filter specifying constraints of a list operation.
* Specify the constraint by the format of "key=value", where key must be
* "src" or "tgt", and the value must be a valid language code.
* For multiple restrictions, concatenate them by "AND" (uppercase only),
* such as: "src=en-US AND tgt=zh-CN". Notice that the exact match is used
* here, which means using 'en-US' and 'en' can lead to different results,
* which depends on the language code you used when you create the glossary.
* For the unidirectional glossaries, the "src" and "tgt" add restrictions
* on the source and target language code separately.
* For the equivalent term set glossaries, the "src" and/or "tgt" add
* restrictions on the term set.
* For example: "src=en-US AND tgt=zh-CN" will only pick the unidirectional
* glossaries which exactly match the source language code as "en-US" and the
* target language code "zh-CN", but all equivalent term set glossaries which
* contain "en-US" and "zh-CN" in their language set will be picked.
* If missing, no filtering is performed.
*/
// const filter = 'abc123'
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callListGlossaries() {
// Construct request
const request = {
parent,
};
// Run request
const iterable = await translationClient.listGlossariesAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListGlossaries();
listGlossariesStream(request, options)
listGlossariesStream(request?: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.IListGlossariesRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Transform | {Stream} An object stream which emits an object representing [Glossary] on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
locationPath(project, location)
locationPath(project: string, location: string): string;
Return a fully-qualified location resource name string.
Name | Description |
project |
string
|
location |
string
|
Type | Description |
string | {string} Resource name string. |
matchGlossaryFromGlossaryName(glossaryName)
matchGlossaryFromGlossaryName(glossaryName: string): string | number;
Parse the glossary from Glossary resource.
Name | Description |
glossaryName |
string
A fully-qualified path representing Glossary resource. |
Type | Description |
string | number | {string} A string representing the glossary. |
matchLocationFromGlossaryName(glossaryName)
matchLocationFromGlossaryName(glossaryName: string): string | number;
Parse the location from Glossary resource.
Name | Description |
glossaryName |
string
A fully-qualified path representing Glossary resource. |
Type | Description |
string | number | {string} A string representing the location. |
matchLocationFromLocationName(locationName)
matchLocationFromLocationName(locationName: string): string | number;
Parse the location from Location resource.
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Type | Description |
string | number | {string} A string representing the location. |
matchProjectFromGlossaryName(glossaryName)
matchProjectFromGlossaryName(glossaryName: string): string | number;
Parse the project from Glossary resource.
Name | Description |
glossaryName |
string
A fully-qualified path representing Glossary resource. |
Type | Description |
string | number | {string} A string representing the project. |
matchProjectFromLocationName(locationName)
matchProjectFromLocationName(locationName: string): string | number;
Parse the project from Location resource.
Name | Description |
locationName |
string
A fully-qualified path representing Location resource. |
Type | Description |
string | number | {string} A string representing the project. |
translateDocument(request, options)
translateDocument(request?: protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse,
(protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | undefined),
{} | undefined
]>;
Translates documents in synchronous mode.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse, (protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | undefined), {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [TranslateDocumentResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. Location to make a regional call.
* Format: `projects/{project-number-or-id}/locations/{location-id}`.
* For global calls, use `projects/{project-number-or-id}/locations/global`.
* Non-global location is required for requests using AutoML models or custom
* glossaries.
* Models and glossaries must be within the same region (have the same
* location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
*/
// const parent = 'abc123'
/**
* Optional. The BCP-47 language code of the input document if known, for
* example, "en-US" or "sr-Latn". Supported language codes are listed in
* Language Support. If the source language isn't specified, the API attempts
* to identify the source language automatically and returns the source
* language within the response. Source language must be specified if the
* request contains a glossary or a custom model.
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. The BCP-47 language code to use for translation of the input
* document, set to one of the language codes listed in Language Support.
*/
// const targetLanguageCode = 'abc123'
/**
* Required. Input configurations.
*/
// const documentInputConfig = {}
/**
* Optional. Output configurations.
* Defines if the output file should be stored within Cloud Storage as well
* as the desired output format. If not provided the translated file will
* only be returned through a byte-stream and its output mime type will be
* the same as the input file's mime type.
*/
// const documentOutputConfig = {}
/**
* Optional. The `model` type requested for this translation.
* The format depends on model type:
* - AutoML Translation models:
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* - General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* If not provided, the default Google model (NMT) will be used for
* translation.
*/
// const model = 'abc123'
/**
* Optional. Glossary to be applied. The glossary must be within the same
* region (have the same location-id) as the model, otherwise an
* INVALID_ARGUMENT (400) error is returned.
*/
// const glossaryConfig = {}
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters (Unicode
* codepoints), can only contain lowercase letters, numeric characters,
* underscores and dashes. International characters are allowed. Label values
* are optional. Label keys must start with a letter.
* See https://cloud.google.com/translate/docs/advanced/labels for more
* information.
*/
// const labels = 1234
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callTranslateDocument() {
// Construct request
const request = {
parent,
targetLanguageCode,
documentInputConfig,
};
// Run request
const response = await translationClient.translateDocument(request);
console.log(response);
}
callTranslateDocument();
translateDocument(request, options, callback)
translateDocument(request: protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse, protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse, protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
translateDocument(request, callback)
translateDocument(request: protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest, callback: Callback<protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse, protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ITranslateDocumentResponse, protos.google.cloud.translation.v3beta1.ITranslateDocumentRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
translateText(request, options)
translateText(request?: protos.google.cloud.translation.v3beta1.ITranslateTextRequest, options?: CallOptions): Promise<[
protos.google.cloud.translation.v3beta1.ITranslateTextResponse,
protos.google.cloud.translation.v3beta1.ITranslateTextRequest | undefined,
{} | undefined
]>;
Translates input text and returns translated text.
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateTextRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
Promise<[ protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest | undefined, {} | undefined ]> | {Promise} - The promise which resolves to an array. The first element of the array is an object representing [TranslateTextResponse]. Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The content of the input in string format.
* We recommend the total content be less than 30k codepoints. The max length
* of this field is 1024.
* Use BatchTranslateText for larger text.
*/
// const contents = 'abc123'
/**
* Optional. The format of the source text, for example, "text/html",
* "text/plain". If left blank, the MIME type defaults to "text/html".
*/
// const mimeType = 'abc123'
/**
* Optional. The BCP-47 language code of the input text if
* known, for example, "en-US" or "sr-Latn". Supported language codes are
* listed in Language Support. If the source language isn't specified, the API
* attempts to identify the source language automatically and returns the
* source language within the response.
*/
// const sourceLanguageCode = 'abc123'
/**
* Required. The BCP-47 language code to use for translation of the input
* text, set to one of the language codes listed in Language Support.
*/
// const targetLanguageCode = 'abc123'
/**
* Required. Project or location to make a call. Must refer to a caller's
* project.
* Format: `projects/{project-number-or-id}` or
* `projects/{project-number-or-id}/locations/{location-id}`.
* For global calls, use `projects/{project-number-or-id}/locations/global` or
* `projects/{project-number-or-id}`.
* Non-global location is required for requests using AutoML models or
* custom glossaries.
* Models and glossaries must be within the same region (have same
* location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
*/
// const parent = 'abc123'
/**
* Optional. The `model` type requested for this translation.
* The format depends on model type:
* - AutoML Translation models:
* `projects/{project-number-or-id}/locations/{location-id}/models/{model-id}`
* - General (built-in) models:
* `projects/{project-number-or-id}/locations/{location-id}/models/general/nmt`,
* For global (non-regionalized) requests, use `location-id` `global`.
* For example,
* `projects/{project-number-or-id}/locations/global/models/general/nmt`.
* If not provided, the default Google model (NMT) will be used
*/
// const model = 'abc123'
/**
* Optional. Glossary to be applied. The glossary must be
* within the same region (have the same location-id) as the model, otherwise
* an INVALID_ARGUMENT (400) error is returned.
*/
// const glossaryConfig = {}
/**
* Optional. The labels with user-defined metadata for the request.
* Label keys and values can be no longer than 63 characters
* (Unicode codepoints), can only contain lowercase letters, numeric
* characters, underscores and dashes. International characters are allowed.
* Label values are optional. Label keys must start with a letter.
* See https://cloud.google.com/translate/docs/labels for more information.
*/
// const labels = 1234
// Imports the Translation library
const {TranslationServiceClient} = require('@google-cloud/translate').v3beta1;
// Instantiates a client
const translationClient = new TranslationServiceClient();
async function callTranslateText() {
// Construct request
const request = {
contents,
targetLanguageCode,
parent,
};
// Run request
const response = await translationClient.translateText(request);
console.log(response);
}
callTranslateText();
translateText(request, options, callback)
translateText(request: protos.google.cloud.translation.v3beta1.ITranslateTextRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateTextRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |
translateText(request, callback)
translateText(request: protos.google.cloud.translation.v3beta1.ITranslateTextRequest, callback: Callback<protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest | null | undefined, {} | null | undefined>): void;
Name | Description |
request |
protos.google.cloud.translation.v3beta1.ITranslateTextRequest
|
callback |
Callback<protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest | null | undefined, {} | null | undefined>
|
Type | Description |
void |