public function LocaleImportFunctionalTest::testLanguageContext in Drupal 8
Same name and namespace in other branches
- 9 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testLanguageContext()
- 10 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testLanguageContext()
Test msgctxt context support.
File
- core/
modules/ locale/ tests/ src/ Functional/ LocaleImportFunctionalTest.php, line 255
Class
- LocaleImportFunctionalTest
- Tests the import of locale files.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testLanguageContext() {
// Try importing a .po file.
$this
->importPoFile($this
->getPoFileWithContext(), [
'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', [], [
'langcode' => 'hr',
'context' => 'Long month name',
]), 'Svibanj', 'Long month name context is working.');
$this
->assertIdentical((string) t('May', [], [
'langcode' => 'hr',
]), 'Svi.', 'Default context is working.');
}