PHP Класс MPTranslate, gxc-cms

Наследование: extends CApplicationComponent
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$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

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

Метод Описание
__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

Защищенные методы

Метод Описание
queryGoogle ( array $args = [], string $method = null ) : stdClass query google translate api

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

Метод Описание
ajaxDialog ( $label, $url, $title = null, $type = 'link', $ajaxOptions = [] )

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

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

php 5.3 only
static public __callStatic ( mixed $method, mixed $args ) : mixed
$method mixed
$args mixed
Результат mixed

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

generates a dropdown containing all accepted languages
public dropdown ( ) : string
Результат string

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

returns an array containing all languages accepted by google translate
public getGoogleAcceptedLanguages ( string $targetLanguage = null ) : array
$targetLanguage string
Результат array

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

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
Результат string

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

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
Результат string translated message

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

public hasMessages ( )

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

handles the initialization parameters of the components
public init ( )

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

method that handles the on missing translation event
public missingTranslation ( CMissingTranslationEvent $event ) : string
$event CMissingTranslationEvent
Результат string the message to translate or the translated message if autoTranslate is set to true

queryGoogle() защищенный Метод

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"
Результат stdClass the google response object

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

it doesn't check if the language is in the accepted languages
public setLanguage ( string | null $language = null ) : string
$language string | null
Результат string the language setted

Описание свойств

$acceptedLanguages публичное свойство

contains the languages accepted by your application
public array $acceptedLanguages
Результат array

$autoSetLanguage публичное свойство

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

$autoTranslate публичное свойство

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

$defaultLanguage публичное свойство

defaults language to use if none is set
public string $defaultLanguage
Результат string

$dialogOptions публичное свойство

options of the dialog
public $dialogOptions

$googleApiKey публичное свойство

public string $googleApiKey
Результат string

$languageKey публичное свойство

an unique key to be used
public string $languageKey
Результат string

$messages статическое публичное свойство

static public $messages