protected function LocaleUpdateBase::assertTranslation in Drupal 10
Same name and namespace in other branches
- 8 core/modules/locale/tests/src/Functional/LocaleUpdateBase.php \Drupal\Tests\locale\Functional\LocaleUpdateBase::assertTranslation()
- 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 non-existent translation.
string $langcode: Language code of the language to translate to.
string $message: (optional) A message to display with the assertion.
File
- core/
modules/ locale/ tests/ src/ Functional/ LocaleUpdateBase.php, line 304
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
->assertEquals($translation, $db_translation, $message ? $message : new FormattableMarkup('Correct translation of %source (%language)', [
'%source' => $source,
'%language' => $langcode,
]));
}