PHP Класс Prado\I18N\TTranslate

This component performs message/string translation. The translation source is set in the TGlobalization handler. The following example demonstrated a simple message translation. Depending on the culture set on the page, the phrase "Goodbye" will be translated. The {@link getParameters Parameters} property can be use to add name values pairs for substitution. Substrings enclosed with "{" and "}" in the translation message are consider as the parameter names during substitution lookup. The following example will substitute the substring "{time}" with the value of the parameter attribute "Parameters.time=<%= time() %>. Note that the value of the parameter named "time" is evaluated. > The unix-time is "{time}". More complex string substitution can be applied using the TTranslateParameter component. Namespace: System.I18N Properties - Text, string,
Gets or sets the string to translate. - Catalogue, string,
Gets or sets the catalogue for message translation. The default catalogue can be set by the @Page directive. - Key, string,
Gets or sets the key used to message look up. - Trim, boolean,
Gets or sets an option to trim the contents. Default is to trim the contents.
Наследование: extends TI18NControl
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
getCatalogue ( ) : string Get the message catalogue.
getKey ( ) : string Get the key for message lookup.
getParameter ( $name ) : string
getParameters ( ) : TAttributeCollection Returns the list of custom parameters.
getText ( ) : string
getTrim ( ) : boolean Trim the content or not.
hasParameter ( $name ) : boolean
removeParameter ( $name ) : string Removes the named parameter.
render ( $writer ) renders the translated string.
setCatalogue ( $value ) Set the message catalogue.
setKey ( $value ) Set the key for message lookup.
setParameter ( $name, $value )
setText ( $value ) Sets the text for localization.
setTrim ( $value ) Set the option to trim the contents.

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

Метод Описание
translateText ( $text, $subs ) : string Translates the text with subsititution.

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

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

Get the message catalogue.
public getCatalogue ( ) : string
Результат string catalogue.

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

Get the key for message lookup.
public getKey ( ) : string
Результат string key

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

public getParameter ( $name ) : string
Результат string parameter value, null if parameter does not exist

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

Custom parameters are name-value pairs that may subsititute translation place holders during rendering.
public getParameters ( ) : TAttributeCollection
Результат Prado\Collections\TAttributeCollection the list of custom parameters

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

public getText ( ) : string
Результат string the text to be localized/translated.

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

Trim the content or not.
public getTrim ( ) : boolean
Результат boolean trim or not.

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

public hasParameter ( $name ) : boolean
Результат boolean whether the named parameter exists

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

Removes the named parameter.
public removeParameter ( $name ) : string
Результат string parameter value removed, null if parameter does not exist.

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

renders the translated string.
public render ( $writer )

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

Set the message catalogue.
public setCatalogue ( $value )

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

Set the key for message lookup.
public setKey ( $value )

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

public setParameter ( $name, $value )

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

Sets the text for localization.
public setText ( $value )

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

Set the option to trim the contents.
public setTrim ( $value )

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

Translates the text with subsititution.
protected translateText ( $text, $subs ) : string
Результат string translated text