Loads the dictionaries from the locale directory.
@param {Object} options
515840
function load(options) {
  if (cache[options.locales]) {
    options.verbose && gutil.log('Skip loading cached translations from', options.locales);
    return dictionaries = cache[options.locales];
  }
  try {
    options.verbose && gutil.log('Loading translations from', options.locales);
    var files = fs.readdirSync(options.locales);
    var count = 0;
    for (var i in files) {
      var file = files[i];
      switch (path.extname(file)) {
        case '.json':
        case '.js':
          dictionaries[path.basename(file, path.extname(file))] = flat(require(path.join(process.cwd(), options.locales, file)));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.ini':
          var iniData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = flat(ini2json(iniData));
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        case '.csv':
          var csvData = fs.readFileSync(path.join(process.cwd(), options.locales, file));
          dictionaries[path.basename(file, path.extname(file))] = csv2json(csvData);
          options.verbose && gutil.log('Added translations from', file);
          count++;
          break;
        default:
          options.verbose && gutil.log('Ignored file', file);
      }
    }
    options.verbose && gutil.log('Loaded', count,  'translations from', options.locales);
    if (options.cache) {
      options.verbose && gutil.log('Cashing translations from', options.locales);
      cache[options.locales] = dictionaries;
    }
  } catch (e) {
    e.message = 'No translation dictionaries have been found!';
    throw e;
  }
}
643002
function translate(key, options, hasOwnOptions) {

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

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

			if (!t) {
				translations[lng][key] = key;
			} else if (!translations[lng][key] || hasOwnOptions) {
				translations[lng][key] = t(key, options);
			}

		}
42125
function registerLocales (headers) {
  var localesList = {
    indexes: {}
  };
  var i = headers.length - 1;
  var localeName;

  while (i >= 2) {
    localeName = headers[i].trim().split(/[\s\(]/)[0];
    localesList[localeName] = {
      localeName: localeName,
      messages: {}
    };
    localesList.indexes[i] = localeName;
    i--;
  }
  return localesList;
}
561226
function load(build) {
  // Resolve all paths.
  if (build.packageFile)
    build.packageFile = build.resolvePath(build.packageFile);
  if (build.sourceDir)
    build.sourceDir = build.resolvePath(build.sourceDir);
  if (build.destDir)
    build.destDir = build.resolvePath(build.destDir);
  if (build.localesDir)
    build.localesDir = build.resolvePath(build.localesDir);
  if (build.engine.nunjucks.extensionsFile)
    build.engine.nunjucks.extensionsFile = 
      build.resolvePath(build.engine.nunjucks.extensionsFile);
  if (build.engine.nunjucks.filtersFile)
    build.engine.nunjucks.filtersFile = 
      build.resolvePath(build.engine.nunjucks.filtersFile);
  if (build.contextFile)
    build.contextFile = build.resolvePath(build.contextFile);
  // Load stuff.
  loadPackage(build);
  loadLocales(build);
  loadViewContext(build);
  loadNunjucksFiles(build);
}
1117347
function parseJSON(locale, data = {}, options = {}) {
  const separator = options.keyseparator || '##';
  const json = {};
  const ctxSeparator = options.ctxSeparator || '_';

  Object.keys(data).forEach((m) => {
    const context = data[m];

    Object.keys(context).forEach((key) => {
      let targetKey = key;
      let appendTo = json;

      if (key.length === 0) {
        // delete if msgid is empty.
        // this might be the header.
        delete context[key];
        return;
      }

      if (options.skipUntranslated && isFuzzy(context[key])) {
        delete context[key];
        return;
      }

      if (key.indexOf(separator) > -1) {
        const keys = key.split(separator);

        let x = 0;
        while (keys[x]) {
          if (x < keys.length - 1) {
            appendTo[keys[x]] = appendTo[keys[x]] || {};
            appendTo = appendTo[keys[x]];
          } else {
            targetKey = keys[x];
          }
          x += 1;
        }
      }

      if (m !== '') targetKey = `${targetKey}${ctxSeparator}${m}`;

      const values = context[key].msgstr;
      const newValues = getGettextValues(values, locale, targetKey, options);
      Object.assign(appendTo, newValues);
    });
  });

  return Promise.resolve(json);
}
666450
function load(dirPath) {

    findFiles(dirPath, function(filePath){
        collection.push( require(filePath) );
    })

    function findFiles(dirPath, callback){
        fs.readdir(dirPath, function(err, files) {
            files.forEach(function(file){
                fs.stat(dirPath + '/' + file, function(err, stats) {
                    if(stats.isFile()) {
                        callback(dirPath + '/' + file);
                    }
                    if(stats.isDirectory()) {
                        getDirectoryFiles(dirPath + '/' + file, callback);
                    }
                });
            });
        });
    }
}
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;
}
40636
function (options, callback) {
        options = extend({}, DEPENDENCY_WRITE_DEFAULTS, options)
        var json = require(options.jsonUri)

        // the JSON DSL has the option to have "/foo" in <moduleNameLeft>
        after.reduce(json, createFoldersIntoFilesIterator(options.uri), 
            {}, runDependencyMapper)

        function runDependencyMapper(err, data) {
            if (err) {
                return callback(err)
            }
            after.map(data, mapToDependencies, callback)
        }

        function mapToDependencies(dependencies, moduleName, callback) {
            if (isFile.test(moduleName)) {
                // the JSON DSL has the option to have "/foo" or ["/foo"]
                // in <moduleNameRight>.
                after.map(dependencies, createConvertToProxyNameIterator({
                    moduleName: moduleName,
                    uri: options.uri
                }), callback)
            }
        }
    }
