PHP Class Stichoza\GoogleTranslate\TranslateClient

Author: Levan Velijanashvili ([email protected])
Show file Open project: stichoza/google-translate-php Class Usage Examples

Public Methods

Method Description
__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.

Private Methods

Method Description
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.

Method Details

__call() public method

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

__callStatic() public static method

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

__construct() public method

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() public method

Set guzzleHttp client options.
public setHttpOption ( array $options ) : TranslateClient
$options array guzzleHttp client options.
return TranslateClient

setSource() public method

Set source language we are transleting from.
public setSource ( string $source = null ) : TranslateClient
$source string Language code
return TranslateClient

setTarget() public method

Set translation language we are transleting to.
public setTarget ( string $target ) : TranslateClient
$target string Language code
return TranslateClient