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 TGlobalization

TComponent
   |
   --TApplicationComponent
      |
      --TModule
         |
         --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.

Since: 3.0
Author: Wei Zhuo<weizhuo[at]gmail[dot]com>

Method Summary
string
string
array
getCultureVariants ( string $culture)
Gets all the variants of a specific culture. If the parameter $culture is null, the current culture is used.
string
string
array
getLocalizedResource ( string $file, string $culture)
Returns a list of possible localized files. Example
string
TMap
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$culturethe 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

  1. $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$filefilename
string$cultureculture 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$xmlapplication configuration
Output
Exception

setCharset

public void setCharset (string $charset )

Input
string$charsetlocalization charset, e.g. <tt>UTF-8</tt>
Output
Exception

setCulture

public void setCulture (string $culture )

Input
string$cultureculture, e.g. <tt>en_US</tt> for American English
Output
Exception

setDefaultCharset

public void setDefaultCharset (string $charset )

Input
string$charsetdefault localization charset, e.g. <tt>UTF-8</tt>
Output
Exception

setDefaultCulture

public void setDefaultCulture (string $culture )

Input
string$culturedefault culture, e.g. <tt>en_US</tt> for American English
Output
Exception

setTranslationCatalogue

public void setTranslationCatalogue (string $value )

Input
string$valueupdate the translation catalogue.
Output
Exception

setTranslationConfiguration

protected void setTranslationConfiguration (TMap $config )

Sets the translation configuration. Example configuration:

  1. $config['type'] = 'XLIFF'; //XLIFF, gettext, Database or MySQL (deprecated)
  2. $config['source'] = 'Path.to.directory'; // for types XLIFF and gettext
  3. $config['source'] = 'connectionId'; // for type Database
  4. $config['source'] = 'mysql://user:pw@host/db'; // for type MySQL (deprecated)
  5. $config['catalogue'] = 'messages'; //default catalog
  6. $config['autosave'] = 'true'; //save untranslated message
  7. $config['cache'] = 'true'; //cache translated message
  8. $config['marker'] = '@@'; // surround untranslated text with '@@'
Throws exception is source is not found.

Input
TMap$configconfiguration options
Output
Exception