# Path: zengine/log.py

# 
# Path: zengine/config.py



from datetime import datetime
from collections import defaultdict
from babel import Locale, UnknownLocaleError, dates, numbers, lists
from babel.support import LazyProxy
from zengine.log import log
from zengine.config import settings
import gettext as gettextlib
import six

class InstalledLocale(object):
    # Force the first language install to swap out the
    # initial NullTranslations of `_active_catalogs`
    language = ''

    datetime = DEFAULT_PREFS['locale_datetime']
    number = DEFAULT_PREFS['locale_number']
    # Until ZEngine runs and translations get installed (i.e. when using the shell),
    # just show untranslated messages for everything
    _active_catalogs = defaultdict(gettextlib.NullTranslations)
    _translation_catalogs = _load_translations()

    @classmethod
    def install_language(cls, language_code):
        """Install the translations for language specified by `language_code`.

        If we don't have translations for this language, then the default language will be used.

        If the language specified is already installed, then this is a no-op.
        """
        # Skip if the language is already installed
        if language_code == cls.language:
            return
        try:
            cls._active_catalogs = cls._translation_catalogs[language_code]
            cls.language = language_code
            log.debug('Installed language %s', language_code)
        except KeyError:
            default = settings.DEFAULT_LANG

# Path: zengine/log.py

# 
# Path: zengine/config.py



# Path: zengine/lib/translation.py
from datetime import datetime
from collections import defaultdict
from babel import Locale, UnknownLocaleError, dates, numbers, lists
from babel.support import LazyProxy
from zengine.log import log
from zengine.config import settings
import gettext as gettextlib
import six


class InstalledLocale(object):
    # Force the first language install to swap out the
    # initial NullTranslations of `_active_catalogs`
    language = ''

    datetime = DEFAULT_PREFS['locale_datetime']
    number = DEFAULT_PREFS['locale_number']
    # Until ZEngine runs and translations get installed (i.e. when using the shell),
    # just show untranslated messages for everything
    _active_catalogs = defaultdict(gettextlib.NullTranslations)
    _translation_catalogs = _load_translations()

    @classmethod
    def install_language(cls, language_code):
        """Install the translations for language specified by `language_code`.

        If we don't have translations for this language, then the default language will be used.

        If the language specified is already installed, then this is a no-op.
        """
        # Skip if the language is already installed
        if language_code == cls.language:
            return
        try:
            cls._active_catalogs = cls._translation_catalogs[language_code]
            cls.language = language_code
            log.debug('Installed language %s', language_code)
        except KeyError:
            default = settings.DEFAULT_LANG

            log.warning('Unknown language %s, falling back to %s', language_code, default)