You are here

public function LocaleImportFunctionalTest::testLanguageContext in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/locale/src/Tests/LocaleImportFunctionalTest.php \Drupal\locale\Tests\LocaleImportFunctionalTest::testLanguageContext()

Test msgctxt context support.

File

core/modules/locale/src/Tests/LocaleImportFunctionalTest.php, line 235
Contains \Drupal\locale\Tests\LocaleImportFunctionalTest.

Class

LocaleImportFunctionalTest
Tests the import of locale files.

Namespace

Drupal\locale\Tests

Code

public function testLanguageContext() {

  // Try importing a .po file.
  $this
    ->importPoFile($this
    ->getPoFileWithContext(), array(
    'langcode' => 'hr',
  ));

  // We cast the return value of t() to string so as to retrieve the
  // translated value, rendered as a string.
  $this
    ->assertIdentical((string) t('May', array(), array(
    'langcode' => 'hr',
    'context' => 'Long month name',
  )), 'Svibanj', 'Long month name context is working.');
  $this
    ->assertIdentical((string) t('May', array(), array(
    'langcode' => 'hr',
  )), 'Svi.', 'Default context is working.');
}