function LocaleStringTest::createTranslation
Same name in other branches
- 9 core/modules/locale/tests/src/Kernel/LocaleStringTest.php \Drupal\Tests\locale\Kernel\LocaleStringTest::createTranslation()
- 10 core/modules/locale/tests/src/Kernel/LocaleStringTest.php \Drupal\Tests\locale\Kernel\LocaleStringTest::createTranslation()
- 11.x 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 - Test CRUD API.
File
-
core/
modules/ locale/ tests/ src/ Kernel/ LocaleStringTest.php, line 229
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.