{@inheritdoc}

CloneableInstantiable
ExtendsGoogle\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient
Constants
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::CODEGEN_NAME = 'gapic'
 
The name of the code generator, to be included in the agent header.

public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::DEFAULT_SERVICE_PORT = 443
 
The default port of the service.

public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::SERVICE_ADDRESS = 'translate.googleapis.com'
 
The default address of the service.

public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::SERVICE_NAME = 'google.cloud.translation.v3.TranslationService'
 
The name of the service.

Properties
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::$serviceScopes
 
The default scopes required by the service.

Methods
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::__construct(array $options = [])
 
Constructor.

  • throws ValidationException
  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::batchTranslateText( $parent, $sourceLanguageCode, $targetLanguageCodes, $inputConfigs, $outputConfig, array $optionalArgs = [])
 
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.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    $sourceLanguageCode = '';
    $targetLanguageCodes = [];
    $inputConfigs = [];
    $outputConfig = new OutputConfig();
    $operationResponse = $translationServiceClient->batchTranslateText($formattedParent, $sourceLanguageCode, $targetLanguageCodes, $inputConfigs, $outputConfig);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }


    // Alternatively:

    // start the operation, keep the operation name, and resume later
    $operationResponse = $translationServiceClient->batchTranslateText($formattedParent, $sourceLanguageCode, $targetLanguageCodes, $inputConfigs, $outputConfig);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $translationServiceClient->resumeOperation($operationName, 'batchTranslateText');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
      $result = $newOperationResponse->getResult();
      // doSomethingWith($result)
    } else {
      $error = $newOperationResponse->getError();
      // handleError($error)
    }
} finally {
    $translationServiceClient->close();
}
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::close()
 
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.

  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::createGlossary( $parent, $glossary, array $optionalArgs = [])
 
Creates a glossary and returns the long-running operation. Returns NOT_FOUND, if the project doesn't exist.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    $glossary = new Glossary();
    $operationResponse = $translationServiceClient->createGlossary($formattedParent, $glossary);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }


    // Alternatively:

    // start the operation, keep the operation name, and resume later
    $operationResponse = $translationServiceClient->createGlossary($formattedParent, $glossary);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $translationServiceClient->resumeOperation($operationName, 'createGlossary');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
      $result = $newOperationResponse->getResult();
      // doSomethingWith($result)
    } else {
      $error = $newOperationResponse->getError();
      // handleError($error)
    }
} finally {
    $translationServiceClient->close();
}
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::deleteGlossary( $name, array $optionalArgs = [])
 
Deletes a glossary, or cancels glossary construction if the glossary isn't created yet.

Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedName = $translationServiceClient->glossaryName('[PROJECT]', '[LOCATION]', '[GLOSSARY]');
    $operationResponse = $translationServiceClient->deleteGlossary($formattedName);
    $operationResponse->pollUntilComplete();
    if ($operationResponse->operationSucceeded()) {
        $result = $operationResponse->getResult();
        // doSomethingWith($result)
    } else {
        $error = $operationResponse->getError();
        // handleError($error)
    }


    // Alternatively:

    // start the operation, keep the operation name, and resume later
    $operationResponse = $translationServiceClient->deleteGlossary($formattedName);
    $operationName = $operationResponse->getName();
    // ... do other work
    $newOperationResponse = $translationServiceClient->resumeOperation($operationName, 'deleteGlossary');
    while (!$newOperationResponse->isDone()) {
        // ... do other work
        $newOperationResponse->reload();
    }
    if ($newOperationResponse->operationSucceeded()) {
      $result = $newOperationResponse->getResult();
      // doSomethingWith($result)
    } else {
      $error = $newOperationResponse->getError();
      // handleError($error)
    }
} finally {
    $translationServiceClient->close();
}
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::detectLanguage( $parent, array $optionalArgs = [])
 
Detects the language of text within a request.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    $response = $translationServiceClient->detectLanguage($formattedParent);
} finally {
    $translationServiceClient->close();
}
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGlossary( $name, array $optionalArgs = [])
 
