You are here

public function InterfaceTranslationTestController::content in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 4.0.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  2. 3.2.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  3. 3.3.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  4. 3.5.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  5. 3.6.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  6. 3.7.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
  7. 3.8.x tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php \Drupal\lingotek_interface_translation_test\Controller\InterfaceTranslationTestController::content()
1 string reference to 'InterfaceTranslationTestController::content'
lingotek_interface_translation_test.routing.yml in tests/modules/lingotek_interface_translation_test/lingotek_interface_translation_test.routing.yml
tests/modules/lingotek_interface_translation_test/lingotek_interface_translation_test.routing.yml

File

tests/modules/lingotek_interface_translation_test/src/Controller/InterfaceTranslationTestController.php, line 13

Class

InterfaceTranslationTestController

Namespace

Drupal\lingotek_interface_translation_test\Controller

Code

public function content(Request $request) {
  $build = [];

  // Context management.
  $build['context_test']['one context'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => $this
      ->t('This is test of context', [], [
      'context' => 'multiple p',
    ]),
  ];
  $build['context_test']['another context'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => $this
      ->t('This is test of context', [], [
      'context' => 'multiple t',
    ]),
  ];
  $build['context_test']['no context'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => $this
      ->t('This is test of context'),
  ];

  // Plurals management.
  $count = $request->query
    ->get('count') ?: 1;
  $build['plurals'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => $this
      ->formatPlural($count, 'This is a singular example', 'This is a plural @count example'),
    '#cache' => [
      'max-age' => 0,
    ],
  ];
  return $build;
}