Class TTranslate

Description

TTranslate class.

This component performs message/string translation. The translation source is set in the TGlobalization handler. The following example demonstrated a simple message translation.

  1. <com:TTranslate Text="Goodbye" />

Depending on the culture set on the page, the phrase "Goodbye" will be translated.

The 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.

  1. <com:TTranslate Parameters.time=<%= time() %> >
  2. The unix-time is "{time}".
  3. </com:TTranslate>

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.

Located in /I18N/TTranslate.php (line 63)

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TI18NControl
            |
            --TTranslate
Direct descendents
Class Description
TChoiceFormat TChoiceFormat class.
Method Summary
string getCatalogue ()
string getKey ()
string getParameter (mixed $name)
string getText ()
boolean getTrim ()
boolean hasParameter (mixed $name)
string removeParameter (string $name)
void render (mixed $writer)
void setCatalogue (string $value)
void setKey (string $value)
void setParameter (string $name, string $value)
void setText (string $value)
void setTrim (boolean $value)
string translateText (string $text, array $subs)
Methods
getCatalogue (line 104)

Get the message catalogue.

  • return: catalogue.
  • access: public
string getCatalogue ()
getKey (line 95)

Get the key for message lookup.

  • return: key
  • access: public
string getKey ()
getParameter (line 169)
  • return: parameter value, null if parameter does not exist
  • access: public
string getParameter (mixed $name)
getParameters (line 142)

Returns the list of custom parameters.

Custom parameters are name-value pairs that may subsititute translation place holders during rendering.

  • return: the list of custom parameters
  • access: public
TAttributeCollection getParameters ()
getText (line 68)
  • return: the text to be localized/translated.
  • access: public
string getText ()
getTrim (line 131)

Trim the content or not.

  • return: trim or not.
  • access: public
boolean getTrim ()
hasParameter (line 158)
  • return: whether the named parameter exists
  • access: public
boolean hasParameter (mixed $name)
removeParameter (line 191)

Removes the named parameter.

  • return: parameter value removed, null if parameter does not exist.
  • access: public
string removeParameter (string $name)
  • string $name: the name of the parameter to be removed.
render (line 202)

renders the translated string.

  • access: public
void render (mixed $writer)

Redefinition of:
TControl::render()
Renders the control.
setCatalogue (line 113)

Set the message catalogue.

  • access: public
void setCatalogue (string $value)
  • string $value: catalogue.
setKey (line 86)

Set the key for message lookup.

  • access: public
void setKey (string $value)
  • string $value: key
setParameter (line 181)
  • access: public
void setParameter (string $name, string $value)
  • string $name: parameter name
  • string $value: value of the parameter
setText (line 77)

Sets the text for localization.

  • access: public
void setText (string $value)
  • string $value: the text for translation.
setTrim (line 122)

Set the option to trim the contents.

  • access: public
void setTrim (boolean $value)
  • boolean $value: trim or not.
translateText (line 234)

Translates the text with subsititution.

  • return: translated text
  • access: protected
string translateText (string $text, array $subs)
  • string $text: text for translation
  • array $subs: list of substitutions

Redefined in descendants as:

Inherited Methods

Inherited From TI18NControl

TI18NControl::getCharset()
TI18NControl::getCulture()
TI18NControl::setCharset()
TI18NControl::setCulture()

Inherited From TControl

TControl::__construct()
TControl::addedControl()
TControl::addParsedObject()
TControl::addToPostDataLoader()
TControl::applyStyleSheetSkin()
TControl::autoBindProperty()
TControl::autoDataBindProperties()
TControl::bindProperty()
TControl::broadcastEvent()
TControl::bubbleEvent()
TControl::clearChildState()
TControl::clearControlState()
TControl::clearNamingContainer()
TControl::clearViewState()
TControl::convertUniqueIdToClientId()
TControl::createChildControls()
TControl::createControlCollection()
TControl::dataBind()
TControl::dataBindChildren()
TControl::dataBindProperties()
TControl::ensureChildControls()
TControl::findControl()
TControl::findControlsByID()
TControl::findControlsByType()
TControl::focus()
TControl::getAdapter()
TControl::getAllowChildControls()
TControl::getAttribute()
TControl::getAttributes()
TControl::getChildControlsCreated()
TControl::getClientID()
TControl::getControls()
TControl::getControlStage()
TControl::getControlState()
TControl::getCustomData()
TControl::getEnabled()
TControl::getEnableTheming()
TControl::getEnableViewState()
TControl::getHasAdapter()
TControl::getHasAttributes()
TControl::getHasChildInitialized()
TControl::getHasControls()
TControl::getHasInitialized()
TControl::getHasLoaded()
TControl::getHasLoadedPostData()
TControl::getHasPreRendered()
TControl::getID()
TControl::getNamingContainer()
TControl::getPage()
TControl::getParent()
TControl::getRegisteredObject()
TControl::getSkinID()
TControl::getSourceTemplateControl()
TControl::getTemplateControl()
TControl::getUniqueID()
TControl::getViewState()
TControl::getVisible()
TControl::hasAttribute()
TControl::initRecursive()
TControl::isDescendentOf()
TControl::isObjectRegistered()
TControl::loadRecursive()
TControl::loadState()
TControl::loadStateRecursive()
TControl::onDataBinding()
TControl::onInit()
TControl::onLoad()
TControl::onPreRender()
TControl::onUnload()
TControl::preRenderRecursive()
TControl::raiseBubbleEvent()
TControl::registerObject()
TControl::removeAttribute()
TControl::removedControl()
TControl::render()
TControl::renderChildren()
TControl::renderControl()
TControl::saveState()
TControl::saveStateRecursive()
TControl::setAdapter()
TControl::setAttribute()
TControl::setChildControlsCreated()
TControl::setControlStage()
TControl::setControlState()
TControl::setCustomData()
TControl::setEnabled()
TControl::setEnableTheming()
TControl::setEnableViewState()
TControl::setID()
TControl::setPage()
TControl::setSkinID()
TControl::setTemplateControl()
TControl::setViewState()
TControl::setVisible()
TControl::trackViewState()
TControl::traverseChildControls()
TControl::unbindProperty()
TControl::unloadRecursive()
TControl::unregisterObject()
TControl::__get()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants

Documentation generated on Mon, 21 Apr 2008 11:36:37 -0400 by phpDocumentor 1.3.0RC4