Gets a glossary. Returns NOT_FOUND, if the glossary doesn't exist.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedName = $translationServiceClient->glossaryName('[PROJECT]', '[LOCATION]', '[GLOSSARY]');
    $response = $translationServiceClient->getGlossary($formattedName);
} finally {
    $translationServiceClient->close();
}
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getOperationsClient()
 
Return an OperationsClient object with the same endpoint as $this.

  • return OperationsClient
  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getSupportedLanguages( $parent, array $optionalArgs = [])
 
Returns a list of supported languages for translation.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    $response = $translationServiceClient->getSupportedLanguages($formattedParent);
} finally {
    $translationServiceClient->close();
}
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::glossaryName( $project, $location, $glossary)
 
Formats a string containing the fully-qualified path to represent a glossary resource.

  • return string The formatted glossary resource.
  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::listGlossaries( $parent, array $optionalArgs = [])
 
Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't exist.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    // Iterate over pages of elements
    $pagedResponse = $translationServiceClient->listGlossaries($formattedParent);
    foreach ($pagedResponse->iteratePages() as $page) {
        foreach ($page as $element) {
            // doSomethingWith($element);
        }
    }


    // Alternatively:

    // Iterate through all elements
    $pagedResponse = $translationServiceClient->listGlossaries($formattedParent);
    foreach ($pagedResponse->iterateAllElements() as $element) {
        // doSomethingWith($element);
    }
} finally {
    $translationServiceClient->close();
}
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::locationName( $project, $location)
 
Formats a string containing the fully-qualified path to represent a location resource.

  • return string The formatted location resource.
  • experimental
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::parseName( $formattedName, $template = NULL)
 
Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported:
Template: Pattern

  • glossary: projects/{project}/locations/{location}/glossaries/{glossary}
  • location: projects/{project}/locations/{location}.

The optional $template argument can be supplied to specify a particular pattern, and must
match one of the templates listed above. If no $template argument is provided, or if the
$template argument does not match one of the templates listed, then parseName will check
each of the supported templates, and return the first match.

  • return array An associative array from name component IDs to component values.
  • throws ValidationException If $formattedName could not be matched.
  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::resumeOperation( $operationName, $methodName = NULL)
 
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.

  • return OperationResponse
  • experimental
public Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::translateText( $contents, $targetLanguageCode, $parent, array $optionalArgs = [])
 
Translates input text and returns translated text.

Sample code:

$translationServiceClient = new TranslationServiceClient();
try {
    $contents = [];
    $targetLanguageCode = '';
    $formattedParent = $translationServiceClient->locationName('[PROJECT]', '[LOCATION]');
    $response = $translationServiceClient->translateText($contents, $targetLanguageCode, $formattedParent);
} finally {
    $translationServiceClient->close();
}
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validate( $arr, $requiredKeys)
 


  • return array Returns $arr for fluent use
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateNotNull( $arr, $requiredKeys)
 


  • return array Returns $arr for fluent use
Methods
protected Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getCredentialsWrapper()
 
Get the credentials for the client. This method is protected to support use by customized clients.

  • access private
  • return CredentialsWrapper
protected Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getTransport()
 
Get the transport for the client. This method is protected to support use by customized clients.

  • access private
  • return TransportInterface
protected Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::modifyClientOptions(array $options)
 
Modify options passed to the client before calling setClientOptions.

  • access private
protected Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::modifyStreamingCallable(callable $callable)
 
Modify the streaming callable.

  • access private
protected Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::modifyUnaryCallable(callable $callable)
 
Modify the unary callable.

  • access private
Methods
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::arrayFilterRemoveNull(array $arr)
 
