Свойство | Тип | Описание | |
---|---|---|---|
$connection | Google\Cloud\Translate\Connection\ConnectionInterface |
Метод | Описание | |
---|---|---|
__construct ( array $config = [] ) | Create a Translate client. | |
detectLanguage ( string $string, array $options = [] ) : array | Detect the language of a string. | |
detectLanguageBatch ( array $strings, array $options = [] ) : array | Detect the language of multiple strings. | |
languages ( array $options = [] ) : array | Get all supported languages. | |
localizedLanguages ( array $options = [] ) : array | Get the supported languages for translation in the targeted language. | |
translate ( string $string, array $options = [] ) : array | null | Translate a string from one language to another. | |
translateBatch ( array $strings, array $options = [] ) : array | Translate multiple strings from one language to another. |
public __construct ( array $config = [] ) | ||
$config | array | [optional] { Configuration Options. @type string $key A public API access key. @type string $target The target language to assign to the client. Must be a valid ISO 639-1 language code. **Defaults to** `"en"` (English). @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type string $projectId The project ID from the Google Developer's Console. @type CacheItemPoolInterface $authCache A cache used storing access tokens. **Defaults to** a simple in memory implementation. @type array $authCacheOptions Cache configuration options. @type callable $authHttpHandler A handler used to deliver Psr7 requests specifically for authentication. @type callable $httpHandler A handler used to deliver Psr7 requests. Only valid for requests sent over REST. @type string $keyFile The contents of the service account credentials .json file retrieved from the Google Developers Console. @type string $keyFilePath The full path to your service account credentials .json file retrieved from the Google Developers Console. @type int $retries Number of retries for a failed request. **Defaults to** `3`. @type array $scopes Scopes to be used for the request. } |
public detectLanguage ( string $string, array $options = [] ) : array | ||
$string | string | The string to detect the language of. |
$options | array | [optional] { Configuration Options. @type string $format Indicates whether the string is either plain-text or HTML. Acceptable values are `html` or `text`. **Defaults to** `"html"`. } |
Результат | array | A result including a `languageCode` key containing the detected ISO 639-1 language code, an `input` key containing the original string, and in most cases a `confidence` key containing a value between 0 - 1 signifying the confidence of the result. |
public detectLanguageBatch ( array $strings, array $options = [] ) : array | ||
$strings | array | |
$options | array | [optional] { Configuration Options. @type string $format Indicates whether the string is either plain-text or HTML. Acceptable values are `html` or `text`. **Defaults to** `"html"`. } |
Результат | array | A set of results. Each result includes a `languageCode` key containing the detected ISO 639-1 language code, an `input` key containing the original string, and in most cases a `confidence` key containing a value between 0 - 1 signifying the confidence of the result. |
public localizedLanguages ( array $options = [] ) : array | ||
$options | array | [optional] { Configuration Options. @type string $target The language to discover supported languages for. Must be a valid ISO 639-1 language code. **Defaults to** the value assigned to the client (`"en"` by default). } |
Результат | array | A set of language results. Each result includes a `code` key containing the ISO 639-1 code for the supported language and a `name` key containing the name of the language written in the target language. |
public translate ( string $string, array $options = [] ) : array | null | ||
$string | string | The string to translate. |
$options | array | [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` or `base`. **Defaults to** an empty string. } |
Результат | array | null | A translation result including a `source` key containing the detected or provided langauge of the provided input, an `input` key containing the original string, and a `text` key containing the translated result. |
public translateBatch ( array $strings, array $options = [] ) : array | ||
$strings | array | An array of strings to translate. |
$options | array | [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` or `base`. **Defaults to** an empty string. } |
Результат | array | A set of translation results. Each result includes 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. |