You are here

private function DisplayTest::addTranslation in Drupal 10

Helper function for adding interface text translations.

File

core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php, line 191

Class

DisplayTest
Tests the display UI.

Namespace

Drupal\Tests\views_ui\FunctionalJavascript

Code

private function addTranslation($langcode, $source_string, $translation_string) {
  $storage = \Drupal::service('locale.storage');
  $string = $storage
    ->findString([
    'source' => $source_string,
  ]);
  if (is_null($string)) {
    $string = new SourceString();
    $string
      ->setString($source_string)
      ->setStorage($storage)
      ->save();
  }
  $storage
    ->createTranslation([
    'lid' => $string
      ->getId(),
    'language' => $langcode,
    'translation' => $translation_string,
  ])
    ->save();
}