Just like array_filter(), but preserves falsey values except null.

  • return array
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::buildClientOptions(array $options)
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::buildMethod( $interfaceName, $methodName)
 


  • return string
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::configureCallConstructionOptions( $methodName, array $optionalArgs)
 


  • return array
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::createCallStack(array $callConstructionOptions)
 


  • return callable
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::createCredentialsWrapper( $credentials, array $credentialsConfig)
 


  • return CredentialsWrapper
  • throws ValidationException
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::createOperationsClient(array $options)
 


  • return OperationsClient
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::createTransport( $apiEndpoint, $transport, array $transportConfig)
 


  • return TransportInterface
  • throws ValidationException
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::defaultTransport()
 


  • return string
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getClientDefaults()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGapicVersion(array $options)
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGlossaryNameTemplate()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGrpcDependencyStatus()
 


  • return bool
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getLocationNameTemplate()
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getPagedListResponse( $methodName, array $optionalArgs, $decodeType, Google\Protobuf\Internal\Message $request, $interfaceName = NULL)
 


  • return PagedListResponse
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getPathTemplateMap()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::initGrpcGcpConfig( $hostName, $confPath)
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::isAssoc(array $arr)
 
Determine whether given array is associative.

  • return bool
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::pluck( $key, array $arr, $isRequired = true)
 
Pluck a value out of an array.

  • return mixed|null
  • throws InvalidArgumentException
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::pluckArray(array $keys, $arr)
 
Pluck a subset of an array.

  • return array
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::setClientOptions(array $options)
 
Configures the GAPIC client based on an array of options.

  • throws ValidationException
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::startCall( $methodName, $decodeType, array $optionalArgs = [], ?Google\Protobuf\Internal\Message $request = NULL, $callType = 0, $interfaceName = NULL)
 


  • return PromiseInterface|\BidiStream|\ClientStream|\ServerStream
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::startOperationsCall( $methodName, array $optionalArgs, Google\Protobuf\Internal\Message $request, Google\ApiCore\LongRunning\OperationsClient $client, $interfaceName = NULL)
 


  • return PromiseInterface
private Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::subsetArray(array $keys, $arr)
 
Return a subset of an array, like pluckArray, without modifying the original array.

  • return array
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateFileExists( $filePath)
 


  • throws ValidationException
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateGrpcSupport()
 


  • throws ValidationException
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateImpl( $arr, $requiredKeys, $allowNull)
Properties
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::$serviceScopes
 
The default scopes required by the service.

Methods
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::defaultTransport()
 


  • return string
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getClientDefaults()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGapicVersion(array $options)
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGlossaryNameTemplate()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getGrpcDependencyStatus()
 


  • return bool
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getLocationNameTemplate()
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::getPathTemplateMap()
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::glossaryName( $project, $location, $glossary)
 
Formats a string containing the fully-qualified path to represent a glossary resource.

  • return string The formatted glossary resource.
  • experimental
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::initGrpcGcpConfig( $hostName, $confPath)
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::locationName( $project, $location)
 
Formats a string containing the fully-qualified path to represent a location resource.

  • return string The formatted location resource.
  • experimental
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::parseName( $formattedName, $template = NULL)
 
Parses a formatted name string and returns an associative array of the components in the name.

The following name formats are supported:
Template: Pattern

  • glossary: projects/{project}/locations/{location}/glossaries/{glossary}
  • location: projects/{project}/locations/{location}.

The optional $template argument can be supplied to specify a particular pattern, and must
match one of the templates listed above. If no $template argument is provided, or if the
$template argument does not match one of the templates listed, then parseName will check
each of the supported templates, and return the first match.

  • return array An associative array from name component IDs to component values.
  • throws ValidationException If $formattedName could not be matched.
  • experimental
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validate( $arr, $requiredKeys)
 


  • return array Returns $arr for fluent use
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateFileExists( $filePath)
 


  • throws ValidationException
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateGrpcSupport()
 


  • throws ValidationException
private static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateImpl( $arr, $requiredKeys, $allowNull)
public static Google\Cloud\Translate\V3\Gapic\TranslationServiceGapicClient::validateNotNull( $arr, $requiredKeys)
 


  • return array Returns $arr for fluent use
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only