You are here

protected function BambooTwigExtensionsI18nTest::setUpTranslations in Bamboo Twig 8.3

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

Sets up translations strings needed for test.

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

File

tests/src/Functional/BambooTwigExtensionsI18nTest.php, line 53

Class

BambooTwigExtensionsI18nTest
Tests Extensions i18n of 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');

  // Second/Seconds.
  $second = $localStorage
    ->createString([
    'source' => 'second',
    'context' => 'Time difference unit',
  ]);
  $second
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $second->lid,
    'language' => 'fr',
    'translation' => 'seconde',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $second->lid,
    'language' => 'de',
    'translation' => 'Sekunde',
  ])
    ->save();
  $seconds = $localStorage
    ->createString([
    'source' => 'seconds',
    'context' => 'Time difference unit',
  ]);
  $seconds
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $seconds->lid,
    'language' => 'fr',
    'translation' => 'secondes',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $seconds->lid,
    'language' => 'de',
    'translation' => 'Sekunden',
  ])
    ->save();

  // Minute/Minutes.
  $minute = $localStorage
    ->createString([
    'source' => 'minute',
    'context' => 'Time difference unit',
  ]);
  $minute
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $minute->lid,
    'language' => 'fr',
    'translation' => 'minute',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $minute->lid,
    'language' => 'de',
    'translation' => 'Minute',
  ])
    ->save();
  $minutes = $localStorage
    ->createString([
    'source' => 'minutes',
    'context' => 'Time difference unit',
  ]);
  $minutes
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $minutes->lid,
    'language' => 'fr',
    'translation' => 'minutes',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $minutes->lid,
    'language' => 'de',
    'translation' => 'Minuten',
  ])
    ->save();

  // Hour/Hours.
  $hour = $localStorage
    ->createString([
    'source' => 'hour',
    'context' => 'Time difference unit',
  ]);
  $hour
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $hour->lid,
    'language' => 'fr',
    'translation' => 'heure',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $hour->lid,
    'language' => 'de',
    'translation' => 'Stunde',
  ])
    ->save();
  $hours = $localStorage
    ->createString([
    'source' => 'hours',
    'context' => 'Time difference unit',
  ]);
  $hours
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $hours->lid,
    'language' => 'fr',
    'translation' => 'heures',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $hours->lid,
    'language' => 'de',
    'translation' => 'Stunden',
  ])
    ->save();

  // Day & Days.
  $day = $localStorage
    ->createString([
    'source' => 'day',
    'context' => 'Time difference unit',
  ]);
  $day
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $day->lid,
    'language' => 'fr',
    'translation' => 'jour',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $day->lid,
    'language' => 'de',
    'translation' => 'Tag',
  ])
    ->save();
  $days = $localStorage
    ->createString([
    'source' => 'days',
    'context' => 'Time difference unit',
  ]);
  $days
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $days->lid,
    'language' => 'fr',
    'translation' => 'jours',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $days->lid,
    'language' => 'de',
    'translation' => 'Tagen',
  ])
    ->save();

  // Month/Months.
  $month = $localStorage
    ->createString([
    'source' => 'month',
    'context' => 'Time difference unit',
  ]);
  $month
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $month->lid,
    'language' => 'fr',
    'translation' => 'mois',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $month->lid,
    'language' => 'de',
    'translation' => 'Monat',
  ])
    ->save();
  $months = $localStorage
    ->createString([
    'source' => 'months',
    'context' => 'Time difference unit',
  ]);
  $months
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $months->lid,
    'language' => 'fr',
    'translation' => 'mois',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $months->lid,
    'language' => 'de',
    'translation' => 'Monaten',
  ])
    ->save();

  // Year/Years.
  $year = $localStorage
    ->createString([
    'source' => 'year',
    'context' => 'Time difference unit',
  ]);
  $year
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $year->lid,
    'language' => 'fr',
    'translation' => 'an',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $year->lid,
    'language' => 'de',
    'translation' => 'Jahr',
  ])
    ->save();
  $years = $localStorage
    ->createString([
    'source' => 'years',
    'context' => 'Time difference unit',
  ]);
  $years
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $years->lid,
    'language' => 'fr',
    'translation' => 'ans',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $years->lid,
    'language' => 'de',
    'translation' => 'Jahren',
  ])
    ->save();

  // Durations & Unit - Futur.
  $in_duration_unit = $localStorage
    ->createString([
    'source' => 'in @duration @unit' . PluralTranslatableMarkup::DELIMITER . 'in @duration @units',
    'context' => 'Time difference',
  ]);
  $in_duration_unit
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $in_duration_unit->lid,
    'language' => 'fr',
    'translation' => 'dans @duration @unit' . PluralTranslatableMarkup::DELIMITER . 'dans @duration @units',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $in_duration_unit->lid,
    'language' => 'de',
    'translation' => 'in @duration @unit' . PluralTranslatableMarkup::DELIMITER . 'in @duration @units',
  ])
    ->save();

  // Durations & Unit - Past.
  $duration_unit_ago = $localStorage
    ->createString([
    'source' => '@duration @unit ago' . PluralTranslatableMarkup::DELIMITER . '@duration @units ago',
    'context' => 'Time difference',
  ]);
  $duration_unit_ago
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $duration_unit_ago->lid,
    'language' => 'fr',
    'translation' => 'il y a @duration @unit' . PluralTranslatableMarkup::DELIMITER . 'il y a @duration @units',
  ])
    ->save();
  $this->translationsStrings[] = $localStorage
    ->createTranslation([
    'lid' => $duration_unit_ago->lid,
    'language' => 'de',
    'translation' => 'vor @duration @unit' . PluralTranslatableMarkup::DELIMITER . 'vor @duration @units',
  ])
    ->save();
}