diff --git a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php
index f2b5f8c..6e09dcd 100644
--- a/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php
+++ b/lib/Drupal/config_translation/Form/ConfigTranslationManageForm.php
@@ -130,6 +130,16 @@ class ConfigTranslationManageForm implements FormInterface {
*/
protected function buildConfigForm($schema, $config, $base_config, $collapsed = FALSE, $base_key = '') {
$build = array();
+ // Try to load the langcode from the configuration, for some configurations
+ // this is not possible, so it will be english.
+ if ($source_language = language_load($this->group->getConfigGroup()->getLangcode())) {
+ $source_language_code = $source_language->langcode;
+ $source_language_name = $source_language->name;
+ }
+ else {
+ $source_language_code = 'en';
+ $source_language_name = t('Built-in English');
+ }
foreach ($schema as $key => $element) {
$element_key = implode('.', array_filter(array($base_key, $key)));
$definition = $element->getDefinition() + array('label' => t('N/A'));
@@ -138,9 +148,16 @@ class ConfigTranslationManageForm implements FormInterface {
// if there are any translatable elements there.
$sub_build = $this->buildConfigForm($element, $config[$key], $base_config[$key], TRUE, $element_key);
if (!empty($sub_build)) {
+ $title = ' ';
+ foreach (array_keys($sub_build) as $key) {
+ if (strpos($key, 'title') !== FALSE) {
+ $title .= strip_tags($sub_build[$key]['source']['#markup']);
+ break;
+ }
+ }
$build[$key] = array(
'#type' => 'details',
- '#title' => t($definition['label']),
+ '#title' => t($definition['label']) . $title,
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
) + $sub_build;
@@ -164,8 +181,8 @@ class ConfigTranslationManageForm implements FormInterface {
'#theme' => 'config_translation_manage_form_element',
);
$build[$element_key]['source'] = array(
- '#markup' => nl2br($base_config[$key]) ?: t('(Empty)'),
- '#title' => t($definition['label']),
+ '#markup' => $base_config[$key] ? ('' . nl2br($base_config[$key] . '')) : t('(Empty)'),
+ '#title' => t($definition['label']) . ' ('. $source_language_name . ')',
'#type' => 'item',
);
$rows_words = ceil(str_word_count($value) / 5);
@@ -174,8 +191,9 @@ class ConfigTranslationManageForm implements FormInterface {
$build[$element_key]['translation'] = array(
'#type' => $type,
'#default_value' => $value,
- '#title' => t($definition['label']),
+ '#title' => t($definition['label']) . ' (' . $this->language->name . ')',
'#rows' => $rows,
+ '#attributes' => array('lang' => $this->language->langcode),
);
}
}