Property | Type | Description | |
---|---|---|---|
$acceptedLanguages | array | contains the languages accepted by your application | |
$autoSetLanguage | wheter to automatically set the language on the initialization of the component | ||
$autoTranslate | wheter to auto translate the missing messages found on the page needs google api key to set | ||
$defaultLanguage | string | defaults language to use if none is set | |
$dialogOptions | options of the dialog | ||
$googleApiKey | string | ||
$languageKey | string | an unique key to be used | |
$messages |
Method | Description | |
---|---|---|
__callStatic ( mixed $method, mixed $args ) : mixed | helper so you can use MPTransalate::someMethod($args) | |
dropdown ( ) : string | generates a dropdown containing all accepted languages | |
editLink ( string $label = 'Edit translations', string $type = 'link' ) | creates a link to the page where you edit the translations | |
getGoogleAcceptedLanguages ( string $targetLanguage = null ) : array | returns an array containing all languages accepted by google translate | |
getLanguage ( ) : string | returns the language in use the language is determined by many variables: session, post, get, header in this order it will filter the language by using accepted languages | |
googleTranslate ( string $message, string $targetLanguage = null, mixed $sourceLanguage = null ) : string | translate some message from $sourceLanguage to $targetLanguage using google translate api googleApiKey must be defined to use this service | |
hasMessages ( ) | ||
init ( ) | handles the initialization parameters of the components | |
missingLink ( string $label = 'Missing translations', string $type = 'link' ) : string | creates a link to the page where you check all missing translations | |
missingTranslation ( CMissingTranslationEvent $event ) : string | method that handles the on missing translation event | |
setLanguage ( string | null $language = null ) : string | set the language that the application will use if $language is null then if you use getLanguage to determine the target language | |
translateDialogLink ( string $label = 'Translate', mixed $title = null, string $type = 'link' ) : string | generates a link or button that generates a dialog to the page where you translate the missing translations found in this page | |
translateLink ( string $label = 'Translate', string $type = 'link' ) : string | generates a link or button to the page where you translate the missing translations found in this page |
Method | Description | |
---|---|---|
queryGoogle ( array $args = [], string $method = null ) : stdClass | query google translate api |
Method | Description | |
---|---|---|
ajaxDialog ( $label, $url, $title = null, $type = 'link', $ajaxOptions = [] ) |
public getGoogleAcceptedLanguages ( string $targetLanguage = null ) : array | ||
$targetLanguage | string | |
return | array |
public getLanguage ( ) : string | ||
return | string |
public googleTranslate ( string $message, string $targetLanguage = null, mixed $sourceLanguage = null ) : string | ||
$message | string | to be translated |
$targetLanguage | string | language to translate the message to, if null it will use the current language in use |
$sourceLanguage | mixed | language that the message is written in, if null it will use the application source language |
return | string | translated message |
public missingTranslation ( CMissingTranslationEvent $event ) : string | ||
$event | CMissingTranslationEvent | |
return | string | the message to translate or the translated message if autoTranslate is set to true |
protected queryGoogle ( array $args = [], string $method = null ) : stdClass | ||
$args | array | |
$method | string | the method to use, use null to translate accepted values are null(translate), "languages" and "detect" |
return | stdClass | the google response object |
public array $acceptedLanguages | ||
return | array |
public $autoSetLanguage |
public $autoTranslate |
public string $defaultLanguage | ||
return | string |