finds and installs translation functions for package
179482
def get_translation_functions(package_name: str, names: Tuple[str, ...] = ('gettext',)):
    """"""
    translation = get_translation_for(package_name)
    return [getattr(translation, x) for x in names]
977555
def translate(self, package, into=None):
    """"""
    if not package.local:
      raise ValueError('BinaryTranslator cannot translate remote packages.')
    if not isinstance(package, self._package_type):
      return None
    if not package.compatible(self._supported_tags):
      TRACER.log('Target package %s is not compatible with %s' % (
          package, self._supported_tags))
      return None
    into = into or safe_mkdtemp()
    target_path = os.path.join(into, package.filename)
    safe_copy(package.local_path, target_path)
    return DistributionHelper.distribution_from_path(target_path)
341990
def needs_packages(*packages):
    '''
    '''
    def real_decorator(func):

        @wraps(func)
        def wrapper(*args, **kwargs):
            non_installed = _non_installed(packages)
            if non_installed:
                what_for = 'in order to run this task'
                install_packages(non_installed, what_for=what_for)
            return func(*args, **kwargs)

        return wrapper

    return real_decorator
898086
def get_translation_for(package_name: str) -> gettext.NullTranslations:
    """"""
    localedir = None
    for localedir in pkg_resources.resource_filename(package_name, 'i18n'), None:
        localefile = gettext.find(package_name, localedir)  # type: ignore
        if localefile:
            break
    else:
        pass
    return gettext.translation(package_name, localedir=localedir, fallback=True)
52921
function translate(key, options, hasOwnOptions) {

			var lng = options.lng || 'auto';

			if (!translations[lng]) {
				translations[lng] = {};
			}

			if (!t) {

				translations[lng][key] = 'defaultLoadingValue' in options ? options.defaultLoadingValue :
					'defaultValue' in options ? options.defaultValue :
					'defaultLoadingValue' in globalOptions ? globalOptions.defaultLoadingValue : key;

			} else if (!translations[lng][key] || hasOwnOptions) {

				translations[lng][key] = t(key, options);

			}

		}
1028123
function tree (dir, opts, cb) {
  var i = 0
  findPackage(dir, function (err, pkg) {
    pull(
      pull.depthFirst(pkg, function (pkg) {
        pkg.tree = {}
        return pull(
          pfs.readdir(path.resolve(pkg.path, 'node_modules')),
          paramap(maybe(readPackage)),
          pull.filter(function (_pkg) {
            if(!_pkg) return
            _pkg.parent = pkg
            
            pkg.tree[_pkg.name] = _pkg
            return pkg
          })
        )
      }),
      opts.post ? paramap(function (data, cb) {
        //run a post install-style hook.
        opts.post(data, cb)
      }) : pull.through(),
      pull.drain(null, function (err) {
        cb(err === true ? null : err, clean(pkg))
      })
    )
  })
}
1118150
function loadThemeTranslations() {
        // This function is called during theme initialization, and when switching language or theme.
        currentLocale = I18n.locale();
        activeTheme = settingsCache.get('active_theme');

        // Reading file for current locale and active theme and keeping its content in memory
        if (activeTheme) {
            // Reading translation file for theme .hbs templates.
            // Compatibility with both old themes and i18n-capable themes.
            // Preventing missing files.
            try {
                themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', currentLocale + '.json'));
            } catch (err) {
                themeStrings = undefined;
                if (err.code === 'ENOENT') {
                    if (currentLocale !== 'en') {
                        logging.warn(`Theme's file locales/${currentLocale}.json not found.`);
                    }
                } else {
                    throw err;
                }
            }
            if (themeStrings === undefined && currentLocale !== 'en') {
                logging.warn('Falling back to locales/en.json.');
                try {
                    themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', 'en.json'));
                } catch (err) {
                    themeStrings = undefined;
                    if (err.code === 'ENOENT') {
                        logging.warn('Theme\'s file locales/en.json not found.');
                    } else {
                        throw err;
                    }
                }
            }
            if (themeStrings !== undefined) {
                // if translation file is not valid, you will see an error
                try {
                    themeStrings = JSON.parse(themeStrings);
                } catch (err) {
                    themeStrings = undefined;
                    throw err;
                }
            }
        }

        if (themeStrings === undefined) {
            // even if empty, themeStrings must be an object for jp.value
            themeStrings = {};
        }

        _private.initializeIntl();
    }
1300921
def translate(self):
        """"""
        expressions, varnames, funcnames = self.expr.translate()

        argnames = []
        for varname in varnames:
            argnames.append(VARIABLE_PREFIX + varname)
        for funcname in funcnames:
            argnames.append(FUNCTION_PREFIX + funcname)

        func = compile_func(
            argnames,
            [ast.Return(ast.List(expressions, ast.Load()))],
        )

        def wrapper_func(values={}, functions={}):
            args = {}
            for varname in varnames:
                args[VARIABLE_PREFIX + varname] = values[varname]
            for funcname in funcnames:
                args[FUNCTION_PREFIX + funcname] = functions[funcname]
            parts = func(**args)
            return u''.join(parts)

        return wrapper_func
