Add core translations of the module to use in `preActivation` and `postActivation`
when the module is not yest activated and translations are not available
779762
private function initializeCoreI18n()
    {
        if ($this->hasContainer()) {
            /** @var Translator $translator */
            $translator = $this->container->get('thelia.translator');

            if (null !== $translator) {
                $i18nPath = sprintf('%s%s/I18n/', THELIA_MODULE_DIR, $this->getCode());
                $languages = LangQuery::create()->find();

                foreach ($languages as $language) {
                    $locale = $language->getLocale();
                    $i18nFile = sprintf('%s%s.php', $i18nPath, $locale);

                    if (is_file($i18nFile) && is_readable($i18nFile)) {
                        $translator->addResource('php', $i18nFile, $locale, strtolower(self::getModuleCode()));
                    }
                }
            }
        }
    }
453541
private function setLoadAfterLegacyModules(): void
    {
        static $legacy = [
            'core',
            'calendar',
            'comments',
            'faq',
            'listing',
            'news',
            'newsletter',
        ];

        $modules = array_merge($legacy, [$this->getName()]);
        sort($modules);
        $modules = array_values($modules);
        array_splice($modules, array_search($this->getName(), $modules, true));

        if (!\in_array('core', $modules, true)) {
            $modules[] = 'core';
        }

        $this->setLoadAfter($modules);
    }
328229
def iter_format_modules(lang):
    
    if check_for_language(lang):
        format_locations = []
        for path in CUSTOM_FORMAT_MODULE_PATHS:
            format_locations.append(path + '.%s')
        format_locations.append('django.conf.locale.%s')
        locale = to_locale(lang)
        locales = [locale]
        if '_' in locale:
            locales.append(locale.split('_')[0])
        for location in format_locations:
            for loc in locales:
                try:
                    yield import_module('.formats', location % loc)
                except ImportError:
                    pass
289191
def initpkg(pkgname, exportdefs, attr=None, eager=False):
    
    attr = attr or {}
    oldmod = sys.modules.get(pkgname)
    d = {}
    f = getattr(oldmod, '__file__', None)
    if f:
        f = _py_abspath(f)
    d['__file__'] = f
    if hasattr(oldmod, '__version__'):
        d['__version__'] = oldmod.__version__
    if hasattr(oldmod, '__loader__'):
        d['__loader__'] = oldmod.__loader__
    if hasattr(oldmod, '__path__'):
        d['__path__'] = [_py_abspath(p) for p in oldmod.__path__]
    if hasattr(oldmod, '__package__'):
        d['__package__'] = oldmod.__package__
    if '__doc__' not in exportdefs and getattr(oldmod, '__doc__', None):
        d['__doc__'] = oldmod.__doc__
    d.update(attr)
    if hasattr(oldmod, "__dict__"):
        oldmod.__dict__.update(d)
    mod = ApiModule(pkgname, exportdefs, implprefix=pkgname, attr=d)
    sys.modules[pkgname] = mod
    # eagerload in bypthon to avoid their monkeypatching breaking packages
    if 'bpython' in sys.modules or eager:
        for module in list(sys.modules.values()):
            if isinstance(module, ApiModule):
                module.__dict__
945785
def get_translations(self):
        
        ctx = stack.top
        if ctx is None:
            return NullTranslations()

        locale = get_locale()

        cache = self.get_translations_cache(ctx)

        translations = cache.get(str(locale))
        if translations is None:
            translations_dir = self.get_translations_path(ctx)
            translations = Translations.load(translations_dir, locale,
                                             domain=self.domain)

            # Load plugins translations
            if isinstance(translations, Translations):
                # Load core extensions translations
                from wtforms.i18n import messages_path
                wtforms_translations = Translations.load(messages_path(),
                                                         locale,
                                                         domain='wtforms')
                translations.merge(wtforms_translations)

                import flask_security
                flask_security_translations = Translations.load(
                    join(flask_security.__path__[0], 'translations'),
                    locale,
                    domain='flask_security'
                )
                translations.merge(flask_security_translations)

                for pkg in entrypoints.get_roots(current_app):
                    package = pkgutil.get_loader(pkg)
                    path = join(package.filename, 'translations')
                    domains = [f.replace(path, '').replace('.pot', '')[1:]
                               for f in iglob(join(path, '*.pot'))]
                    for domain in domains:
                        translations.merge(Translations.load(path, locale,
                                                             domain=domain))

                # Allows the theme to provide or override translations
                from . import theme

                theme_translations_dir = join(theme.current.path, 'translations')
                if exists(theme_translations_dir):
                    domain = theme.current.identifier
                    theme_translations = Translations.load(theme_translations_dir,
                                                           locale,
                                                           domain=domain)
                    translations.merge(theme_translations)

                cache[str(locale)] = translations

        return translations
1290250
def translation_activate_block(function=None, language=None):
    

    def _translation_activate_block(function):
        def _decorator(*args, **kwargs):
            tmp_language = translation.get_language()
            try:
                translation.activate(language or settings.LANGUAGE_CODE)
                return function(*args, **kwargs)
            finally:
                translation.activate(tmp_language)
        return wraps(function)(_decorator)

    if function:
        return _translation_activate_block(function)
    else:
        return _translation_activate_block
1059592
def prefetch_translations(instances, **kwargs):
    
    from .mixins import ModelMixin

    if not isinstance(instances, collections.Iterable):
        instances = [instances]

    populate_missing = kwargs.get("populate_missing", True)
    grouped_translations = utils.get_grouped_translations(instances, **kwargs)

    # In the case of no translations objects
    if not grouped_translations and populate_missing:
        for instance in instances:
            instance.populate_missing_translations()

    for instance in instances:
        if (
            issubclass(instance.__class__, ModelMixin)
            and instance.pk in grouped_translations
        ):
            for translation in grouped_translations[instance.pk]:
                instance._linguist.set_cache(instance=instance, translation=translation)
            if populate_missing:
                instance.populate_missing_translations()
