PHP Class 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.
Inheritance: extends TI18NControl
Datei anzeigen Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
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.

Protected Methods

Method Description
translateText ( $text, $subs ) : string Translates the text with subsititution.

Method Details

getCatalogue() public method

Get the message catalogue.
public getCatalogue ( ) : string
return string catalogue.

getKey() public method

Get the key for message lookup.
public getKey ( ) : string
return string key

getParameter() public method

public getParameter ( $name ) : string
return string parameter value, null if parameter does not exist

getParameters() public method

Custom parameters are name-value pairs that may subsititute translation place holders during rendering.
public getParameters ( ) : TAttributeCollection
return Prado\Collections\TAttributeCollection the list of custom parameters

getText() public method

public getText ( ) : string
return string the text to be localized/translated.

getTrim() public method

Trim the content or not.
public getTrim ( ) : boolean
return boolean trim or not.

hasParameter() public method

public hasParameter ( $name ) : boolean
return boolean whether the named parameter exists

removeParameter() public method

Removes the named parameter.
public removeParameter ( $name ) : string
return string parameter value removed, null if parameter does not exist.

render() public method

renders the translated string.
public render ( $writer )

setCatalogue() public method

Set the message catalogue.
public setCatalogue ( $value )

setKey() public method

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

setParameter() public method

public setParameter ( $name, $value )

setText() public method

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

setTrim() public method

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

translateText() protected method

Translates the text with subsititution.
protected translateText ( $text, $subs ) : string
return string translated text