protected function LocaleStringTest::createTranslation in Drupal 9
Same name and namespace in other branches
- 8 core/modules/locale/tests/src/Kernel/LocaleStringTest.php \Drupal\Tests\locale\Kernel\LocaleStringTest::createTranslation()
Creates single translation for source string.
Parameters
\Drupal\locale\StringInterface $source: The source string.
string $langcode: The language code.
array $values: The values array.
Return value
\Drupal\locale\StringInterface The translated string object.
2 calls to LocaleStringTest::createTranslation()
- LocaleStringTest::createAllTranslations in core/
modules/ locale/ tests/ src/ Kernel/ LocaleStringTest.php - Creates translations for source string and all languages.
- LocaleStringTest::testStringCrudApi in core/
modules/ locale/ tests/ src/ Kernel/ LocaleStringTest.php - Tests CRUD API.
File
- core/
modules/ locale/ tests/ src/ Kernel/ LocaleStringTest.php, line 235
Class
- LocaleStringTest
- Tests the locale string storage, string objects and data API.
Namespace
Drupal\Tests\locale\KernelCode
protected function createTranslation(StringInterface $source, $langcode, array $values = []) {
return $this->storage
->createTranslation($values + [
'lid' => $source->lid,
'language' => $langcode,
'translation' => $this
->randomMachineName(100),
])
->save();
}