You are here

protected function BambooTwigI18nTest::setUpTranslations in Bamboo Twig 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/BambooTwigI18nTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigI18nTest::setUpTranslations()
  2. 8.3 tests/src/Functional/BambooTwigI18nTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigI18nTest::setUpTranslations()

Sets up translations strings needed for test.

1 call to BambooTwigI18nTest::setUpTranslations()
BambooTwigI18nTest::setUp in tests/src/Functional/BambooTwigI18nTest.php

File

tests/src/Functional/BambooTwigI18nTest.php, line 41

Class

BambooTwigI18nTest
Tests I18n twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

protected function setUpTranslations() {

  /** @var \Drupal\locale\StringStorageInterface $localStorage */
  $localStorage = $this->container
    ->get('locale.storage');
  $thursday = $localStorage
    ->createString([
    'source' => 'Thursday',
  ]);
  $thursday
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $thursday->lid,
    'language' => 'fr',
    'translation' => 'Jeudi',
  ])
    ->save();
  $thu = $localStorage
    ->createString([
    'source' => 'Thu',
  ]);
  $thu
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $thu->lid,
    'language' => 'fr',
    'translation' => 'Jeu',
  ])
    ->save();
  $july = $localStorage
    ->createString([
    'source' => 'July',
    'context' => 'Long month name',
  ]);
  $july
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $july->lid,
    'language' => 'fr',
    'translation' => 'Juillet',
  ])
    ->save();
}