- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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: TChoiceFormat TDateFormat TGlobalization TGlobalizationAutoDetect TI18NControl TNumberFormat Translation TTranslate TTranslateParameter |
Keyword
# Class TGlobalization
    TComponent
       |
       --TApplicationComponent
          |
          --TModule
             |
             --TGlobalization
#### Direct Known Sub-classes: TGlobalizationAutoDetect 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. Since: 3.0 Author: Wei Zhuo<weizhuo[at]gmail[dot]com>
Method Summary
string | getCharset ()
string | getCulture ()
array | getCultureVariants ( string $culture) Gets all the variants of a specific culture. If the parameter $culture is null, the current culture is used.
string | getDefaultCharset ()
string | getDefaultCulture ()
array | getLocalizedResource ( string $file, string $culture) Returns a list of possible localized files. Example
string | getTranslationCatalogue ()
TMap | getTranslationConfiguration ()
void | init ( TXmlElement $xml) Initialize the Culture and Charset for this application.
void | setCharset ( string $charset)
void | setCulture ( string $culture)
void | setDefaultCharset ( string $charset)
void | setDefaultCulture ( string $culture)
void | setTranslationCatalogue ( string $value)
protected void | setTranslationConfiguration ( TMap $config) Sets the translation configuration. Example configuration:
Methods Inherited From TModule
TModule::getID(), TModule::init(), TModule::setID()
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()
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

     $files = $app->getLocalizedResource("path/to/Home.page","en_US");
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
public void init | (TXmlElement $xml )
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