function locale_config_update_multiple

Updates all configuration for names / languages.

Parameters

array $names: Array of names of configuration objects to update.

array $langcodes: (optional) Array of language codes to update. Defaults to all languages.

Return value

int Number of configuration objects retranslated.

3 calls to locale_config_update_multiple()
locale_config_batch_refresh_name in drupal/core/modules/locale/locale.bulk.inc
Performs configuration translation refresh as a batch step.
locale_translate_batch_refresh in drupal/core/modules/locale/locale.bulk.inc
Refreshs translations after importing strings.
_locale_refresh_configuration in drupal/core/modules/locale/locale.module
Refreshes configuration after string translations have been updated.

File

drupal/core/modules/locale/locale.bulk.inc, line 862
Mass import-export and batch import functionality for Gettext .po files.

Code

function locale_config_update_multiple(array $names, $langcodes = array()) {
  $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
  $count = 0;
  foreach ($names as $name) {
    $wrapper = \Drupal\locale\Locale::config()
      ->get($name);
    foreach ($langcodes as $langcode) {
      $translation = $wrapper
        ->getValue() ? $wrapper
        ->getTranslation($langcode)
        ->getValue() : NULL;
      if ($translation) {
        \Drupal\locale\Locale::config()
          ->saveTranslationData($name, $langcode, $translation);
        $count++;
      }
      else {
        \Drupal\locale\Locale::config()
          ->deleteTranslationData($name, $langcode);
      }
    }
  }
  return $count;
}