Class v3.TranslationServiceClient (8.0.3)

Provides natural language translation operations. v3

Package

@google-cloud/translate

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of TranslationServiceClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new TranslationServiceClient({fallback: true}, gax); ```

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

adaptiveMtDatasetPath(project, location, dataset)

adaptiveMtDatasetPath(project: string, location: string, dataset: string): string;

Return a fully-qualified adaptiveMtDataset resource name string.

Parameters
NameDescription
project string
location string
dataset string
Returns
TypeDescription
string

{string} Resource name string.

adaptiveMtFilePath(project, location, dataset, file)

adaptiveMtFilePath(project: string, location: string, dataset: string, file: string): string;

Return a fully-qualified adaptiveMtFile resource name string.

Parameters
NameDescription
project string
location string
dataset string
file string
Returns
TypeDescription
string

{string} Resource name string.

adaptiveMtSentencePath(project, location, dataset, file, sentence)

adaptiveMtSentencePath(project: string, location: string, dataset: string, file: string, sentence: string): string;

Return a fully-qualified adaptiveMtSentence resource name string.

Parameters
NameDescription
project string
location string
dataset string
file string
sentence string
Returns
TypeDescription
string

{string} Resource name string.

adaptiveMtTranslate(request, options)

adaptiveMtTranslate(request?: protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse,
        (protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | undefined),
        {} | undefined
    ]>;

Translate text using Adaptive MT.

Parameters
NameDescription
request IAdaptiveMtTranslateRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse, (protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AdaptiveMtTranslateResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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}`.
   */
  // const parent = 'abc123'
  /**
   *  Required. The resource name for the dataset to use for adaptive MT.
   *  `projects/{project}/locations/{location-id}/adaptiveMtDatasets/{dataset}`
   */
  // const dataset = 'abc123'
  /**
   *  Required. The content of the input in string format.
   *  For now only one sentence per request is supported.
   */
  // const content = ['abc','def']

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callAdaptiveMtTranslate() {
    // Construct request
    const request = {
      parent,
      dataset,
      content,
    };

    // Run request
    const response = await translationClient.adaptiveMtTranslate(request);
    console.log(response);
  }

  callAdaptiveMtTranslate();

adaptiveMtTranslate(request, options, callback)

