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. 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. 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.
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
|
Get the key for message lookup.
|
string
|
|
TAttributeCollection
|
Returns the list of custom parameters.
|
string
|
|
boolean
|
Trim the content or not.
|
boolean
|
|
string
|
Removes the named parameter.
|
void
|
renders the translated string.
|
void
|
Set the message catalogue.
|
void
|
Set the key for message lookup.
|
void
|
|
void
|
Sets the text for localization.
|
void
|
Set the option to trim the contents.
|
protected
string
|
Translates the text with subsititution.
|
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 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()
|
Method Details |
getCatalogue
public string getCatalogue |
() |
Get the message catalogue.
Output |
string
| catalogue. |
Exception |
|
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
Returns the list of custom parameters.
Custom parameters are name-value pairs that may subsititute translation place holders during rendering.
|
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 | $name | the 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 | $value | catalogue. |
Output |
Exception |
|
setKey
public void setKey |
(string $value ) |
Set the key for message lookup.
Input |
string | $value | key |
Output |
Exception |
|
setParameter
public void setParameter |
(string $name , string $value ) |
Input |
string | $name | parameter name |
string | $value | value of the parameter |
Output |
Exception |
|
setText
public void setText |
(string $value ) |
Sets the text for localization.
Input |
string | $value | the text for translation. |
Output |
Exception |
|
setTrim
public void setTrim |
(boolean $value ) |
Set the option to trim the contents.
Input |
boolean | $value | trim or not. |
Output |
Exception |
|
translateText
protected string translateText |
(string $text , array $subs ) |
Translates the text with subsititution.
Input |
string | $text | text for translation |
array | $subs | list of substitutions |
Output |
string
| translated text |
Exception |
|
|