Commit 201ea5ba authored by webchick's avatar webchick

Issue #3016471 by Gábor Hojtsy, drumm, tedbow: Make localization file download...

Issue #3016471 by Gábor Hojtsy, drumm, tedbow: Make localization file download major version agnostic

(cherry picked from commit d3d71807)
parent 9f8bf98f
......@@ -1939,7 +1939,7 @@ function install_check_translations($langcode, $server_pattern) {
$variables = [
'%project' => 'drupal',
'%version' => $version,
'%core' => \Drupal::CORE_COMPATIBILITY,
'%core' => 'all',
'%language' => $langcode,
];
$translation_url = strtr($server_pattern, $variables);
......
......@@ -69,7 +69,7 @@ function locale_translation_build_projects() {
$data += [
'name' => $name,
'version' => isset($data['info']['version']) ? $data['info']['version'] : '',
'core' => \Drupal::CORE_COMPATIBILITY,
'core' => 'all',
// A project can provide the path and filename pattern to download the
// gettext file. Use the default if not.
'server_pattern' => isset($data['info']['interface translation server pattern']) && $data['info']['interface translation server pattern'] ? $data['info']['interface translation server pattern'] : $default_server['pattern'],
......
......@@ -328,3 +328,10 @@ function locale_update_8500() {
->save();
}
}
/**
* Clear Locale project storage to use new 'all' instead of 8.x in URLs.
*/
function locale_update_8800() {
\Drupal::service('locale.project')->deleteAll();
}
......@@ -49,7 +49,7 @@ public function testUpdateImportSourceRemote() {
], $this->translationsStream);
$url = \Drupal::service('url_generator')->generateFromRoute('<front>', [], ['absolute' => TRUE]);
$uri = $url . PublicStream::basePath() . '/remote/8.x/contrib_module_one/contrib_module_one-8.x-1.1.de._po';
$uri = $url . PublicStream::basePath() . '/remote/all/contrib_module_one/contrib_module_one-8.x-1.1.de._po';
$source_file = (object) [
'uri' => $uri,
];
......
......@@ -194,9 +194,9 @@ protected function setTranslationFiles() {
// Add a number of files to the local file system to serve as remote
// translation server and match the project definitions set in
// locale_test_locale_translation_projects_alter().
$this->makePoFile('remote/8.x/contrib_module_one', 'contrib_module_one-8.x-1.1.de._po', $this->timestampNew, $translations_one);
$this->makePoFile('remote/8.x/contrib_module_two', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestampOld, $translations_two);
$this->makePoFile('remote/8.x/contrib_module_three', 'contrib_module_three-8.x-1.0.de._po', $this->timestampOld, $translations_three);
$this->makePoFile('remote/all/contrib_module_one', 'contrib_module_one-8.x-1.1.de._po', $this->timestampNew, $translations_one);
$this->makePoFile('remote/all/contrib_module_two', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestampOld, $translations_two);
$this->makePoFile('remote/all/contrib_module_three', 'contrib_module_three-8.x-1.0.de._po', $this->timestampOld, $translations_three);
// Add a number of files to the local file system to serve as local
// translation files and match the project definitions set in
......
......@@ -36,10 +36,10 @@ public function testBuildProjects() {
// Confirm the project name and core value before the module is altered.
$projects = locale_translation_build_projects();
$this->assertSame('locale_test', $projects['locale_test']->name);
$this->assertSame('8.x', $projects['locale_test']->core);
$this->assertSame('all', $projects['locale_test']->core);
$projects['locale_test']->langcode = 'de';
$this->assertSame('/8.x/locale_test/locale_test-1.2.de.po', locale_translation_build_server_pattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));
$this->assertSame('/all/locale_test/locale_test-1.2.de.po', locale_translation_build_server_pattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));
// Alter both the name and core value of the project.
\Drupal::state()->set('locale.test_system_info_alter_name_core', TRUE);
......@@ -55,10 +55,10 @@ public function testBuildProjects() {
// Confirm the name and core value are not changed in the project.
$projects = locale_translation_build_projects();
$this->assertSame('locale_test', $projects['locale_test']->name);
$this->assertSame('8.x', $projects['locale_test']->core);
$this->assertSame('all', $projects['locale_test']->core);
$projects['locale_test']->langcode = 'de';
$this->assertSame('/8.x/locale_test/locale_test-1.2.de.po', locale_translation_build_server_pattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));
$this->assertSame('/all/locale_test/locale_test-1.2.de.po', locale_translation_build_server_pattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment