models

Class i18n

lucee.Component
    extended by models.i18n

Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com --- Internationalization and localization support for ColdBox

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Property Summary
    type property default serializable required
    any controller


    • access = public
    • returntype = any
    • inject = coldbox
    true false
    any defaultLocale
          The default locale configured for the application.

    • access = public
    • returntype = any
    true false
    any defaultResourceBundle
          The default resource bundle for the application, if any.

    • access = public
    • returntype = any
    true false
    any localeStorage
          The wirebox id of the storage provider.

    • access = public
    • returntype = any
    true false
    any resourceService


    • access = public
    • returntype = any
    • inject = resourceService@cbi18n
    true false
    any settings


    • access = public
    • returntype = any
    • inject = coldbox:moduleSettings:cbi18n
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init()
          Constructor.
    Method Summary
    private any buildLocale([string thisLocale='en_US'])
         creates valid core java locale from java style locale ID.
    numeric dateAdd(numeric thisOffset, string thisDatePart, numeric dateUnits, [any thisTZ='[runtime expression]'])
         DateAdd.
    numeric dateDiff(numeric thisOffset, numeric thatOffset, string thisDatePart, [any thisTZ='[runtime expression]'])
         DateDiff.
    string dateFormat(numeric thisOffset, [numeric thisDateFormat='1'], [any tz='[runtime expression]'])
         Date format.
    any dateLocaleFormat(date date, [string style='LONG'])
         locale version of dateFormat.
    numeric dateParse(string thisDate)
         parses localized date string to datetime object or returns blank if it can't parse.
    string dateTimeFormat(numeric thisOffset, [numeric thisDateFormat='1'], [numeric thisTimeFormat='1'], [any tz='[runtime expression]'])
         DateTime format.
    numeric dateTimeParse(string thisDate)
         parses localized datetime string to datetime object or returns blank if it can't parse.
    any datetimeLocaleFormat(date date, [string dateStyle='SHORT'], [string timeStyle='SHORT'])
         locale date/time format.
    string formatDateTime(numeric thisOffset, string thisPattern, [any tz='[runtime expression]'])
         formats a date/time to given pattern.
    models.datetime fromEpoch(numeric thisOffset)
         converts java epoch offset to datetime.
    array getAvailableTZ()
         returns an array of timezones available on this server.
    string getController()
    string getCurrencySymbol([boolean localized='true'])
         returns currency symbol for this locale.
    numeric getDST([any thisTZ='[runtime expression]'])
         returns DST savings in hours.
    string getDateTimePattern([numeric thisDateFormat='1'], [numeric thisTimeFormat='3'])
         returns locale date/time pattern.
    numeric getDay(numeric thisOffset, [any tz='[runtime expression]'])
         returns day from epoch offset.
    struct getDecimalSymbols()
         returns structure holding decimal format symbols for this locale.
    string getDefaultLocale()
    string getDefaultResourceBundle()
    string getFWCountry()
         returns a human readable country name for the chosen application locale.
    string getFWCountryCode()
         returns 2-letter ISO country name for the chosen application locale.
    string getFWISO3CountryCode()
         returns 3-letter ISO country name for the chosen application locale.
    string getFWISO3LanguageCode()
         Returns the ISO 3 code for the locale's language.
    string getFWLanguage()
         Returns a human readable name for the locale's language.
    string getFWLanguageCode()
         Returns the two digit code for the locale's language.
    string getFWLocaleDisplay()
         Returns a name for the locale that is appropriate for display to the user.
    string getFwLocale()
         Get the user's locale.
    numeric getHour(numeric thisOffset, [any tz='[runtime expression]'])
         returns hour of day, 24 hr format, from epoch offset.
    array getIsoCountries()
         returns array of 2 letter ISO countries.
    array getIsoLanguages()
         returns array of 2 letter ISO languages.
    string getLocaleNames()
         returns list of locale names, UNICODE direction char (LRE/RLE) added as required.
    query getLocaleQuery()
         returns a sorted query of locales (locale,country,language,dspName,localname.
    string getLocaleStorage()
    array getLocales()
         returns array of locales.
    any getLocalizedDays()
         Facade to getShortWeedDays.
    string getLocalizedMonth(numeric month)
         Returns localized month.
    string getLocalizedYear(numeric thisYear)
         Returns localized year, probably only useful for BE calendars like in thailand, etc.
    numeric getMinute(numeric thisOffset, [any tz='[runtime expression]'])
         returns minute from epoch offset.
    numeric getMonth(numeric thisOffset, [any tz='[runtime expression]'])
         returns month from epoch offset.
    numeric getRawOffset([any tz='[runtime expression]'])
         returns rawoffset in hours.
    string getResourceService()
    numeric getSecond(numeric thisOffset, [any tz='[runtime expression]'])
         returns second from epoch offset.
    any getServerTZ()
         returns server TZ.
    string getSettings()
    array getShortWeekDays([boolean calendarOrder='true'])
         returns short day names for this calendar.
    array getTZByOffset(numeric thisOffset)
         returns a list of timezones available on this server for a given raw offset.
    string getTZDisplayName([any thisTZ='[runtime expression]'], [string dspType=''])
         returns the display name of the timezone requested in either long, short, or default style.
    any getTZOffset(date thisDate, [any thisTZ='[runtime expression]'])
         returns the offset in hours for the given datetime in the specified timezone.
    query getTZQuery(boolean returnUnique)
         returns a sorted query of timezones, optionally filters for only unique display names (fields:id,offset,dspName,longname,shortname,usesDST).
    string getWirebox()
    numeric getYear(numeric thisOffset, [any tz='[runtime expression]'])
         returns year from epoch offset.
    boolean inDST([models.requred numeric], [any tzToTest='[runtime expression]'])
         determines if a given date in a given timezone is in DST.
    boolean isBidi()
         determines if given locale is BIDI.
    boolean isValidLocale(string thisLocale)
         Validate a locale.
    void onDIComplete()
         Reads,parses,saves the locale and resource bundles defined in the config.
    any setController(any controller)
    any setDefaultLocale(any defaultLocale)
    any setDefaultResourceBundle(any defaultResourceBundle)
    i18n setFwLocale([string locale=''])
         Set the default locale to use in the framework for a specific user.
    any setLocaleStorage(any localeStorage)
    any setResourceService(any resourceService)
    any setSettings(any settings)
    any setWirebox(any wirebox)
    string timeFormat(numeric thisOffset, [numeric thisTimeFormat='1'], [any tz='[runtime expression]'])
         Time Format.
    any timeLocaleFormat(date date, [string style='SHORT'])
         locale version of timeFormat.
    numeric toEpoch(date thisDate)
         converts datetime to java epoch offset.
    boolean usesDST([any tz='[runtime expression]'])
         determines if a given timezone uses DST.
    string weekStarts()
         Determines the first DOW.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Property Detail

    controller

    property any controller

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox
    serializable - true

    defaultLocale

    property any defaultLocale

    The default locale configured for the application

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    defaultResourceBundle

    property any defaultResourceBundle

    The default resource bundle for the application, if any

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    localeStorage

    property any localeStorage

    The wirebox id of the storage provider

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    resourceService

    property any resourceService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - resourceService@cbi18n
    serializable - true

    settings

    property any settings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - coldbox:moduleSettings:cbi18n
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    buildLocale

    private any buildLocale([string thisLocale='en_US'])

    creates valid core java locale from java style locale ID

    Parameters:
    thisLocale - true
    Throws:
    i18n.InvalidLocaleException if locale is not valid

    dateAdd

    public numeric dateAdd(numeric thisOffset, string thisDatePart, numeric dateUnits, [any thisTZ='[runtime expression]'])

    DateAdd

    Parameters:
    thisOffset - true
    thisDatePart - true
    dateUnits - true
    thisTZ - true

    dateDiff

    public numeric dateDiff(numeric thisOffset, numeric thatOffset, string thisDatePart, [any thisTZ='[runtime expression]'])

    DateDiff

    Parameters:
    thisOffset - true
    thatOffset - true
    thisDatePart - true
    thisTZ - true

    dateFormat

    public string dateFormat(numeric thisOffset, [numeric thisDateFormat='1'], [any tz='[runtime expression]'])

    Date format

    Parameters:
    thisOffset - java epoch offset
    thisDateFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    tz - timezone

    dateLocaleFormat

    public any dateLocaleFormat(date date, [string style='LONG'])

    locale version of dateFormat. Needs object instantiation. That is your job not mine.

    Parameters:
    date - true
    style - FULL=0, LONG=1, MEDIUM=2, SHORT=3

    dateParse

    public numeric dateParse(string thisDate)

    parses localized date string to datetime object or returns blank if it can't parse

    Parameters:
    thisDate - true

    dateTimeFormat

    public string dateTimeFormat(numeric thisOffset, [numeric thisDateFormat='1'], [numeric thisTimeFormat='1'], [any tz='[runtime expression]'])

    DateTime format

    Parameters:
    thisOffset - java epoch offset
    thisDateFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    thisTimeFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    tz - timezone

    dateTimeParse

    public numeric dateTimeParse(string thisDate)

    parses localized datetime string to datetime object or returns blank if it can't parse

    Parameters:
    thisDate - true

    datetimeLocaleFormat

    public any datetimeLocaleFormat(date date, [string dateStyle='SHORT'], [string timeStyle='SHORT'])

    locale date/time format. Needs object instantiation. That is your job not mine.

    Parameters:
    date - true
    dateStyle - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    timeStyle - FULL=0, LONG=1, MEDIUM=2, SHORT=3

    formatDateTime

    public string formatDateTime(numeric thisOffset, string thisPattern, [any tz='[runtime expression]'])

    formats a date/time to given pattern

    Parameters:
    thisOffset - true
    thisPattern - true
    tz - true

    fromEpoch

    public models.datetime fromEpoch(numeric thisOffset)

    converts java epoch offset to datetime

    Parameters:
    thisOffset - java epoch offset to convert to datetime

    getAvailableTZ

    public array getAvailableTZ()

    returns an array of timezones available on this server


    getController

    public string getController()


    getCurrencySymbol

    public string getCurrencySymbol([boolean localized='true'])

    returns currency symbol for this locale

    Parameters:
    localized - return international (USD, THB, etc.) or localized ($,etc.) symbol

    getDST

    public numeric getDST([any thisTZ='[runtime expression]'])

    returns DST savings in hours

    Parameters:
    thisTZ

    getDateTimePattern

    public string getDateTimePattern([numeric thisDateFormat='1'], [numeric thisTimeFormat='3'])

    returns locale date/time pattern

    Parameters:
    thisDateFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    thisTimeFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3

    getDay

    public numeric getDay(numeric thisOffset, [any tz='[runtime expression]'])

    returns day from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    getDecimalSymbols

    public struct getDecimalSymbols()

    returns structure holding decimal format symbols for this locale


    getDefaultLocale

    public string getDefaultLocale()


    getDefaultResourceBundle

    public string getDefaultResourceBundle()


    getFWCountry

    public string getFWCountry()

    returns a human readable country name for the chosen application locale. Eg: United States


    getFWCountryCode

    public string getFWCountryCode()

    returns 2-letter ISO country name for the chosen application locale. Eg: us


    getFWISO3CountryCode

    public string getFWISO3CountryCode()

    returns 3-letter ISO country name for the chosen application locale. Eg: USA


    getFWISO3LanguageCode

    public string getFWISO3LanguageCode()

    Returns the ISO 3 code for the locale's language. Eg: eng


    getFWLanguage

    public string getFWLanguage()

    Returns a human readable name for the locale's language. Eg: English


    getFWLanguageCode

    public string getFWLanguageCode()

    Returns the two digit code for the locale's language. Eg: en


    getFWLocaleDisplay

    public string getFWLocaleDisplay()

    Returns a name for the locale that is appropriate for display to the user. Eg: English (United States)


    getFwLocale

    public string getFwLocale()

    Get the user's locale

    Returns:
    The users locale string if set, else, the default locale

    getHour

    public numeric getHour(numeric thisOffset, [any tz='[runtime expression]'])

    returns hour of day, 24 hr format, from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    getIsoCountries

    public array getIsoCountries()

    returns array of 2 letter ISO countries


    getIsoLanguages

    public array getIsoLanguages()

    returns array of 2 letter ISO languages


    getLocaleNames

    public string getLocaleNames()

    returns list of locale names, UNICODE direction char (LRE/RLE) added as required


    getLocaleQuery

    public query getLocaleQuery()

    returns a sorted query of locales (locale,country,language,dspName,localname. 'localname' will contain the locale's name in its native characters). Suitable for use in creating select lists.


    getLocaleStorage

    public string getLocaleStorage()


    getLocales

    public array getLocales()

    returns array of locales


    getLocalizedDays

    public any getLocalizedDays()

    Facade to getShortWeedDays. For compatability


    getLocalizedMonth

    public string getLocalizedMonth(numeric month)

    Returns localized month.

    Parameters:
    month - true

    getLocalizedYear

    public string getLocalizedYear(numeric thisYear)

    Returns localized year, probably only useful for BE calendars like in thailand, etc.

    Parameters:
    thisYear - true

    getMinute

    public numeric getMinute(numeric thisOffset, [any tz='[runtime expression]'])

    returns minute from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    getMonth

    public numeric getMonth(numeric thisOffset, [any tz='[runtime expression]'])

    returns month from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    getRawOffset

    public numeric getRawOffset([any tz='[runtime expression]'])

    returns rawoffset in hours

    Parameters:
    tz - true

    getResourceService

    public string getResourceService()


    getSecond

    public numeric getSecond(numeric thisOffset, [any tz='[runtime expression]'])

    returns second from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    getServerTZ

    public any getServerTZ()

    returns server TZ


    getSettings

    public string getSettings()


    getShortWeekDays

    public array getShortWeekDays([boolean calendarOrder='true'])

    returns short day names for this calendar

    Parameters:
    calendarOrder - true

    getTZByOffset

    public array getTZByOffset(numeric thisOffset)

    returns a list of timezones available on this server for a given raw offset

    Parameters:
    thisOffset - true

    getTZDisplayName

    public string getTZDisplayName([any thisTZ='[runtime expression]'], [string dspType=''])

    returns the display name of the timezone requested in either long, short, or default style

    Parameters:
    thisTZ - true
    dspType - true

    getTZOffset

    public any getTZOffset(date thisDate, [any thisTZ='[runtime expression]'])

    returns the offset in hours for the given datetime in the specified timezone

    Parameters:
    thisDate - true
    thisTZ - true

    getTZQuery

    public query getTZQuery(boolean returnUnique)

    returns a sorted query of timezones, optionally filters for only unique display names (fields:id,offset,dspName,longname,shortname,usesDST). Suitable for use in creating select lists.

    Parameters:
    returnUnique - true

    getWirebox

    public string getWirebox()


    getYear

    public numeric getYear(numeric thisOffset, [any tz='[runtime expression]'])

    returns year from epoch offset

    Parameters:
    thisOffset - java epoch offset
    tz - true

    inDST

    public boolean inDST([models.requred numeric], [any tzToTest='[runtime expression]'])

    determines if a given date in a given timezone is in DST

    Parameters:
    numeric
    tzToTest - true

    isBidi

    public boolean isBidi()

    determines if given locale is BIDI. core java uses 'iw' for hebrew, leaving 'he' just in case this is a version thing


    isValidLocale

    public boolean isValidLocale(string thisLocale)

    Validate a locale

    Parameters:
    thisLocale - Locale to validate

    onDIComplete

    public void onDIComplete()

    Reads,parses,saves the locale and resource bundles defined in the config.

    Throws:
    i18N.DefaultSettingsInvalidException

    setController

    public any setController(any controller)

    Parameters:
    controller

    setDefaultLocale

    public any setDefaultLocale(any defaultLocale)

    Parameters:
    defaultLocale

    setDefaultResourceBundle

    public any setDefaultResourceBundle(any defaultResourceBundle)

    Parameters:
    defaultResourceBundle

    setFwLocale

    public i18n setFwLocale([string locale=''])

    Set the default locale to use in the framework for a specific user.

    Parameters:
    locale - The locale to change and set. Must be Java Style: en_US. If none passed, then we default to default locale from configuration settings

    setLocaleStorage

    public any setLocaleStorage(any localeStorage)

    Parameters:
    localeStorage

    setResourceService

    public any setResourceService(any resourceService)

    Parameters:
    resourceService

    setSettings

    public any setSettings(any settings)

    Parameters:
    settings

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    timeFormat

    public string timeFormat(numeric thisOffset, [numeric thisTimeFormat='1'], [any tz='[runtime expression]'])

    Time Format

    Parameters:
    thisOffset - java epoch offset
    thisTimeFormat - FULL=0, LONG=1, MEDIUM=2, SHORT=3
    tz - timezone

    timeLocaleFormat

    public any timeLocaleFormat(date date, [string style='SHORT'])

    locale version of timeFormat. Needs object instantiation. That is your job not mine.

    Parameters:
    date - true
    style - FULL=0, LONG=1, MEDIUM=2, SHORT=3

    toEpoch

    public numeric toEpoch(date thisDate)

    converts datetime to java epoch offset

    Parameters:
    thisDate - datetime to convert to java epoch

    usesDST

    public boolean usesDST([any tz='[runtime expression]'])

    determines if a given timezone uses DST

    Parameters:
    tz - true

    weekStarts

    public string weekStarts()

    Determines the first DOW.