767763
def update_translations(self, project_id, file_path=None,
                            language_code=None, overwrite=False, fuzzy_trigger=None):
        
        return self._upload(
            project_id=project_id,
            updating=self.UPDATING_TRANSLATIONS,
            file_path=file_path,
            language_code=language_code,
            overwrite=overwrite,
            fuzzy_trigger=fuzzy_trigger
        )
1225391
function replaceLocale(context, payload) {
      context.commit({
        type: 'REPLACE_LOCALE',
        locale: payload.locale,
        translations: payload.translations
      });
    }
605335
function Translations (params, translations) {

  /** @type {Object} Store current translations source */
  this._translations = {};
  /** @type {Object} Store current stats for latest merge request */
  this._stats = {};
  /** @type {Object} Set default parameters */
  this.params = _.defaults(params, {
    "tree": false,
    "safeMode": false,
    "nullEmpty": false
  });
  // Set translations if given as parameter
  this.setTranslations(translations);
  // Initialize statistics
  this.initStats();

}
912128
def help_center_category_translations_missing(self, category_id, **kwargs):
        ""
        api_path = "/api/v2/help_center/categories/{category_id}/translations/missing.json"
        api_path = api_path.format(category_id=category_id)
        return self.call(api_path, **kwargs)
273372
def add_localedir_translations(self, localedir):
        """"""
        global _localedirs
        if localedir in self.localedirs:
            return
        self.localedirs.append(localedir)
        full_localedir = os.path.join(localedir, 'locale')
        if os.path.exists(full_localedir):
            translation = self._new_gnu_trans(full_localedir)
            self.merge(translation)
1056595
function translateOptions(cliOptions) {
    return {
        envs: cliOptions.env,
        extensions: cliOptions.ext,
        rules: cliOptions.rule,
        plugins: cliOptions.plugin,
        globals: cliOptions.global,
        ignore: cliOptions.ignore,
        ignorePath: cliOptions.ignorePath,
        ignorePattern: cliOptions.ignorePattern,
        configFile: cliOptions.config,
        rulePaths: cliOptions.rulesdir,
        useEslintrc: cliOptions.eslintrc,
        parser: cliOptions.parser,
        parserOptions: cliOptions.parserOptions,
        cache: cliOptions.cache,
        cacheFile: cliOptions.cacheFile,
        cacheLocation: cliOptions.cacheLocation,
        fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
        fixTypes: cliOptions.fixType,
        allowInlineConfig: cliOptions.inlineConfig,
        reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
    };
}
1318799
def autodiscover():
    
    import os
    import sys
    import copy
    from django.utils.module_loading import module_has_submodule
    from modeltranslation.translator import translator
    from modeltranslation.settings import TRANSLATION_FILES, DEBUG

    from importlib import import_module
    from django.apps import apps
    mods = [(app_config.name, app_config.module) for app_config in apps.get_app_configs()]

    for (app, mod) in mods:
        # Attempt to import the app's translation module.
        module = '%s.translation' % app
        before_import_registry = copy.copy(translator._registry)
        try:
            import_module(module)
        except:
            # Reset the model registry to the state before the last import as
            # this import will have to reoccur on the next request and this
            # could raise NotRegistered and AlreadyRegistered exceptions
            translator._registry = before_import_registry

            # Decide whether to bubble up this error. If the app just
            # doesn't have an translation module, we can ignore the error
            # attempting to import it, otherwise we want it to bubble up.
            if module_has_submodule(mod, 'translation'):
                raise

    for module in TRANSLATION_FILES:
        import_module(module)

    # In debug mode, print a list of registered models and pid to stdout.
    # Note: Differing model order is fine, we don't rely on a particular
    # order, as far as base classes are registered before subclasses.
    if DEBUG:
        try:
            if sys.argv[1] in ('runserver', 'runserver_plus'):
                models = translator.get_registered_models()
                names = ', '.join(m.__name__ for m in models)
                print('modeltranslation: Registered %d models for translation'
                      ' (%s) [pid: %d].' % (len(models), names, os.getpid()))
        except IndexError:
            pass
946902
protected function overrideLangJS(): void
    {
        // Bind the Laravel JS Localization command into the app IOC.
        $this->app->singleton('localization.js', function ($app) {
            $app = $this->app;
            $laravelMajorVersion = (int) $app::VERSION;

            $files = $app['files'];

            if ($laravelMajorVersion === 4) {
                $langs = $app['path.base'].'/app/lang';
            } elseif ($laravelMajorVersion === 5) {
                $langs = $app['path.base'].'/resources/lang';
            }
            $messages = $app['config']->get('localization-js.messages');
            $generator = new LangJsGenerator($files, $langs, $messages);

            return new LangJsCommand($generator);
        });

        // Bind the Laravel JS Localization command into Laravel Artisan.
        $this->commands('localization.js');
    }
453071
function addPart(locale, master, needed, toLoad, prefix, suffix) {
        if (master[locale]) {
            needed.push(locale);
            if (master[locale] === true || master[locale] === 1) {
                toLoad.push(prefix + locale + '/' + suffix);
            }
        }
    }
295525
def lazy_translations(cls):
        """"""
        return {
            cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
            cloudfiles.errors.NoSuchObject: errors.NoObjectException,
        }