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.
<com:TTranslate Text="Goodbye" />
Depending on the culture set on the page, the phrase "Goodbye" will be translated.
The \Prado\I18N\getParameters 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.
<com:TTranslate Parameters.time=<%= time() %> >
The unix-time is "{time}".
</com:TTranslate>
More complex string substitution can be applied using the TTranslateParameter component.
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.
Class hierarchy
- \Prado\I18N\TTranslate
- \Prado\I18N\TI18NControl
- \Prado\Web\UI\TControl implements IRenderable, IBindable
- \Prado\TApplicationComponent
- \Prado\TComponent
public
|
|
public
|
|
public
|
|
public
|
getParameters() : TAttributeCollection
Returns the list of custom parameters.
Custom parameters are name-value pairs that may subsititute translation place holders during rendering. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
protected
|
translateText(string $text, array<string|int, mixed> $subs) : string
Translates the text with subsititution.
|