adaptiveMtTranslate(request: protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse, protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAdaptiveMtTranslateRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse, protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

adaptiveMtTranslate(request, callback)

adaptiveMtTranslate(request: protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse, protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAdaptiveMtTranslateRequest
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtTranslateResponse, protos.google.cloud.translation.v3.IAdaptiveMtTranslateRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchTranslateDocument(request, options)

batchTranslateDocument(request?: protos.google.cloud.translation.v3.IBatchTranslateDocumentRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.IBatchTranslateDocumentMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Translates a large volume of document 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.

Parameters
NameDescription
request IBatchTranslateDocumentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.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 promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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 ISO-639 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 ISO-639 language code to use for translation of the input
   *  document. Specify up to 10 language codes here.
   */
  // const targetLanguageCodes = ['abc','def']
  /**
   *  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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" *="" *="" optional.="" glossaries="" to="" be="" applied.="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="[1,2,3,4]" *="" *="" optional.="" the="" file="" format="" conversion="" map="" that="" is="" applied="" to="" all="" input="" *="" files.="" the="" map="" key="" is="" the="" original="" mime_type.="" the="" map="" 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="[1,2,3,4]" *="" *="" optional.="" this="" flag="" is="" to="" support="" user="" customized="" attribution.="" *="" if="" not="" provided,="" the="" default="" is="" `machine="" translated="" by="" google`.="" *="" customized="" attribution="" should="" follow="" rules="" in="" *="" https://cloud.google.com/translate/attribution#attribution_and_logos="" */="" const="" customizedattribution='abc123' *="" *="" optional.="" if="" true,="" use="" the="" text="" removal="" server="" to="" remove="" the="" shadow="" text="" on="" *="" background="" image="" for="" native="" pdf="" translation.="" *="" shadow="" removal="" feature="" can="" only="" be="" enabled="" when="" *="" is_translate_native_pdf_only:="" false="" &&="" pdf_native_only:="" false="" */="" const="" enableshadowremovalnativepdf="true" *="" *="" optional.="" if="" true,="" enable="" auto="" rotation="" correction="" in="" dvs.="" */="" const="" enablerotationcorrection="true" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3;" 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.v3.IBatchTranslateDocumentRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IBatchTranslateDocumentRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchTranslateDocument(request, callback)

batchTranslateDocument(request: protos.google.cloud.translation.v3.IBatchTranslateDocumentRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IBatchTranslateDocumentRequest
callback Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateDocumentResponse, protos.google.cloud.translation.v3.IBatchTranslateDocumentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchTranslateText(request, options)

batchTranslateText(request?: protos.google.cloud.translation.v3.IBatchTranslateTextRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.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.

Parameters
NameDescription
request IBatchTranslateTextRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.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 promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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 = ['abc','def']
  /**
   *  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 = [1,2,3,4]
  /**
   *  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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3;" 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.v3.IBatchTranslateTextRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IBatchTranslateTextRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

batchTranslateText(request, callback)

batchTranslateText(request: protos.google.cloud.translation.v3.IBatchTranslateTextRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IBatchTranslateTextRequest
callback Callback<LROperation<protos.google.cloud.translation.v3.IBatchTranslateResponse, protos.google.cloud.translation.v3.IBatchTranslateMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

checkBatchTranslateDocumentProgress(name)

checkBatchTranslateDocumentProgress(name: string): Promise<LROperation<protos.google.cloud.translation.v3.BatchTranslateDocumentResponse, protos.google.cloud.translation.v3.BatchTranslateDocumentMetadata>>;

Check the status of the long running operation returned by batchTranslateDocument().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.translation.v3.BatchTranslateDocumentResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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 ISO-639 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 ISO-639 language code to use for translation of the input
   *  document. Specify up to 10 language codes here.
   */
  // const targetLanguageCodes = ['abc','def']
  /**
   *  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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" *="" *="" optional.="" glossaries="" to="" be="" applied.="" it's="" keyed="" by="" target="" language="" code.="" */="" const="" glossaries="[1,2,3,4]" *="" *="" optional.="" the="" file="" format="" conversion="" map="" that="" is="" applied="" to="" all="" input="" *="" files.="" the="" map="" key="" is="" the="" original="" mime_type.="" the="" map="" 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="[1,2,3,4]" *="" *="" optional.="" this="" flag="" is="" to="" support="" user="" customized="" attribution.="" *="" if="" not="" provided,="" the="" default="" is="" `machine="" translated="" by="" google`.="" *="" customized="" attribution="" should="" follow="" rules="" in="" *="" https://cloud.google.com/translate/attribution#attribution_and_logos="" */="" const="" customizedattribution='abc123' *="" *="" optional.="" if="" true,="" use="" the="" text="" removal="" server="" to="" remove="" the="" shadow="" text="" on="" *="" background="" image="" for="" native="" pdf="" translation.="" *="" shadow="" removal="" feature="" can="" only="" be="" enabled="" when="" *="" is_translate_native_pdf_only:="" false="" &&="" pdf_native_only:="" false="" */="" const="" enableshadowremovalnativepdf="true" *="" *="" optional.="" if="" true,="" enable="" auto="" rotation="" correction="" in="" dvs.="" */="" const="" enablerotationcorrection="true" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3;" 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.v3.BatchTranslateResponse, protos.google.cloud.translation.v3.BatchTranslateMetadata>>;

Check the status of the long running operation returned by batchTranslateText().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.translation.v3.BatchTranslateResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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 = ['abc','def']
  /**
   *  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 = [1,2,3,4]
  /**
   *  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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" *="" *="" 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="[1,2,3,4]" imports="" the="" translation="" library="" const="" {translationserviceclient}="require('@google-cloud/translate').v3;" 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.v3.Glossary, protos.google.cloud.translation.v3.CreateGlossaryMetadata>>;

Check the status of the long running operation returned by createGlossary().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.translation.v3.Glossary, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.DeleteGlossaryResponse, protos.google.cloud.translation.v3.DeleteGlossaryMetadata>>;

Check the status of the long running operation returned by deleteGlossary().

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.translation.v3.DeleteGlossaryResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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').v3;

  // 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.

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

createAdaptiveMtDataset(request, options)

createAdaptiveMtDataset(request?: protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtDataset,
        (protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | undefined),
        {} | undefined
    ]>;

Creates an Adaptive MT dataset.

Parameters
NameDescription
request ICreateAdaptiveMtDatasetRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtDataset, (protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AdaptiveMtDataset. Please see the documentation for more details and examples.

Example

  /**
   * 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. Name of the parent project. In form of
   *  `projects/{project-number-or-id}/locations/{location-id}`
   */
  // const parent = 'abc123'
  /**
   *  Required. The AdaptiveMtDataset to be created.
   */
  // const adaptiveMtDataset = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callCreateAdaptiveMtDataset() {
    // Construct request
    const request = {
      parent,
      adaptiveMtDataset,
    };

    // Run request
    const response = await translationClient.createAdaptiveMtDataset(request);
    console.log(response);
  }

  callCreateAdaptiveMtDataset();

createAdaptiveMtDataset(request, options, callback)

createAdaptiveMtDataset(request: protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateAdaptiveMtDatasetRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createAdaptiveMtDataset(request, callback)

createAdaptiveMtDataset(request: protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateAdaptiveMtDatasetRequest
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.ICreateAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createGlossary(request, options)

createGlossary(request?: protos.google.cloud.translation.v3.ICreateGlossaryRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.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.

Parameters
NameDescription
request ICreateGlossaryRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.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 promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.ICreateGlossaryRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateGlossaryRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

createGlossary(request, callback)

createGlossary(request: protos.google.cloud.translation.v3.ICreateGlossaryRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ICreateGlossaryRequest
callback Callback<LROperation<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.ICreateGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteAdaptiveMtDataset(request, options)

deleteAdaptiveMtDataset(request?: protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | undefined),
        {} | undefined
    ]>;

Deletes an Adaptive MT dataset, including all its entries and associated metadata.

Parameters
NameDescription
request IDeleteAdaptiveMtDatasetRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.protobuf.IEmpty, (protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * 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. Name of the dataset. In the form of
   *  `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callDeleteAdaptiveMtDataset() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await translationClient.deleteAdaptiveMtDataset(request);
    console.log(response);
  }

  callDeleteAdaptiveMtDataset();

deleteAdaptiveMtDataset(request, options, callback)

deleteAdaptiveMtDataset(request: protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteAdaptiveMtDatasetRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteAdaptiveMtDataset(request, callback)

deleteAdaptiveMtDataset(request: protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteAdaptiveMtDatasetRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteAdaptiveMtFile(request, options)

deleteAdaptiveMtFile(request?: protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest, options?: CallOptions): Promise<[
        protos.google.protobuf.IEmpty,
        (protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | undefined),
        {} | undefined
    ]>;

Deletes an AdaptiveMtFile along with its sentences.

Parameters
NameDescription
request IDeleteAdaptiveMtFileRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.protobuf.IEmpty, (protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Empty. Please see the documentation for more details and examples.

Example

  /**
   * 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 resource name of the file to delete, in form of
   *  `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callDeleteAdaptiveMtFile() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await translationClient.deleteAdaptiveMtFile(request);
    console.log(response);
  }

  callDeleteAdaptiveMtFile();

deleteAdaptiveMtFile(request, options, callback)

deleteAdaptiveMtFile(request: protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest, options: CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteAdaptiveMtFileRequest
options CallOptions
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteAdaptiveMtFile(request, callback)

deleteAdaptiveMtFile(request: protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteAdaptiveMtFileRequest
callback Callback<protos.google.protobuf.IEmpty, protos.google.cloud.translation.v3.IDeleteAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteGlossary(request, options)

deleteGlossary(request?: protos.google.cloud.translation.v3.IDeleteGlossaryRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.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.

Parameters
NameDescription
request IDeleteGlossaryRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.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 promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.IDeleteGlossaryRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteGlossaryRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteGlossary(request, callback)

deleteGlossary(request: protos.google.cloud.translation.v3.IDeleteGlossaryRequest, callback: Callback<LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteGlossaryRequest
callback Callback<LROperation<protos.google.cloud.translation.v3.IDeleteGlossaryResponse, protos.google.cloud.translation.v3.IDeleteGlossaryMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

detectLanguage(request, options)

detectLanguage(request?: protos.google.cloud.translation.v3.IDetectLanguageRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IDetectLanguageResponse,
        protos.google.cloud.translation.v3.IDetectLanguageRequest | undefined,
        {} | undefined
    ]>;

Detects the language of text within a request.

Parameters
NameDescription
request IDetectLanguageRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IDetectLanguageResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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/advanced/labels for more
   *  information.
   */
  // const labels = [1,2,3,4]

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // 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.v3.IDetectLanguageRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IDetectLanguageResponse, protos.google.cloud.translation.v3.IDetectLanguageRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDetectLanguageRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IDetectLanguageResponse, protos.google.cloud.translation.v3.IDetectLanguageRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

detectLanguage(request, callback)

detectLanguage(request: protos.google.cloud.translation.v3.IDetectLanguageRequest, callback: Callback<protos.google.cloud.translation.v3.IDetectLanguageResponse, protos.google.cloud.translation.v3.IDetectLanguageRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDetectLanguageRequest
callback Callback<protos.google.cloud.translation.v3.IDetectLanguageResponse, protos.google.cloud.translation.v3.IDetectLanguageRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getAdaptiveMtDataset(request, options)

getAdaptiveMtDataset(request?: protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtDataset,
        (protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | undefined),
        {} | undefined
    ]>;

Gets the Adaptive MT dataset.

Parameters
NameDescription
request IGetAdaptiveMtDatasetRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtDataset, (protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AdaptiveMtDataset. Please see the documentation for more details and examples.

Example

  /**
   * 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. Name of the dataset. In the form of
   *  `projects/{project-number-or-id}/locations/{location-id}/adaptiveMtDatasets/{adaptive-mt-dataset-id}`
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callGetAdaptiveMtDataset() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await translationClient.getAdaptiveMtDataset(request);
    console.log(response);
  }

  callGetAdaptiveMtDataset();

getAdaptiveMtDataset(request, options, callback)

getAdaptiveMtDataset(request: protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetAdaptiveMtDatasetRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getAdaptiveMtDataset(request, callback)

getAdaptiveMtDataset(request: protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetAdaptiveMtDatasetRequest
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtDataset, protos.google.cloud.translation.v3.IGetAdaptiveMtDatasetRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getAdaptiveMtFile(request, options)

getAdaptiveMtFile(request?: protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtFile,
        protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | undefined,
        {} | undefined
    ]>;

Gets and AdaptiveMtFile

Parameters
NameDescription
request IGetAdaptiveMtFileRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtFile, protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AdaptiveMtFile. Please see the documentation for more details and examples.

Example

  /**
   * 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 resource name of the file, in form of
   *  `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
   */
  // const name = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callGetAdaptiveMtFile() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await translationClient.getAdaptiveMtFile(request);
    console.log(response);
  }

  callGetAdaptiveMtFile();

getAdaptiveMtFile(request, options, callback)

getAdaptiveMtFile(request: protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtFile, protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetAdaptiveMtFileRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtFile, protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getAdaptiveMtFile(request, callback)

getAdaptiveMtFile(request: protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest, callback: Callback<protos.google.cloud.translation.v3.IAdaptiveMtFile, protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetAdaptiveMtFileRequest
callback Callback<protos.google.cloud.translation.v3.IAdaptiveMtFile, protos.google.cloud.translation.v3.IGetAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getGlossary(request, options)

getGlossary(request?: protos.google.cloud.translation.v3.IGetGlossaryRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IGlossary,
        protos.google.cloud.translation.v3.IGetGlossaryRequest | undefined,
        {} | undefined
    ]>;

Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Parameters
NameDescription
request IGetGlossaryRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.IGetGlossaryRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.IGetGlossaryRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.IGetGlossaryRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetGlossaryRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.IGetGlossaryRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getGlossary(request, callback)

getGlossary(request: protos.google.cloud.translation.v3.IGetGlossaryRequest, callback: Callback<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.IGetGlossaryRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetGlossaryRequest
callback Callback<protos.google.cloud.translation.v3.IGlossary, protos.google.cloud.translation.v3.IGetGlossaryRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

getSupportedLanguages(request, options)

getSupportedLanguages(request?: protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.ISupportedLanguages,
        (protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest | undefined),
        {} | undefined
    ]>;

Returns a list of supported languages for translation.

Parameters
NameDescription
request IGetSupportedLanguagesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.ISupportedLanguages, (protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.IGetSupportedLanguagesRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.ISupportedLanguages, protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSupportedLanguagesRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.ISupportedLanguages, protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getSupportedLanguages(request, callback)

getSupportedLanguages(request: protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest, callback: Callback<protos.google.cloud.translation.v3.ISupportedLanguages, protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetSupportedLanguagesRequest
callback Callback<protos.google.cloud.translation.v3.ISupportedLanguages, protos.google.cloud.translation.v3.IGetSupportedLanguagesRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

glossaryPath(project, location, glossary)

glossaryPath(project: string, location: string, glossary: string): string;

Return a fully-qualified glossary resource name string.

Parameters
NameDescription
project string
location string
glossary string
Returns
TypeDescription
string

{string} Resource name string.

importAdaptiveMtFile(request, options)

importAdaptiveMtFile(request?: protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse,
        (protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | undefined),
        {} | undefined
    ]>;

Imports an AdaptiveMtFile and adds all of its sentences into the AdaptiveMtDataset.

Parameters
NameDescription
request IImportAdaptiveMtFileRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse, (protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | undefined), {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing ImportAdaptiveMtFileResponse. Please see the documentation for more details and examples.

Example

  /**
   * 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 resource name of the file, in form of
   *  `projects/{project-number-or-id}/locations/{location_id}/adaptiveMtDatasets/{dataset}`
   */
  // const parent = 'abc123'
  /**
   *  Inline file source.
   */
  // const fileInputSource = {}
  /**
   *  Google Cloud Storage file source.
   */
  // const gcsInputSource = {}

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callImportAdaptiveMtFile() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const response = await translationClient.importAdaptiveMtFile(request);
    console.log(response);
  }

  callImportAdaptiveMtFile();

importAdaptiveMtFile(request, options, callback)

importAdaptiveMtFile(request: protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse, protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IImportAdaptiveMtFileRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse, protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

importAdaptiveMtFile(request, callback)

importAdaptiveMtFile(request: protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest, callback: Callback<protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse, protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IImportAdaptiveMtFileRequest
callback Callback<protos.google.cloud.translation.v3.IImportAdaptiveMtFileResponse, protos.google.cloud.translation.v3.IImportAdaptiveMtFileRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

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.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

listAdaptiveMtDatasets(request, options)

listAdaptiveMtDatasets(request?: protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtDataset[],
        protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest | null,
        protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse
    ]>;

Lists all Adaptive MT datasets for which the caller has read permission.

Parameters
NameDescription
request IListAdaptiveMtDatasetsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtDataset[], protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest | null, protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of AdaptiveMtDataset. 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 listAdaptiveMtDatasetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtDatasets(request, options, callback)

listAdaptiveMtDatasets(request: protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtDataset>): void;
Parameters
NameDescription
request IListAdaptiveMtDatasetsRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtDataset>
Returns
TypeDescription
void

listAdaptiveMtDatasets(request, callback)

listAdaptiveMtDatasets(request: protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtDataset>): void;
Parameters
NameDescription
request IListAdaptiveMtDatasetsRequest
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtDataset>
Returns
TypeDescription
void

listAdaptiveMtDatasetsAsync(request, options)

listAdaptiveMtDatasetsAsync(request?: protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtDataset>;

Equivalent to listAdaptiveMtDatasets, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListAdaptiveMtDatasetsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtDataset>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtDataset. 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 for more details and examples.

Example

  /**
   * 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 resource name of the project from which to list the Adaptive
   *  MT datasets. `projects/{project-number-or-id}/locations/{location-id}`
   */
  // const parent = 'abc123'
  /**
   *  Optional. Requested page size. The server may return fewer results 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
   *  ListAdaptiveMtDatasetsResponse.next_page_token returned from the
   *  previous call to `ListAdaptiveMtDatasets` method. The first page is
   *  returned if `page_token`is empty or missing.
   */
  // const pageToken = 'abc123'
  /**
   *  Optional. An expression for filtering the results of the request.
   *  Filter is not supported yet.
   */
  // const filter = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtDatasets() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await translationClient.listAdaptiveMtDatasetsAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtDatasets();

listAdaptiveMtDatasetsStream(request, options)

listAdaptiveMtDatasetsStream(request?: protos.google.cloud.translation.v3.IListAdaptiveMtDatasetsRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListAdaptiveMtDatasetsRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing AdaptiveMtDataset 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 listAdaptiveMtDatasetsAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtFiles(request, options)

listAdaptiveMtFiles(request?: protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtFile[],
        protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest | null,
        protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse
    ]>;

Lists all AdaptiveMtFiles associated to an AdaptiveMtDataset.

Parameters
NameDescription
request IListAdaptiveMtFilesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtFile[], protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest | null, protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of AdaptiveMtFile. 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 listAdaptiveMtFilesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtFiles(request, options, callback)

listAdaptiveMtFiles(request: protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtFile>): void;
Parameters
NameDescription
request IListAdaptiveMtFilesRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtFile>
Returns
TypeDescription
void

listAdaptiveMtFiles(request, callback)

listAdaptiveMtFiles(request: protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtFile>): void;
Parameters
NameDescription
request IListAdaptiveMtFilesRequest
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtFilesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtFile>
Returns
TypeDescription
void

listAdaptiveMtFilesAsync(request, options)

listAdaptiveMtFilesAsync(request?: protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtFile>;

Equivalent to listAdaptiveMtFiles, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListAdaptiveMtFilesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtFile>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtFile. 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 for more details and examples.

Example

  /**
   * 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 resource name of the project from which to list the Adaptive
   *  MT files.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
   */
  // const parent = 'abc123'
  /**
   *  Optional.
   */
  // const pageSize = 1234
  /**
   *  Optional. A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListAdaptiveMtFilesResponse.next_page_token returned from the
   *  previous call to `ListAdaptiveMtFiles` method. The first page is
   *  returned if `page_token`is empty or missing.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtFiles() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await translationClient.listAdaptiveMtFilesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtFiles();

listAdaptiveMtFilesStream(request, options)

listAdaptiveMtFilesStream(request?: protos.google.cloud.translation.v3.IListAdaptiveMtFilesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListAdaptiveMtFilesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing AdaptiveMtFile 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 listAdaptiveMtFilesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtSentences(request, options)

listAdaptiveMtSentences(request?: protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IAdaptiveMtSentence[],
        protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest | null,
        protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse
    ]>;

Lists all AdaptiveMtSentences under a given file/dataset.

Parameters
NameDescription
request IListAdaptiveMtSentencesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IAdaptiveMtSentence[], protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest | null, protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of AdaptiveMtSentence. 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 listAdaptiveMtSentencesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listAdaptiveMtSentences(request, options, callback)

listAdaptiveMtSentences(request: protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtSentence>): void;
Parameters
NameDescription
request IListAdaptiveMtSentencesRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtSentence>
Returns
TypeDescription
void

listAdaptiveMtSentences(request, callback)

listAdaptiveMtSentences(request: protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, callback: PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtSentence>): void;
Parameters
NameDescription
request IListAdaptiveMtSentencesRequest
callback PaginationCallback<protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, protos.google.cloud.translation.v3.IListAdaptiveMtSentencesResponse | null | undefined, protos.google.cloud.translation.v3.IAdaptiveMtSentence>
Returns
TypeDescription
void

listAdaptiveMtSentencesAsync(request, options)

listAdaptiveMtSentencesAsync(request?: protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtSentence>;

Equivalent to listAdaptiveMtSentences, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListAdaptiveMtSentencesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.translation.v3.IAdaptiveMtSentence>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing AdaptiveMtSentence. 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 for more details and examples.

Example

  /**
   * 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 resource name of the project from which to list the Adaptive
   *  MT files. The following format lists all sentences under a file.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}/adaptiveMtFiles/{file}`
   *  The following format lists all sentences within a dataset.
   *  `projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset}`
   */
  // const parent = 'abc123'
  /**
   */
  // const pageSize = 1234
  /**
   *  A token identifying a page of results the server should return.
   *  Typically, this is the value of
   *  ListAdaptiveMtSentencesRequest.next_page_token returned from the
   *  previous call to `ListTranslationMemories` method. The first page is
   *  returned if `page_token` is empty or missing.
   */
  // const pageToken = 'abc123'

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // Instantiates a client
  const translationClient = new TranslationServiceClient();

  async function callListAdaptiveMtSentences() {
    // Construct request
    const request = {
      parent,
    };

    // Run request
    const iterable = await translationClient.listAdaptiveMtSentencesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListAdaptiveMtSentences();

listAdaptiveMtSentencesStream(request, options)

listAdaptiveMtSentencesStream(request?: protos.google.cloud.translation.v3.IListAdaptiveMtSentencesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListAdaptiveMtSentencesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing AdaptiveMtSentence 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 listAdaptiveMtSentencesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listGlossaries(request, options)

listGlossaries(request?: protos.google.cloud.translation.v3.IListGlossariesRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.IGlossary[],
        protos.google.cloud.translation.v3.IListGlossariesRequest | null,
        protos.google.cloud.translation.v3.IListGlossariesResponse
    ]>;

Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Parameters
NameDescription
request IListGlossariesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.IGlossary[], protos.google.cloud.translation.v3.IListGlossariesRequest | null, protos.google.cloud.translation.v3.IListGlossariesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . 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 listGlossariesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listGlossaries(request, options, callback)

listGlossaries(request: protos.google.cloud.translation.v3.IListGlossariesRequest, options: CallOptions, callback: PaginationCallback<protos.google.cloud.translation.v3.IListGlossariesRequest, protos.google.cloud.translation.v3.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3.IGlossary>): void;
Parameters
NameDescription
request IListGlossariesRequest
options CallOptions
callback PaginationCallback<protos.google.cloud.translation.v3.IListGlossariesRequest, protos.google.cloud.translation.v3.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3.IGlossary>
Returns
TypeDescription
void

listGlossaries(request, callback)

listGlossaries(request: protos.google.cloud.translation.v3.IListGlossariesRequest, callback: PaginationCallback<protos.google.cloud.translation.v3.IListGlossariesRequest, protos.google.cloud.translation.v3.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3.IGlossary>): void;
Parameters
NameDescription
request IListGlossariesRequest
callback PaginationCallback<protos.google.cloud.translation.v3.IListGlossariesRequest, protos.google.cloud.translation.v3.IListGlossariesResponse | null | undefined, protos.google.cloud.translation.v3.IGlossary>
Returns
TypeDescription
void

listGlossariesAsync(request, options)

listGlossariesAsync(request?: protos.google.cloud.translation.v3.IListGlossariesRequest, options?: CallOptions): AsyncIterable<protos.google.cloud.translation.v3.IGlossary>;

Equivalent to listGlossaries, but returns an iterable object.

for-await-of syntax is used with the iterable to get response elements on-demand.

Parameters
NameDescription
request IListGlossariesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.cloud.translation.v3.IGlossary>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . 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 for more details and examples.

Example

  /**
   * 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').v3;

  // 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.v3.IListGlossariesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListGlossariesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing 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 listGlossariesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

locationPath(project, location)

locationPath(project: string, location: string): string;

Return a fully-qualified location resource name string.

Parameters
NameDescription
project string
location string
Returns
TypeDescription
string

{string} Resource name string.

matchDatasetFromAdaptiveMtDatasetName(adaptiveMtDatasetName)

matchDatasetFromAdaptiveMtDatasetName(adaptiveMtDatasetName: string): string | number;

Parse the dataset from AdaptiveMtDataset resource.

Parameter
NameDescription
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns
TypeDescription
string | number

{string} A string representing the dataset.

matchDatasetFromAdaptiveMtFileName(adaptiveMtFileName)

matchDatasetFromAdaptiveMtFileName(adaptiveMtFileName: string): string | number;

Parse the dataset from AdaptiveMtFile resource.

Parameter
NameDescription
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns
TypeDescription
string | number

{string} A string representing the dataset.

matchDatasetFromAdaptiveMtSentenceName(adaptiveMtSentenceName)

matchDatasetFromAdaptiveMtSentenceName(adaptiveMtSentenceName: string): string | number;

Parse the dataset from AdaptiveMtSentence resource.

Parameter
NameDescription
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns
TypeDescription
string | number

{string} A string representing the dataset.

matchFileFromAdaptiveMtFileName(adaptiveMtFileName)

matchFileFromAdaptiveMtFileName(adaptiveMtFileName: string): string | number;

Parse the file from AdaptiveMtFile resource.

Parameter
NameDescription
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns
TypeDescription
string | number

{string} A string representing the file.

matchFileFromAdaptiveMtSentenceName(adaptiveMtSentenceName)

matchFileFromAdaptiveMtSentenceName(adaptiveMtSentenceName: string): string | number;

Parse the file from AdaptiveMtSentence resource.

Parameter
NameDescription
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns
TypeDescription
string | number

{string} A string representing the file.

matchGlossaryFromGlossaryName(glossaryName)

matchGlossaryFromGlossaryName(glossaryName: string): string | number;

Parse the glossary from Glossary resource.

Parameter
NameDescription
glossaryName string

A fully-qualified path representing Glossary resource.

Returns
TypeDescription
string | number

{string} A string representing the glossary.

matchLocationFromAdaptiveMtDatasetName(adaptiveMtDatasetName)

matchLocationFromAdaptiveMtDatasetName(adaptiveMtDatasetName: string): string | number;

Parse the location from AdaptiveMtDataset resource.

Parameter
NameDescription
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromAdaptiveMtFileName(adaptiveMtFileName)

matchLocationFromAdaptiveMtFileName(adaptiveMtFileName: string): string | number;

Parse the location from AdaptiveMtFile resource.

Parameter
NameDescription
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromAdaptiveMtSentenceName(adaptiveMtSentenceName)

matchLocationFromAdaptiveMtSentenceName(adaptiveMtSentenceName: string): string | number;

Parse the location from AdaptiveMtSentence resource.

Parameter
NameDescription
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromGlossaryName(glossaryName)

matchLocationFromGlossaryName(glossaryName: string): string | number;

Parse the location from Glossary resource.

Parameter
NameDescription
glossaryName string

A fully-qualified path representing Glossary resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchLocationFromLocationName(locationName)

matchLocationFromLocationName(locationName: string): string | number;

Parse the location from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the location.

matchProjectFromAdaptiveMtDatasetName(adaptiveMtDatasetName)

matchProjectFromAdaptiveMtDatasetName(adaptiveMtDatasetName: string): string | number;

Parse the project from AdaptiveMtDataset resource.

Parameter
NameDescription
adaptiveMtDatasetName string

A fully-qualified path representing AdaptiveMtDataset resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromAdaptiveMtFileName(adaptiveMtFileName)

matchProjectFromAdaptiveMtFileName(adaptiveMtFileName: string): string | number;

Parse the project from AdaptiveMtFile resource.

Parameter
NameDescription
adaptiveMtFileName string

A fully-qualified path representing AdaptiveMtFile resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromAdaptiveMtSentenceName(adaptiveMtSentenceName)

matchProjectFromAdaptiveMtSentenceName(adaptiveMtSentenceName: string): string | number;

Parse the project from AdaptiveMtSentence resource.

Parameter
NameDescription
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromGlossaryName(glossaryName)

matchProjectFromGlossaryName(glossaryName: string): string | number;

Parse the project from Glossary resource.

Parameter
NameDescription
glossaryName string

A fully-qualified path representing Glossary resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchProjectFromLocationName(locationName)

matchProjectFromLocationName(locationName: string): string | number;

Parse the project from Location resource.

Parameter
NameDescription
locationName string

A fully-qualified path representing Location resource.

Returns
TypeDescription
string | number

{string} A string representing the project.

matchSentenceFromAdaptiveMtSentenceName(adaptiveMtSentenceName)

matchSentenceFromAdaptiveMtSentenceName(adaptiveMtSentenceName: string): string | number;

Parse the sentence from AdaptiveMtSentence resource.

Parameter
NameDescription
adaptiveMtSentenceName string

A fully-qualified path representing AdaptiveMtSentence resource.

Returns
TypeDescription
string | number

{string} A string representing the sentence.

translateDocument(request, options)

translateDocument(request?: protos.google.cloud.translation.v3.ITranslateDocumentRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.ITranslateDocumentResponse,
        protos.google.cloud.translation.v3.ITranslateDocumentRequest | undefined,
        {} | undefined
    ]>;

Translates documents in synchronous mode.

Parameters
NameDescription
request ITranslateDocumentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.ITranslateDocumentResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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` 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 the same
   *  location-id), otherwise an INVALID_ARGUMENT (400) error is returned.
   */
  // const parent = 'abc123'
  /**
   *  Optional. The ISO-639 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 ISO-639 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 = [1,2,3,4]
  /**
   *  Optional. This flag is to support user customized attribution.
   *  If not provided, the default is `Machine Translated by Google`.
   *  Customized attribution should follow rules in
   *  https://cloud.google.com/translate/attribution#attribution_and_logos
   */
  // const customizedAttribution = 'abc123'
  /**
   *  Optional. is_translate_native_pdf_only field for external customers.
   *  If true, the page limit of online native pdf translation is 300 and only
   *  native pdf pages will be translated.
   */
  // const isTranslateNativePdfOnly = true
  /**
   *  Optional. If true, use the text removal server to remove the shadow text on
   *  background image for native pdf translation.
   *  Shadow removal feature can only be enabled when
   *  is_translate_native_pdf_only: false && pdf_native_only: false
   */
  // const enableShadowRemovalNativePdf = true
  /**
   *  Optional. If true, enable auto rotation correction in DVS.
   */
  // const enableRotationCorrection = true

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // 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.v3.ITranslateDocumentRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.ITranslateDocumentResponse, protos.google.cloud.translation.v3.ITranslateDocumentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITranslateDocumentRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.ITranslateDocumentResponse, protos.google.cloud.translation.v3.ITranslateDocumentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

translateDocument(request, callback)

translateDocument(request: protos.google.cloud.translation.v3.ITranslateDocumentRequest, callback: Callback<protos.google.cloud.translation.v3.ITranslateDocumentResponse, protos.google.cloud.translation.v3.ITranslateDocumentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITranslateDocumentRequest
callback Callback<protos.google.cloud.translation.v3.ITranslateDocumentResponse, protos.google.cloud.translation.v3.ITranslateDocumentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

translateText(request, options)

translateText(request?: protos.google.cloud.translation.v3.ITranslateTextRequest, options?: CallOptions): Promise<[
        protos.google.cloud.translation.v3.ITranslateTextResponse,
        protos.google.cloud.translation.v3.ITranslateTextRequest | undefined,
        {} | undefined
    ]>;

Translates input text and returns translated text.

Parameters
NameDescription
request ITranslateTextRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.translation.v3.ITranslateTextResponse, protos.google.cloud.translation.v3.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 for more details and examples.

Example

  /**
   * 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 30,000 codepoints. The max
   *  length of this field is 1024. Use BatchTranslateText for larger text.
   */
  // const contents = ['abc','def']
  /**
   *  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 ISO-639 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 ISO-639 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/advanced/labels for more
   *  information.
   */
  // const labels = [1,2,3,4]

  // Imports the Translation library
  const {TranslationServiceClient} = require('@google-cloud/translate').v3;

  // 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.v3.ITranslateTextRequest, options: CallOptions, callback: Callback<protos.google.cloud.translation.v3.ITranslateTextResponse, protos.google.cloud.translation.v3.ITranslateTextRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITranslateTextRequest
options CallOptions
callback Callback<protos.google.cloud.translation.v3.ITranslateTextResponse, protos.google.cloud.translation.v3.ITranslateTextRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

translateText(request, callback)

translateText(request: protos.google.cloud.translation.v3.ITranslateTextRequest, callback: Callback<protos.google.cloud.translation.v3.ITranslateTextResponse, protos.google.cloud.translation.v3.ITranslateTextRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request ITranslateTextRequest
callback Callback<protos.google.cloud.translation.v3.ITranslateTextResponse, protos.google.cloud.translation.v3.ITranslateTextRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void