function WebTestBase::writeCustomTranslations

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);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.