1039081
function loadTranslation(localeFilePath) {
    if(typeof localeFilePath == "undefined"){
        messages = defaultMessages;
        return null;
    }
    let fp = path.join(__dirname, localeFilePath);
    messages = require('jsonfile').readFileSync("." + fp);
    return messages;
}
140222
function addFixes() {
        var match = fnPackage.name.match(/^build(\w+)Fix$/);
        if (match) {
          addSugarFix(match[1], fnPackage);
          fnPackage.dependencies.push(fnCallName);
          fnPackage.postAssigns = findVarAssignments(fnPackage.node.body.body, true);
        }
      }
937764
private function installTranslations($localeID, Package $package = null)
    {
        if ($package === null) {
            $localStats = $this->localFactory->getCoreStats($localeID);
            $shownDirectoryName = '/' . DIRNAME_APPLICATION . '/' . DIRNAME_LANGUAGES;
        } else {
            $localStats = $this->localFactory->getPackageStats($package, $localeID);
            $shownDirectoryName = '/' . DIRNAME_PACKAGES . '/' . $package->getPackageHandle() . '/' . DIRNAME_LANGUAGES;
        }
        $directory = dirname($localStats->getFilename());
        if (!$this->fs->isDirectory($directory)) {
            if ($this->fs->makeDirectory($directory, DIRECTORY_PERMISSIONS_MODE_COMPUTED, true, true) !== true) {
                throw new Exception(t('Failed to create the directory for the language file. Please be sure that the %s directory is writable', $shownDirectoryName));
            }
        }
        if (!$this->fs->isWritable($directory)) {
            throw new Exception(t('Please be sure that the %s directory is writable', $shownDirectoryName));
        }
        if ($package === null) {
            $coreVersion = $this->config->get('concrete.version_installed');
            $translations = $this->remoteProvider->fetchCoreTranslations($coreVersion, $localeID);
        } else {
            $translations = $this->remoteProvider->fetchPackageTranslations($package->getPackageHandle(), $package->getPackageVersion(), $localeID);
        }
        $saved = @$this->fs->put($localStats->getFilename(), $translations, true) !== false;
        unset($translations);
        if ($saved === false) {
            throw new Exception(t('Failed to save the language file: please be sure that PHP can write files in the directory %s', $shownDirectoryName));
        }
    }
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();

}
890515
function translate (content, contentTypes) {
  let output = {}
  content.forEach(each => {
    const base = path.parse(each.file).base
    if (base === 'index.md') {
      const type = each.dir.split('/').pop()
      const contentTypeTranslation = contentTypes.find(contentType => contentType[type])
      if (contentTypeTranslation && contentTypeTranslation[type]) {
        output[type] = contentTypeTranslation[type](content, type)
      }
    }
  })
  return output
}
970372
def defpm(name, *lines):
    ''

    @register_macro(name, group='package managers')
    @shell_escape_args
    def package_manager(*packages):
        if not packages:
            return
        sh_packages = ' '.join(pkg for pkg in packages)
        expanded_lines = [line.format(sh_packages) for line in lines]
        return eval([['run'] + expanded_lines])

    package_manager.__doc__ = "install packages with {}".format(name)
429756
def avail_approaches(pkg):
    '''
    '''
    methods = [modname for importer, modname, ispkg in
               pkgutil.walk_packages(path=pkg.__path__)
               if modname not in
               ['common_args', 'directions', 'sobol_sequence']]
    return methods
133689
function() {
  var originalPackageJson;
  var cleanPackageJson = function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(){
      return originalPackageJson;
    }, {
      'end_with_newline': true
    }))
    .pipe(gulp.dest(__dirname + '/'));
  };

  /* Lazy dependencies installation */
  gulp.task('dirty-install-dep', function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      var
        tplName = addons.templates[
          (config.modules && config.modules.templates) || 'handlebars'
        ].name,
        styleName = addons.styles[
          (config.modules && config.modules.styles) || 'less'
        ].name;
      originalPackageJson = JSON.parse(JSON.stringify(json));
      json.dependencies[tplName] = lazyDependencies[tplName];
      json.dependencies[styleName] = lazyDependencies[styleName];
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dep', ['dirty-install-dep'], cleanPackageJson);

  /* Lazy dev dependencies installation */
  gulp.task('dirty-install-dev-dep', ['dirty-install-dep'], function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      addons.dev.forEach(function(moduleName) {
        json.dependencies[moduleName] = lazyDependencies[moduleName];
      });
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dev-dep', ['dirty-install-dev-dep'], cleanPackageJson);
}
1203846
function (packages) {
  var resolvedPackages = {};

  _.forOwn(packages, function (definition, packageName) {
    if (!definition) return;

    var git = definition.git;
    if (!git) return;

    var repo = resolvedPackages[git] = resolvedPackages[git] || {};

    // If no branch provided - checkout origin HEAD and
    // don't show 'detached HEAD' notification
    branch = definition.branch || '-q origin';
    // If no version provided - pull HEAD
    version = definition.version || 'HEAD';
    repo[branch] = repo[branch] || {};
    repo[branch][version] = repo[branch][version] || {};
    repo[branch][version][packageName] = definition.path || '';
  });

  return resolvedPackages;
}