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
Пример #1
0
 /**
  * Display the choosen translated string.
  * Overrides the parent method, also calls parent's renderBody to
  * translate.
  */
 protected function translateText($text, $subs)
 {
     $text = parent::translateText($text, $subs);
     $choice = new ChoiceFormat();
     $value = $this->getValue();
     $string = $choice->format($text, $value);
     if ($string) {
         return strtr($string, array('{Value}' => $value));
     }
 }