For applications that present content in multiple languages the DataFaucet system provides several localization (l10n) features you can use to customize data access for a specific region. These features are neatly bundled into a component called a Localization object (localization.cfc) in the system directory.
The localization object has five responsibilities:
- Return the current time in Universally Coordinated Time (UTC) to replace timestamp parameters for which the content value is specified as "now"
- Parse dates and numbers (if necessary)
- Values are not converted if they're already dates or numbers
- Convert dates with time included to Universally Coordinated Time (UTC)
- no conversion is performed if:
- the date doesn't include time information (1/1/1970 instead of 1/1/1970 10:00am)
- the Localization timezone is UTC (default)
- Sort query results for a specific language (i.e. umlauts in german text can be properly sorted)
- Provide language-specific translation of user input for specific filtering features such as and/or filters - for example and/or keywords in German would be "und" and "oder" (see /datafaucet/i18n/de.properties for an example)
The localization object has these properties
|locale||n/a||The locale (language and region) associated with the current request.|
|timezone||UTC||the ID of a Java timezone from which times should be converted to UTC|
|resourcePath||/datafaucet/i18n||path to a resource bundle file - OR - a directory containing resource bundles for translating filter keywords - if a resource bundle path is not supplied or not found, the localization object defaults to using the file /datafaucet/i18n/en.properties|
|charset||ISO-8859-1||indicates the character set used in resource bundles found in the resourcePath directory - if ISO-8859-1 then resource bundles will be read via Java (slower) otherwise they'll be read via ColdFusion|
|sortStrength||TERTIARY||the default strength for Java collation when sorting query results|
|sortDecomp||FULL||the default decomposition for Java collation when sorting query results|
The localization used for a given query defaults to a localization object set during each page request and accessible via the bootstrap method getLocalization().
<cfset loc = request.DataFaucet.getLocalization() />
Localizations can also be set within a datasource object or within an individual SQL Statement object using the respective setLocalization() method. If set these localizations will override the localization for the individual request.