# Path: pylons/i18n/translation.py
# def _get_translator(lang, **kwargs):
#     """Utility method to get a valid translator object from a language
#     name"""
#     if not lang:
#         return NullTranslations()
#     if 'pylons_config' in kwargs:
#         conf = kwargs.pop('pylons_config')
#     else:
#         conf = pylons.config.current_conf()
#     localedir = os.path.join(conf['pylons.paths']['root'], 'i18n')
#     if not isinstance(lang, list):
#         lang = [lang]
#     try:
#         translator = translation(conf['pylons.package'], localedir,
#                                  languages=lang, **kwargs)
#     except IOError, ioe:
#         raise LanguageError('IOError: %s' % ioe)
#     translator.pylons_lang = lang
#     return translator


import os
import sys
import nose.plugins
import pkg_resources
import pylons
from paste.deploy import loadapp
from pylons.i18n.translation import _get_translator
        env_opt.replace('-', '_')

        parser.add_option("--with-%s" % self.name,
                          dest=self.enableOpt, type="string",
                          default="",
                          help="Setup Pylons environment with the config file"
                          " specified by ATTR [NOSE_ATTR]")

    def configure(self, options, conf):
        """Configure the plugin"""
        self.config_file = None
        self.conf = conf
        if hasattr(options, self.enableOpt):
            self.enabled = bool(getattr(options, self.enableOpt))
            self.config_file = getattr(options, self.enableOpt)

    def begin(self):
        """Called before any tests are collected or run

        Loads the application, and in turn its configuration.

        """
        global pylonsapp
        path = os.getcwd()
        sys.path.insert(0, path)
        pkg_resources.working_set.add_entry(path)
        self.app = pylonsapp = loadapp('config:' + self.config_file,
                                       relative_to=path)

        # Initialize a translator for tests that utilize i18n

# Path: pylons/i18n/translation.py
# def _get_translator(lang, **kwargs):
#     """Utility method to get a valid translator object from a language
#     name"""
#     if not lang:
#         return NullTranslations()
#     if 'pylons_config' in kwargs:
#         conf = kwargs.pop('pylons_config')
#     else:
#         conf = pylons.config.current_conf()
#     localedir = os.path.join(conf['pylons.paths']['root'], 'i18n')
#     if not isinstance(lang, list):
#         lang = [lang]
#     try:
#         translator = translation(conf['pylons.package'], localedir,
#                                  languages=lang, **kwargs)
#     except IOError, ioe:
#         raise LanguageError('IOError: %s' % ioe)
#     translator.pylons_lang = lang
#     return translator


# Path: pylons/test.py
import os
import sys
import nose.plugins
import pkg_resources
import pylons
from paste.deploy import loadapp
from pylons.i18n.translation import _get_translator

        env_opt.replace('-', '_')

        parser.add_option("--with-%s" % self.name,
                          dest=self.enableOpt, type="string",
                          default="",
                          help="Setup Pylons environment with the config file"
                          " specified by ATTR [NOSE_ATTR]")

    def configure(self, options, conf):
        """Configure the plugin"""
        self.config_file = None
        self.conf = conf
        if hasattr(options, self.enableOpt):
            self.enabled = bool(getattr(options, self.enableOpt))
            self.config_file = getattr(options, self.enableOpt)

    def begin(self):
        """Called before any tests are collected or run

        Loads the application, and in turn its configuration.

        """
        global pylonsapp
        path = os.getcwd()
        sys.path.insert(0, path)
        pkg_resources.working_set.add_entry(path)
        self.app = pylonsapp = loadapp('config:' + self.config_file,
                                       relative_to=path)

        # Initialize a translator for tests that utilize i18n

        translator = _get_translator(pylons.config.get('lang'))