Skip to content
Snippets Groups Projects
Commit c42156c8 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2311859 by Gábor Hojtsy, jhodgdon: Fixed Configuration and Javascript...

Issue #2311859 by Gábor Hojtsy, jhodgdon: Fixed Configuration and Javascript translation not created/updated in .po translation import.
parent b343c571
No related branches found
No related tags found
No related merge requests found
......@@ -298,7 +298,7 @@ function locale_translate_batch_refresh(array &$context) {
}
if ($strings) {
// Initialize multi-step string refresh.
$context['message'] = t('Updating translations for JavaScript and configuration strings.');
$context['message'] = t('Updating translations for JavaScript and default configuration.');
$context['sandbox']['refresh']['strings'] = array_unique($strings);
$context['sandbox']['refresh']['languages'] = $langcodes;
$context['sandbox']['refresh']['names'] = array();
......@@ -306,7 +306,7 @@ function locale_translate_batch_refresh(array &$context) {
$context['sandbox']['refresh']['count'] = count($strings);
// We will update strings on later steps.
$context['finished'] = 1 - 1 / $context['sandbox']['refresh']['count'];
$context['finished'] = 0;
}
else {
$context['finished'] = 1;
......@@ -316,6 +316,10 @@ function locale_translate_batch_refresh(array &$context) {
// Refresh all languages for one object at a time.
$count = locale_config_update_multiple(array($name), $context['sandbox']['refresh']['languages']);
$context['results']['stats']['config'] += $count;
// Inherit finished information from the "parent" string lookup step so
// visual display of status will make sense.
$context['finished'] = $context['sandbox']['refresh']['names_finished'];
$context['message'] = t('Updating default configuration (@percent%).', array('@percent' => (int) ($context['finished'] * 100)));
}
elseif (!empty($context['sandbox']['refresh']['strings'])) {
// Not perfect but will give some indication of progress.
......@@ -327,10 +331,12 @@ function locale_translate_batch_refresh(array &$context) {
_locale_refresh_translations($context['sandbox']['refresh']['languages'], $next);
// Check whether we need to refresh configuration objects.
if ($names = \Drupal\locale\Locale::config()->getStringNames($next)) {
$context['sandbox']['refresh']['names_finished'] = $context['finished'];
$context['sandbox']['refresh']['names'] = $names;
}
}
else {
$context['message'] = t('Updated default configuration.');
$context['finished'] = 1;
}
}
......
......@@ -293,14 +293,11 @@ public function testConfigPoFile() {
$this->assertText($config_string[1], format_string('Translation of @string found.', array('@string' => $config_string[0])));
}
$locale_config = $this->container->get('locale.config.typed');
// Translations got recorded in the config system.
// Test that translations got recorded in the config system.
$overrides = \Drupal::service('language.config_factory_override');
foreach ($config_strings as $config_key => $config_string) {
$wrapper = $locale_config->get($config_key);
$translation = $wrapper->getTranslation($langcode);
$properties = $translation->getProperties();
$this->assertEqual(count($properties), 1, 'Got the right number of properties with strict translation');
$this->assertEqual($properties[$config_string[2]]->getValue(), $config_string[1]);
$override = $overrides->getOverride($langcode, $config_key);
$this->assertEqual($override->get($config_string[2]), $config_string[1]);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment