Updates all configuration for names / languages.
array $names: Array of names of configuration objects to update.
array $langcodes: (optional) Array of language codes to update. Defaults to all languages.
int Number of configuration objects retranslated.
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;
}