PHP Class MPTranslate, gxc-cms

Inheritance: extends CApplicationComponent
Afficher le fichier Open project: nganhtuan63/gxc-cms

Méthodes publiques

Свойство 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

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode Description
queryGoogle ( array $args = [], string $method = null ) : stdClass query google translate api

Private Methods

Méthode Description
ajaxDialog ( $label, $url, $title = null, $type = 'link', $ajaxOptions = [] )

Method Details

__callStatic() static public méthode

php 5.3 only
static public __callStatic ( mixed $method, mixed $args ) : mixed
$method mixed
$args mixed
Résultat mixed

dropdown() public méthode

generates a dropdown containing all accepted languages
public dropdown ( ) : string
Résultat string

getGoogleAcceptedLanguages() public méthode

returns an array containing all languages accepted by google translate
public getGoogleAcceptedLanguages ( string $targetLanguage = null ) : array
$targetLanguage string
Résultat array

getLanguage() public méthode

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
public getLanguage ( ) : string
Résultat string

googleTranslate() public méthode

translate some message from $sourceLanguage to $targetLanguage using google translate api googleApiKey must be defined to use this service
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
Résultat string translated message

hasMessages() public méthode

public hasMessages ( )

init() public méthode

handles the initialization parameters of the components
public init ( )

missingTranslation() public méthode

method that handles the on missing translation event
public missingTranslation ( CMissingTranslationEvent $event ) : string
$event CMissingTranslationEvent
Résultat string the message to translate or the translated message if autoTranslate is set to true

queryGoogle() protected méthode

query google translate api
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"
Résultat stdClass the google response object

setLanguage() public méthode

it doesn't check if the language is in the accepted languages
public setLanguage ( string | null $language = null ) : string
$language string | null
Résultat string the language setted

Property Details

$acceptedLanguages public_oe property

contains the languages accepted by your application
public array $acceptedLanguages
Résultat array

$autoSetLanguage public_oe property

wheter to automatically set the language on the initialization of the component
public $autoSetLanguage

$autoTranslate public_oe property

wheter to auto translate the missing messages found on the page needs google api key to set
public $autoTranslate

$defaultLanguage public_oe property

defaults language to use if none is set
public string $defaultLanguage
Résultat string

$dialogOptions public_oe property

options of the dialog
public $dialogOptions

$googleApiKey public_oe property

public string $googleApiKey
Résultat string

$languageKey public_oe property

an unique key to be used
public string $languageKey
Résultat string

$messages static_oe public_oe property

static public $messages