You are here

protected function WebTestBase::writeCustomTranslations in Drupal 8

Writes custom translations to the test site's settings.php.

Use TestBase::addCustomTranslations() to queue custom translations before calling this method.

File

core/modules/simpletest/src/WebTestBase.php, line 477

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function writeCustomTranslations() {
  $settings = [];
  foreach ($this->customTranslations as $langcode => $values) {
    $settings_key = 'locale_custom_strings_' . $langcode;

    // Update in-memory settings directly.
    $this
      ->settingsSet($settings_key, $values);
    $settings['settings'][$settings_key] = (object) [
      'value' => $values,
      'required' => TRUE,
    ];
  }

  // Only rewrite settings if there are any translation changes to write.
  if (!empty($settings)) {
    $this
      ->writeSettings($settings);
  }
}