Commit 49cf73e0 authored by catch's avatar catch
Browse files

fix: #3609087 \Drupal\locale\LocaleProjectRepository::buildProjects() does not...

fix: #3609087 \Drupal\locale\LocaleProjectRepository::buildProjects() does not respect weight in 11.4.x

By: alexpott
By: nicxvan
(cherry picked from commit 38d6cd53)
parent d4fe6da2
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -164,6 +164,7 @@ public function buildProjects(): array {
        // gettext file. Use the default if not.
        server_pattern: !empty($data['info']['interface translation server pattern']) ? $data['info']['interface translation server pattern'] : $pattern,
        info: $data['info'] ?? [],
        weight: $data['weight'] ?? 0,
        status: TRUE,
      );

+3 −0
Original line number Diff line number Diff line
@@ -153,6 +153,9 @@ public function localeTranslationProjectsAlter(&$projects): void {
        ],
      ];
    }
    if (\Drupal::state()->get('locale.test_projects_alter.weight')) {
      $projects['locale_test']['weight'] = 100;
    }
  }

  /**
+5 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ public function testBuildProjects(): void {
    $projects = \Drupal::service(LocaleProjectRepository::class)->buildProjects();
    $this->assertSame('locale_test', $projects['locale_test']->name);
    $this->assertSame('all', $projects['locale_test']->core);
    $this->assertSame(0, $projects['locale_test']->getWeight());

    $projects['locale_test']->setLangcode('de');
    $this->assertSame('/all/locale_test/locale_test-1.2.de.po', \Drupal::service(LocaleSource::class)->buildServerPattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));
@@ -64,6 +65,10 @@ public function testBuildProjects(): void {

    $projects['locale_test']->setLangcode('de');
    $this->assertSame('/all/locale_test/locale_test-1.2.de.po', \Drupal::service(LocaleSource::class)->buildServerPattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));

    \Drupal::state()->set('locale.test_projects_alter.weight', TRUE);
    $projects = \Drupal::service(LocaleProjectRepository::class)->buildProjects();
    $this->assertSame(100, $projects['locale_test']->getWeight());
  }

  /**