Merges two localization languages and return merged YAML string and indexes of added lines.
519253
public function addStringsFromAnotherLanguage($destContents, $srcArray)
    {
        // 1. Find array keys that exists in the source array and don't exist in the destination array
        // 2. Merge the arrays recursively
        // 3. To find which lines were added:
        //    3.1 get a YAML representation of the destination array
        //    3.2 walk through the missing paths obtained in step 1 and for each path:
        //    3.3 find its path and its corresponding line in the string from 3.1.

        $result = [
            'strings' => '',
            'mismatch' => false,
            'updatedLines' => [],
        ];

        try
        {
            $destArray = Yaml::parse($destContents);
        }
        catch (Exception $ex) {
            throw new ApplicationException(sprintf('Cannot parse the YAML content: %s', $ex->getMessage()));
        }

        if (!$destArray) {
            $result['strings'] = $this->arrayToYaml($srcArray);
            return $result;
        }

        $mismatch = false;
        $missingPaths = $this->findMissingPaths($destArray, $srcArray, $mismatch);
        $mergedArray = self::arrayMergeRecursive($srcArray, $destArray);

        $destStrings = $this->arrayToYaml($mergedArray);
        $addedLines = $this->getAddedLines($destStrings, $missingPaths);

        $result['strings'] = $destStrings;
        $result['updatedLines'] = $addedLines['lines'];
        $result['mismatch'] = $mismatch || $addedLines['mismatch'];

        return $result;
    }
273210
function  {
  var defaultLocaleBundle, localeBundle, merged;
  var aux = {};

  init();

  // Load i18n content.
  loadCldr(defaultLocale);
  loadCldr(locale);

  defaultLocaleBundle = new Globalize(defaultLocale).cldr.attributes.bundle;
  localeBundle = new Globalize(locale).cldr.attributes.bundle;

  assertLocale(locale);
  assert(typeof translation === "object", "missing or invalid `translation` argument, JSON expected (e.g., {\"en\": ...})");
  assert(typeof defaultLocale === "string", "missing or invalid `defaultLocale` argument, String expected (e.g., \"en\")");

  aux[localeBundle] = generateDefaultTranslation(defaultLocale)[defaultLocaleBundle];
  merged = merge({}, aux, translation);
  if (orderedStringify(translation) !== orderedStringify(merged)) {
    return merged;
  }
}
998493
protected function mergeGenericLocales(array $inputLocales)
    {
        $locales = [];
        foreach ($inputLocales as $locale) {
            $locales[] = $locale;
            if (strlen($locale) === 5) {
                $locale = substr($locale, 0, 2);
                $locales[] = $locale;
            }
        }

        $locales = array_reverse(array_unique(array_reverse($locales)));

        return $locales;
    }
884079
def merge_config(config)
      @config.deep_merge!(config)
      complement

      unless @config['epubversion'].nil?
        case @config['epubversion'].to_i
        when 2
          @epub = EPUBMaker::EPUBv2.new(self)
        when 3
          @epub = EPUBMaker::EPUBv3.new(self)
        else
          raise "Invalid EPUB version (#{@config['epubversion']}.)"
        end
      end
      if config['language']
        ReVIEW::I18n.locale = config['language']
      end
      support_legacy_maker
    end
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;
}
633896
private function addGettextEntriesToLocale(Locale $locale, Translations $translations)
    {
        $defaultTranslations = $locale->hasPoFile() ?
            Translations::fromPoFile($locale->getPoFilePath()) :
            new Translations();

        $i18n = Strata::i18n();

        // it looks reversed to merge defaults into the found strings, but it's the
        // most efficient way of keeping existing translations
        $i18n->hardTranslationSetMerge($locale, $defaultTranslations, $translations);
        $i18n->generateTranslationFiles($locale, $translations);
    }
137232
private Map<String, String> getMessagesForLocale() {

        Map<Locale, Map<String, String>> data = getData();
        if (data == null) {
            return Collections.emptyMap();
        }
        List<Locale> available = new ArrayList<Locale>(data.keySet());
        Locale bestMatchingLocale = OpenCms.getLocaleManager().getBestMatchingLocale(
            getLocale(),
            OpenCms.getLocaleManager().getDefaultLocales(),
            available);
        Map<String, String> bundleForLocale = data.get(bestMatchingLocale);
        if (bundleForLocale == null) {
            return Collections.emptyMap();
        } else {
            return Collections.unmodifiableMap(bundleForLocale);
        }
    }
769820
function addLocale(locale, translations) {
    return store.dispatch({
      type: "".concat(moduleName, "/addLocale"),
      locale: locale,
      translations: translations
    });
  }
908430
def _ParseOrMerge(self, lines, message):
    
    tokenizer = Tokenizer(lines)
    while not tokenizer.AtEnd():
      self._MergeField(tokenizer, message)
