protected function LocaleUpdateBase::assertTranslation in Drupal 8
Same name and namespace in other branches
- 9 core/modules/locale/tests/src/Functional/LocaleUpdateBase.php \Drupal\Tests\locale\Functional\LocaleUpdateBase::assertTranslation()
Checks the translation of a string.
Parameters
string $source: Translation source string.
string $translation: Translation to check. Use empty string to check for a not existing translation.
string $langcode: Language code of the language to translate to.
string $message: (optional) A message to display with the assertion.
3 calls to LocaleUpdateBase::assertTranslation()
- LocaleUpdateTest::testEnableLanguage in core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateTest.php - Tests automatic translation import when a language is added.
- LocaleUpdateTest::testEnableUninstallModule in core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateTest.php - Tests automatic translation import when a module is enabled.
- LocaleUpdateTest::testUpdateImportModeNone in core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateTest.php - Tests translation import and don't overwrite any translation.
File
- core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateBase.php, line 303
Class
- LocaleUpdateBase
- Base class for testing updates to string translations.
Namespace
Drupal\Tests\locale\FunctionalCode
protected function assertTranslation($source, $translation, $langcode, $message = '') {
$query = Database::getConnection()
->select('locales_target', 'lt');
$query
->innerJoin('locales_source', 'ls', 'ls.lid = lt.lid');
$db_translation = $query
->fields('lt', [
'translation',
])
->condition('ls.source', $source)
->condition('lt.language', $langcode)
->execute()
->fetchField();
$db_translation = $db_translation == FALSE ? '' : $db_translation;
$this
->assertEqual($translation, $db_translation, $message ? $message : new FormattableMarkup('Correct translation of %source (%language)', [
'%source' => $source,
'%language' => $langcode,
]));
}