function ComponentTranslationTest::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.
File
-
core/
tests/ Drupal/ KernelTests/ Components/ ComponentTranslationTest.php, line 147
Class
- ComponentTranslationTest
- Tests the component can be translated.
Namespace
Drupal\KernelTests\ComponentsCode
protected function createTranslation(StringInterface $source, $langcode, array $values = []) : StringInterface {
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.