Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TTranslate

Direct Known Sub-classes:

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.

Author: Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
Constants Inherited From TControl
AUTOMATIC_ID_PREFIX, CLIENT_ID_SEPARATOR, CS_CHILD_INITIALIZED, CS_CONSTRUCTED, CS_INITIALIZED, CS_LOADED, CS_PRERENDERED, CS_STATE_LOADED, ID_FORMAT, ID_SEPARATOR, IS_CHILD_CREATED, IS_CREATING_CHILD, IS_DISABLE_THEMING, IS_DISABLE_VIEWSTATE, IS_ID_SET, IS_SKIN_APPLIED, IS_STYLESHEET_APPLIED, RF_ADAPTER, RF_AUTO_BINDINGS, RF_CHILD_STATE, RF_CONTROLS, RF_CONTROLSTATE, RF_DATA_BINDINGS, RF_EVENTS, RF_NAMED_CONTROLS, RF_NAMED_CONTROLS_ID, RF_NAMED_OBJECTS, RF_SKIN_ID,

Method Summary
string
Get the message catalogue.
string
getKey ()
Get the key for message lookup.
string
getParameter ( mixed $name)
TAttributeCollection
Returns the list of custom parameters.
string
getText ()
boolean
getTrim ()
Trim the content or not.
boolean
hasParameter ( mixed $name)
string
removeParameter ( string $name)
Removes the named parameter.
void
render ( mixed $writer)
renders the translated string.
void
setCatalogue ( string $value)
Set the message catalogue.
void
setKey ( string $value)
Set the key for message lookup.
void
setParameter ( string $name, string $value)
void
setText ( string $value)
Sets the text for localization.
void
setTrim ( boolean $value)
Set the option to trim the contents.
protected  string
translateText ( string $text, array $subs)
Translates the text with subsititution.
Methods Inherited From TI18NControl
TI18NControl::getCharset(), TI18NControl::getCulture(), TI18NControl::setCharset(), TI18NControl::setCulture()
Methods Inherited From TControl
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()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods 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()

Constant Summary

Method Details

getCatalogue

public string getCatalogue ()

Get the message catalogue.

Output
string catalogue.
Exception

getKey

public string getKey ()

Get the key for message lookup.

Output
string key
Exception

getParameter

public string getParameter (mixed $name )

Input
mixed$name
Output
string parameter value, null if parameter does not exist
Exception

getParameters

public TAttributeCollection getParameters ()

Returns the list of custom parameters.

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

Output
TAttributeCollection the list of custom parameters
Exception

getText

public string getText ()

Output
string the text to be localized/translated.
Exception

getTrim

public boolean getTrim ()

Trim the content or not.

Output
boolean trim or not.
Exception

hasParameter

public boolean hasParameter (mixed $name )

Input
mixed$name
Output
boolean whether the named parameter exists
Exception

removeParameter

public string removeParameter (string $name )

Removes the named parameter.

Input
string$namethe name of the parameter to be removed.
Output
string parameter value removed, null if parameter does not exist.
Exception

render

public void render (mixed $writer )

renders the translated string.

Input
mixed$writer
Output
Exception

setCatalogue

public void setCatalogue (string $value )

Set the message catalogue.

Input
string$valuecatalogue.
Output
Exception

setKey

public void setKey (string $value )

Set the key for message lookup.

Input
string$valuekey
Output
Exception

setParameter

public void setParameter (string $name , string $value )

Input
string$nameparameter name
string$valuevalue of the parameter
Output
Exception

setText

public void setText (string $value )

Sets the text for localization.

Input
string$valuethe text for translation.
Output
Exception

setTrim

public void setTrim (boolean $value )

Set the option to trim the contents.

Input
boolean$valuetrim or not.
Output
Exception

translateText

protected string translateText (string $text , array $subs )

Translates the text with subsititution.

Input
string$texttext for translation
array$subslist of substitutions
Output
string translated text
Exception