 
 
 
-    # We only need one translator
-    #
-    localeManager = new LocaleManager()
-    return localeManager
+    ##  Export singleton.
+    ##
+    return new LocaleManager()
+
 )

            )


        getLocaleName: () ->
            return @locale.name

        translate: ( key, interpolation ) ->
            @polyglot.t( key, interpolation )

        date: ( type, date ) ->
            moment = Moment( date )

            return moment.format( @locale.formatting.datetime[ type ] )

        money: ( currency, amount ) ->
            # Choose the default currency if requested
            #
            if currency is 'default'
                currency = @locale.formatting.money.default )

            sign        = @locale.formatting.money[ currency ].sign
            precision   = @locale.formatting.money[ currency ].precision
            decimal     = @locale.formatting.number.decimalMarker
            thousand    = @locale.formatting.number.thousandMarker

            return accounting.formatMoney( amount, sign, precision, thousand, decimal )

        number: ( number, precision ) ->
            precision  ?= @locale.formatting.number.precision
            decimal     = @locale.formatting.number.decimalMarker
            thousand    = @locale.formatting.number.thousandMarker

            return accounting.formatNumber( number, precision, thousand, decimal )


        ###*

( ( factory ) ->
    if typeof exports is 'object'
        module.exports = factory(
            require( 'accounting' )
            require( 'madlib-console' )
            require( 'madlib-settings' )
            require( 'madlib-xhr' )
            require( 'moment' )
            require( 'node-polyglot' )
            require( 'q' )
            require( 'underscore' )
            require( 'underscore.string/capitalize' )
        )
    else if typeof define is 'function' and define.amd
        define( [
            'accounting'
            'madlib-console'
            'madlib-settings'
            'madlib-xhr'
            'moment'
            'node-polyglot'
            'q'
            'underscore'
            'underscore.string/capitalize'
        ], factory )
    return
)((
    accounting
    console
    settings
    XHR
    Moment
    Polyglot
    Q
    _
    capitalize
) ->


    TAG = '[LocaleManager]'


    ###*
    #   A `Handlebars.js` helper collection providing keyed dictionary substitution and simple localization.
    #
    #   @author         mdoeswijk, rdewit
    #   @class          LocaleManager
    #   @constructor
    ###

    class LocaleManager

        ###*
        #   A shared object caching already loaded locale definitions.
        #
        #   @property   cache
        #   @type       Object
        #   @protected
        ###

        cache:          {}


        ###*
        #   Whether the `LocaleManager` has been `initialize()`-ed.
        #
        #   @property   initialized
        #   @type       Boolean
        #   @protected
        #
        #   @default    false
        ###

        initialized:    false


        ###*
        #   The currently active locale definition.
        #
        #   @property   locale
        #   @type       Object
        #   @protected
        ###

        locale:         undefined


        ###*
        #   A url path to use as a base for loading locale definitions.
        #
        #   @property   localeLocation
        #   @type       String
        #   @protected
        #
        #   @default    './i18n'
        ###

        localeLocation:  './i18n'


        ###*
        #   Load the initial locale definition and extend the given `Handlebars` `runtime` with `madlib-locale`'s helpers.
        #
        #   @method     initialize
        #
        #   @param      {HandleBars}    runtime                         The `Handlebars` runtime to extend with `madlib-locale`'s helper collection once the
        #                                                               locale definition has been loaded.
        #   @param      {String}        localeName                      A valid [BCP 47 language tag](https://tools.ietf.org/html/bcp47#section-2) string
        #                                                               designating a `.json` locale definition by the same name that is to be loaded;
        #   @param      {String}        [localeLocation='./i18n']       An optional url path to use as a base for loading this and any future locale
        #                                                               definitions; defaults to `'./i18n'`.
        #
        #   @return     {Promise}                                       A promise to load the locale definition.
        ###

        initialize: ( runtime, localeName, localeLocation ) ->

            if @initialized