530663
def localized(locales = I18n.available_locales, opts = {})
      # Add if not added Rails.root/config/locales/*.yml in the I18n.load_path
      if !@i18n_routing_path_set and defined?(Rails) and Rails.respond_to?(:root) and Rails.root
        I18n.load_path = (I18n.load_path << Dir[Rails.root.join('config', 'locales', '*.yml')]).flatten.uniq
        @i18n_routing_path_set = true
      end

      old_value = @locales
      @locales = locales
      @i18n_verbose ||= opts.delete(:verbose)
      yield
    ensure
      @locales = old_value
    end
322492
def load_from_filesystem(options)
      return if options[:skip_metadata]

      # Load localised data
      ignore_validation = options[:ignore_language_directory_validation]
      Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|
        language = File.basename(lang_folder)
        (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|
          path = File.join(lang_folder, "#{key}.txt")
          next unless File.exist?(path)

          UI.message("Loading '#{path}'...")
          options[key] ||= {}
          options[key][language] ||= File.read(path)
        end
      end

      # Load non localised data
      (NON_LOCALISED_VERSION_VALUES + NON_LOCALISED_APP_VALUES).each do |key|
        path = File.join(options[:metadata_path], "#{key}.txt")
        next unless File.exist?(path)

        UI.message("Loading '#{path}'...")
        options[key] ||= File.read(path)
      end

      # Load trade representative contact information
      options[:trade_representative_contact_information] ||= {}
      TRADE_REPRESENTATIVE_CONTACT_INFORMATION_VALUES.values.each do |option_name|
        path = File.join(options[:metadata_path], TRADE_REPRESENTATIVE_CONTACT_INFORMATION_DIR, "#{option_name}.txt")
        next unless File.exist?(path)
        next if options[:trade_representative_contact_information][option_name].to_s.length > 0

        UI.message("Loading '#{path}'...")
        options[:trade_representative_contact_information][option_name] ||= File.read(path)
      end

      # Load review information
      options[:app_review_information] ||= {}
      REVIEW_INFORMATION_VALUES.values.each do |option_name|
        path = File.join(options[:metadata_path], REVIEW_INFORMATION_DIR, "#{option_name}.txt")
        next unless File.exist?(path)
        next if options[:app_review_information][option_name].to_s.length > 0

        UI.message("Loading '#{path}'...")
        options[:app_review_information][option_name] ||= File.read(path)
      end
    end
769820
function addLocale(locale, translations) {
    return store.dispatch({
      type: "".concat(moduleName, "/addLocale"),
      locale: locale,
      translations: translations
    });
  }
499482
function parseGettext(locale, data, options = {}) {
  const out = {
    charset: 'utf-8',
    headers: {
      'project-id-version': options.project || 'i18next-conv',
      'mime-version': '1.0',
      'content-type': 'text/plain; charset=utf-8',
      'content-transfer-encoding': '8bit',
    },
    translations: {},
  };

  const ext = plurals.getRule(locale);
  const trans = {};

  out.headers['plural-forms'] = `nplurals=${ext.nplurals}; plural=${ext.plurals}`;

  if (!options.noDate) {
    out.headers['pot-creation-date'] = new Date().toISOString();
    out.headers['po-revision-date'] = new Date().toISOString();
    if (options.potCreationDate && typeof options.potCreationDate.toISOString === 'function') out.headers['pot-creation-date'] = options.potCreationDate.toISOString();
    if (options.poRevisionDate && typeof options.poRevisionDate.toISOString === 'function') out.headers['po-revision-date'] = options.poRevisionDate.toISOString();
  }
  if (options.language) {
    out.headers.language = options.language;
  }
  const delkeys = [];

  Object.keys(data).forEach((m) => {
    const kv = data[m];

    if (kv.plurals) {
      const pArray = [];

      for (let i = 0, len = kv.plurals.length; i < len; i += 1) {
        const plural = kv.plurals[i];
        pArray.splice(getGettextPluralPosition(ext, plural.pluralNumber - 1), 0, plural.value);
      }
      pArray.splice(getGettextPluralPosition(ext, kv.pluralNumber - 1), 0, kv.value);

      if (typeof trans[kv.context] !== 'object') trans[kv.context] = {};
      if (options.keyasareference) {
        if (typeof trans[kv.context][kv.value] === 'object') {
          // same context and msgid. this could theorically be merged.
          trans[kv.context][kv.value].comments.reference.push(kv.key);
        } else {
          trans[kv.context][kv.value] = {
            msgctxt: kv.context,
            msgid: pArray[0],
            msgid_plural: pArray.slice(1, pArray.length),
            msgstr: kv.translated_value,
            comments: { reference: [kv.key] },
          };
        }
        if (kv.key !== kv.value) {
          delkeys.push([kv.context, kv.key]);
        }
      } else {
        trans[kv.context][kv.key] = {
          msgctxt: kv.context,
          msgid: kv.key,
          msgid_plural: kv.key,
          msgstr: pArray,
        };
      }
    } else {
      if (typeof trans[kv.context] !== 'object') trans[kv.context] = {};

      if (options.keyasareference) {
        if (typeof trans[kv.context][kv.value] === 'object') {
          // same context and msgid. this could theorically be merged.
          trans[kv.context][kv.value].comments.reference.push(kv.key);
        } else {
          trans[kv.context][kv.value] = {
            msgctxt: kv.context,
            msgid: kv.value,
            msgstr: kv.translated_value,
            comments: {
              reference: [kv.key],
            },
          };
        }
        if (kv.key !== kv.value) {
          delkeys.push([kv.context, kv.key]);
        }
      } else {
        trans[kv.context][kv.key] = { msgctxt: kv.context, msgid: kv.key, msgstr: kv.value };
      }
    }
  });

  delkeys.forEach((a) => {
    const c = a[0];
    const k = a[1];
    delete trans[c][k];
  });

  // re-format reference comments to be able to compile with gettext-parser...
  Object.keys(trans).forEach((ctxt) => {
    Object.keys(trans[ctxt]).forEach((id) => {
      if (trans[ctxt][id].comments && trans[ctxt][id].comments.reference) {
        trans[ctxt][id].comments.reference = trans[ctxt][id].comments.reference.join('\n');
      }
    });
  });

  out.translations = trans;
  return Promise.resolve(out);
}
399956
async def load(self,
                   file_path,
                   locale=None,
                   key: int = 0,
                   pos: int = 1,
                   neg: Optional[ColRanges] = None):
        

        if neg is None:
            neg: ColRanges = [(2, None)]

        await self.start(file_path, locale, kwargs={
            'key': key,
            'pos': pos,
            'neg': neg,
        })
1300961
function getLocals(options) {
    if (!options || !options.locals) {
      return self.options.locals;
    }

    return utils.extend({}, self.options.locals, options.locals);
  }
101826
function (directory, callback) {
        var that = this;
        fs.readdir(directory, function (err, files) {
            async.map(files, function langdir_iterator(file, next) {
                file = path.join(directory, file);
                fs.stat(file, function (err, stats) {
                    if (err || !stats.isDirectory()) return next(err);
                    var l = path.basename(file);
                    fs.readdir(file, function (err, files) {
                        if (err) return next(err);
                        async.map(files, function podir_iterator(file, next) {
                            file = path.join(directory, l, file);
                            fs.stat(file, function (err, stats) {
                                if (err || !stats.isFile()) return next(err);
                                that.loadLanguageFile(file, l, next);
                            });
                        }, next);
                    });
                });
            }, function langdir_done(err, results) {
                callback && callback(err);
            });
        });
    }
93368
function _importDirectoryOptionsParser(options={}) {
  const _options = Object.assign({
    imports: {},
    onload: options.callback,
    extension: makeArray(options.extensions || settings.get('extensions')),
    useSyncRequire: settings.get('useSyncRequire'),
    merge: settings.get('mergeImports'),
    rescursive: false
  }, options, {
    squashErrors: !!options.retry
  });

  if (_options.extensions) delete _options.extensions;

  if (options.callback) console.warn(`The options.callback method is deprecated, please use options.onload() instead. This being used in ${getCallingFileName()}`);

  return _options;
}
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);

			}

		}