function LocaleImportFunctionalTest::testLanguageContext
Same name in other branches
- 7.x modules/locale/locale.test \LocaleImportFunctionalTest::testLanguageContext()
- 9 core/modules/locale/tests/src/Functional/LocaleImportFunctionalTest.php \Drupal\Tests\locale\Functional\LocaleImportFunctionalTest::testLanguageContext()
- 8.9.x 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()
Tests msgctxt context support.
File
-
core/
modules/ locale/ tests/ src/ Functional/ LocaleImportFunctionalTest.php, line 261
Class
- LocaleImportFunctionalTest
- Tests the import of locale files.
Namespace
Drupal\Tests\locale\FunctionalCode
public function testLanguageContext() : void {
// 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->assertSame('Svibanj', (string) t('May', [], [
'langcode' => 'hr',
'context' => 'Long month name',
]), 'Long month name context is working.');
$this->assertSame('Svi.', (string) t('May', [], [
'langcode' => 'hr',
]), 'Default context is working.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.