protected function ConfigTranslationUiTest::getTranslation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php \Drupal\config_translation\Tests\ConfigTranslationUiTest::getTranslation()
Gets translation from locale storage.
Parameters
$config_name: Configuration object.
$key: Translation configuration field key.
$langcode: String language code to load translation.
Return value
bool|mixed Returns translation if exists, FALSE otherwise.
1 call to ConfigTranslationUiTest::getTranslation()
- ConfigTranslationUiTest::testLocaleDBStorage in core/
modules/ config_translation/ src/ Tests/ ConfigTranslationUiTest.php - Test translation storage in locale storage.
File
- core/
modules/ config_translation/ src/ Tests/ ConfigTranslationUiTest.php, line 979 - Contains \Drupal\config_translation\Tests\ConfigTranslationUiTest.
Class
- ConfigTranslationUiTest
- Translate settings and entities to various languages.
Namespace
Drupal\config_translation\TestsCode
protected function getTranslation($config_name, $key, $langcode) {
$settings_locations = $this->localeStorage
->getLocations(array(
'type' => 'configuration',
'name' => $config_name,
));
$this
->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array(
'%config_name' => $config_name,
)));
if (!empty($settings_locations)) {
$source = $this->container
->get('config.factory')
->get($config_name)
->get($key);
$source_string = $this->localeStorage
->findString(array(
'source' => $source,
'type' => 'configuration',
));
$this
->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array(
'%config_name' => $config_name,
'%key' => $key,
)));
if (!empty($source_string)) {
$conditions = array(
'lid' => $source_string->lid,
'language' => $langcode,
);
$translations = $this->localeStorage
->getTranslations($conditions + array(
'translated' => TRUE,
));
return reset($translations);
}
}
return FALSE;
}