Class TGlobalization
Direct Known Sub-classes:
TGlobalization contains settings for Culture, Charset and TranslationConfiguration.
TGlobalization can be subclassed to change how the Culture, Charset are determined. See TGlobalizationAutoDetect for example of setting the Culture based on browser settings.
Method Summary |
string
|
|
string
|
|
array
|
Gets all the variants of a specific culture. If the parameter $culture is null, the current culture is used.
|
string
|
|
string
|
|
array
|
Returns a list of possible localized files. Example
|
string
|
|
TMap
|
|
void
|
Initialize the Culture and Charset for this application.
|
void
|
|
void
|
|
void
|
|
void
|
|
void
|
|
protected
void
|
Sets the translation configuration. Example configuration:
|
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 |
getCharset
public string getCharset |
() |
Output |
string
| localization charset |
Exception |
|
getCulture
public string getCulture |
() |
Output |
string
| current application culture |
Exception |
|
getCultureVariants
public array getCultureVariants |
(string $culture ) |
Gets all the variants of a specific culture. If the parameter $culture is null, the current culture is used.
Input |
string | $culture | the Culture string |
Output |
array
| variants of the culture. |
Exception |
|
getDefaultCharset
public string getDefaultCharset |
() |
Output |
string
| default charset set |
Exception |
|
getDefaultCulture
public string getDefaultCulture |
() |
Output |
string
| default culture |
Exception |
|
getLocalizedResource
public array getLocalizedResource |
(string $file , string $culture ) |
Returns a list of possible localized files. Example
will return array
0 => 'path/to/en_US/Home.page'
1 => 'path/to/en/Home.page'
2 => 'path/to/Home.en_US.page'
3 => 'path/to/Home.en.page'
4 => 'path/to/Home.page' Note that you still need to verify the existance of these files.
Input |
string | $file | filename |
string | $culture | culture string, null to use current culture |
Output |
array
| list of possible localized resource files. |
Exception |
|
getTranslationCatalogue
public string getTranslationCatalogue |
() |
Output |
string
| current translation catalogue. |
Exception |
|
getTranslationConfiguration
public TMap getTranslationConfiguration |
() |
Output |
TMap
| translation source configuration. |
Exception |
|
init
Initialize the Culture and Charset for this application.
You should override this method if you want a different way of setting the Culture and/or Charset for your application. If you override this method, call parent::init($xml) first.
Input |
TXmlElement | $xml | application configuration |
Output |
Exception |
|
setCharset
public void setCharset |
(string $charset ) |
Input |
string | $charset | localization charset, e.g. <tt>UTF-8</tt> |
Output |
Exception |
|
setCulture
public void setCulture |
(string $culture ) |
Input |
string | $culture | culture, e.g. <tt>en_US</tt> for American English |
Output |
Exception |
|
setDefaultCharset
public void setDefaultCharset |
(string $charset ) |
Input |
string | $charset | default localization charset, e.g. <tt>UTF-8</tt> |
Output |
Exception |
|
setDefaultCulture
public void setDefaultCulture |
(string $culture ) |
Input |
string | $culture | default culture, e.g. <tt>en_US</tt> for American English |
Output |
Exception |
|
setTranslationCatalogue
public void setTranslationCatalogue |
(string $value ) |
Input |
string | $value | update the translation catalogue. |
Output |
Exception |
|
setTranslationConfiguration
protected void setTranslationConfiguration |
(TMap $config ) |
Sets the translation configuration. Example configuration:
- $config['type'] = 'XLIFF'; //XLIFF, gettext, Database or MySQL (deprecated)
- $config['source'] = 'Path.to.directory'; // for types XLIFF and gettext
- $config['source'] = 'connectionId'; // for type Database
- $config['source'] = 'mysql://user:pw@host/db'; // for type MySQL (deprecated)
- $config['catalogue'] = 'messages'; //default catalog
- $config['autosave'] = 'true'; //save untranslated message
- $config['cache'] = 'true'; //cache translated message
- $config['marker'] = '@@'; // surround untranslated text with '@@'
Throws exception is source is not found.
Input |
TMap | $config | configuration options |
Output |
Exception |
|
|