PHP Класс Stichoza\GoogleTranslate\TranslateClient

Автор: Levan Velijanashvili ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__call ( $name, $args ) Override translate method for instance call.
__callStatic ( $name, $args ) Override translate method for static call.
__construct ( string $source = null, string $target = 'en', array $options = [], Stichoza\GoogleTranslate\Tokens\TokenProviderInterface $tokener = null ) Class constructor.
setHttpOption ( array $options ) : TranslateClient Set guzzleHttp client options.
setSource ( string $source = null ) : TranslateClient Set source language we are transleting from.
setTarget ( string $target ) : TranslateClient Set translation language we are transleting to.

Приватные методы

Метод Описание
checkStaticInstance ( ) : void Check if static instance exists and instantiate if not.
getResponse ( string | array $data ) : array Get response array.
instanceTranslate ( string | array $data ) : string | boolean Translate text.
isValidLocale ( string $lang ) : boolean Check if given locale is valid.
staticGetLastDetectedSource ( ) : string | boolean Get last detected language.
staticTranslate ( string $source, string $target, string $string ) : string | boolean Translate text statically.

Описание методов

__call() публичный Метод

Override translate method for instance call.
public __call ( $name, $args )

__callStatic() публичный статический Метод

Override translate method for static call.
public static __callStatic ( $name, $args )

__construct() публичный Метод

For more information about HTTP client configuration options, visit "Creating a client" section of GuzzleHttp docs. 5.x - http://guzzle.readthedocs.org/en/5.3/clients.html#creating-a-client
public __construct ( string $source = null, string $target = 'en', array $options = [], Stichoza\GoogleTranslate\Tokens\TokenProviderInterface $tokener = null )
$source string Source language (Optional)
$target string Target language (Optional)
$options array Associative array of http client configuration options (Optional)
$tokener Stichoza\GoogleTranslate\Tokens\TokenProviderInterface

setHttpOption() публичный Метод

Set guzzleHttp client options.
public setHttpOption ( array $options ) : TranslateClient
$options array guzzleHttp client options.
Результат TranslateClient

setSource() публичный Метод

Set source language we are transleting from.
public setSource ( string $source = null ) : TranslateClient
$source string Language code
Результат TranslateClient

setTarget() публичный Метод

Set translation language we are transleting to.
public setTarget ( string $target ) : TranslateClient
$target string Language code
Результат TranslateClient