You are here

protected function WebTestBase::addCustomTranslations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::addCustomTranslations()

Queues custom translations to be written to settings.php.

Use WebTestBase::writeCustomTranslations() to apply and write the queued translations.

Parameters

string $langcode: The langcode to add translations for.

array $values: Array of values containing the untranslated string and its translation. For example:

array(
  '' => array(
    'Sunday' => 'domingo',
  ),
  'Long month name' => array(
    'March' => 'marzo',
  ),
);

Pass an empty array to remove all existing custom translations for the given $langcode.

1 call to WebTestBase::addCustomTranslations()
PageTitleTest::testRoutingTitle in core/modules/system/src/Tests/System/PageTitleTest.php
Tests the page title of render arrays.

File

core/modules/simpletest/src/WebTestBase.php, line 1115
Contains \Drupal\simpletest\WebTestBase.

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function addCustomTranslations($langcode, array $values) {

  // If $values is empty, then the test expects all custom translations to be
  // cleared.
  if (empty($values)) {
    $this->customTranslations[$langcode] = array();
  }
  else {
    foreach ($values as $context => $translations) {
      foreach ($translations as $original => $translation) {
        $this->customTranslations[$langcode][$context][$original] = $translation;
      }
    }
  }
}