358763
public function load_language($lang = null, $add = array(), $merge = array())
    {
        $lang = $this->language_prop($lang ?: $_SESSION['language']);

        // load localized texts
        if (empty($this->texts) || $lang != $_SESSION['language']) {
            $this->texts = array();

            // handle empty lines after closing PHP tag in localization files
            ob_start();

            // get english labels (these should be complete)
            @include(RCUBE_LOCALIZATION_DIR . 'en_US/labels.inc');
            @include(RCUBE_LOCALIZATION_DIR . 'en_US/messages.inc');

            if (is_array($labels))
                $this->texts = $labels;
            if (is_array($messages))
                $this->texts = array_merge($this->texts, $messages);

            // include user language files
            if ($lang != 'en' && $lang != 'en_US' && is_dir(RCUBE_LOCALIZATION_DIR . $lang)) {
                include_once(RCUBE_LOCALIZATION_DIR . $lang . '/labels.inc');
                include_once(RCUBE_LOCALIZATION_DIR . $lang . '/messages.inc');

                if (is_array($labels))
                    $this->texts = array_merge($this->texts, $labels);
                if (is_array($messages))
                    $this->texts = array_merge($this->texts, $messages);
            }

            ob_end_clean();

            $_SESSION['language'] = $lang;
        }

        // append additional texts (from plugin)
        if (is_array($add) && !empty($add)) {
            $this->texts += $add;
        }

        // merge additional texts (from plugin)
        if (is_array($merge) && !empty($merge)) {
            $this->texts = array_merge($this->texts, $merge);
        }
    }
37471
public function mergeWith(Translations $translations, $options = Merge::DEFAULTS)
    {
        Merge::mergeHeaders($translations, $this, $options);
        Merge::mergeTranslations($translations, $this, $options);

        return $this;
    }
1339805
protected function mergeModuleTranslations($langcode = null)
    {
        $modules = $this->module->getEnabled();

        // Sort modules in descending order
        // More important modules go first so their translations will be added earlier
        gplcart_array_sort($modules, 'weight', false);

        foreach ($modules as $module) {
            $file = $this->getFile($langcode, $module['module_id']);
            if (is_file($file)) {
                $this->mergeTranslation($file, $langcode);
            }
        }
    }
1204026
def append_translated(model, fields):
    ""
    fields = set(fields)
    from modeltranslation.translator import translator
    opts = translator.get_options_for_model(model)
    for key, translated in opts.fields.items():
        if key in fields:
            fields = fields.union(f.name for f in translated)
    return fields
1074088
function indexTranslations() {
  const { translations = {} } = getComponentsSettings();

  return index({
    file: 'translations.js',
    config: {
      type: TYPE_TRANSLATIONS,
      config: translations,
    },
    defaultContent: 'export default null;\n',
    ...getIndexLogTranslations(TYPE_TRANSLATIONS),
  });
}
158106
def localizable_duplicate_entries
      localizable_files = (git.modified_files + git.added_files) - git.deleted_files
      localizable_files.select! { |line| line.end_with?('.strings') }

      duplicate_entries = []

      localizable_files.each do |file|
        lines = File.readlines(file)

        # Grab just the keys, translations might be different
        keys = lines.map { |e| e.split('=').first }
        # Filter newlines and comments
        keys = keys.select do |e|
          e != "\n" && !e.start_with?('/*') && !e.start_with?('//')
        end

        # Grab keys that appear more than once
        duplicate_keys = keys.select { |e| keys.rindex(e) != keys.index(e) }
        # And make sure we have one entry per duplicate key
        duplicate_keys = duplicate_keys.uniq

        duplicate_keys.each do |key|
          duplicate_entries << { 'file' => file, 'key' => key }
        end
      end

      duplicate_entries
    end
296793
def register_languages():
    """"""
    for language in set(SUPPORTED_LANGUAGES) - {"en"}:
        language_stemmer = partial(nltk_stemmer, get_language_stemmer(language))
        Pipeline.register_function(language_stemmer, "stemmer-{}".format(language))
229932
function ADD_LOCALE(state, payload) {
      // reduce the given translations to a single-depth tree
      var translations = flattenTranslations(payload.translations);

      if (state.translations.hasOwnProperty(payload.locale)) {
        // get the existing translations
        var existingTranslations = state.translations[payload.locale]; // merge the translations

        state.translations[payload.locale] = Object.assign({}, existingTranslations, translations);
      } else {
        // just set the locale if it does not yet exist
        state.translations[payload.locale] = translations;
      } // make sure to notify vue of changes (this might break with new vue versions)


      try {
        if (state.translations.__ob__) {
          state.translations.__ob__.dep.notify();
        }
      } catch (ex) {}
    }