Translate/src/TranslateClient.php
public function translate($string, array $options = [])
    {
        $res = $this->translateBatch([$string], $options);
        if (count($res) > 0) {
            return $res[0];
        }
    }
public function translate($string, array $options = [])
    {
        $res = $this->translateBatch([$string], $options);
        if (count($res) > 0) {
            return $res[0];
        }
    }
public function translate ( $ string , array $ options = [ ] ) { $ res = $ this -> translateBatch ( [ $ string ] , $ options ) ; if ( count ( $ res ) > 0 ) { return $ res [ 0 ] ; } }
Translate a string from one language to another.

Example:
```
$result = $translate->translate('Hello world!');

echo $result['text'];
```

@see https://cloud.google.com/translation/v2/translating-text-with-rest Translating Text

@param string $string The string to translate.
@param array $options [optional] {
Configuration Options.

@type string $source The source language to translate from. Must be a
valid ISO 639-1 language code. If not provided the value will
be automatically detected by the server.
@type string $target The target language to translate to. Must be a
valid ISO 639-1 language code. **Defaults to** the value assigned
to the client (`"en"` by default).
@type string $format Indicates whether the string to be translated is
either plain-text or HTML. Acceptable values are `html` or
`text`. **Defaults to** `"html"`.
@type string $model The model to use for the translation request. May
be `nmt` (for the NMT model) or `base` (for the PBMT model).
**Defaults to** using the NMT model. If the NMT model is not
supported for the requested language translation pair, the PBMT
model will be defaulted instead. For a list of supported
languages for the model types, please see the
[Language Support](https://cloud.google.com/translate/docs/languages)
documentation.
}
@return array|null A translation result including a `source` key containing
the detected or provided language of the provided input, an
`input` key containing the original string, and a `text` key
containing the translated result.
Translate a string from one language to another .