Learning with Texts - Fork  2.10.0-fork
Learn foreign languages with texts
Public Member Functions | Static Public Member Functions | Data Fields
GoogleTranslate Class Reference

Public Member Functions

 setLangFrom ($lang)
 
 setLangTo ($lang)
 
 __construct ($from, $to)
 
 translate ($string)
 

Static Public Member Functions

static getDomain ($domain)
 
static array_iunique ($array)
 
static setDomain ($domain)
 
static makeCurl ($url, $cookieSet=false)
 
static staticTranslate ( $string, $from, $to, $time_token=null, $domain=self::DEFAULT_DOMAIN)
 

Data Fields

 $lastResult = ""
 
const DEFAULT_DOMAIN = null
 

Detailed Description

Wrapper class to get translation.

See staticTranslate for a clssical translation.

Member Function Documentation

◆ getDomain()

static getDomain (   $domain)
static

Return the current domain.

Parameters
string | void$domain(Optionnal) Google Translate domain to use.
  • Usually two letters (e.g "en" or "com")
  • Random if not provided.
Returns
string

◆ staticTranslate()

static staticTranslate (   $string,
  $from,
  $to,
  $time_token = null,
  $domain = self::DEFAULT_DOMAIN 
)
static

Returns an array of Translations

Parameters
string$stringWord to translate
string$fromSource language code (i.e. en,de,fr,...)
string$toTarget language code (i.e. en,de,fr,...) all supported language codes can be found here: https://cloud.google.com/translate/docs/basic/discovering-supported-languages#getting_a_list_of_supported_languages
int[] | null$time_token(optional) array() from https://translate.google.com. If empty, array(408254,585515986) is used
string$domain(optional) Connect to Google Domain (i.e. 'com' for https://translate.google.com). If empty, a random domain will be used (the default value can be altered by changing DEFAULT_DOMAIN) Possible values: ('com.ar', 'at', 'com.au', 'be', 'com.br', 'ca', 'cat', 'ch', 'cl', 'cn', 'cz', 'de', 'dk', 'es', 'fi', 'fr', 'gr', 'com.hk', 'hr', 'hu', 'co.id', 'ie', 'co.il', 'im', 'co.in', 'it', 'co.jp', 'co.kr', 'com.mx', 'nl', 'no', 'pl', 'pt', 'ru', 'se', 'com.sg', 'co.th', 'com.tw', 'co.uk', 'com')
Returns
string[]|false An array of translation, or false if an error occured.

The documentation for this class was generated from the following file: