summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries2013-06-20 18:24:41 (GMT)
committerDries2013-06-20 18:24:41 (GMT)
commita72d1f1b0fdc0014a201860ba6b36d98f613232e (patch)
treedc141d2230b6b295ec6422451fc8203a07c53b4a
parent7a0c707eeb4afed6e743e4cef68bfb3dd2da1aa6 (diff)
Issue #2004684 by mgifford, Schnitzel: Improve Accessibility for String Translation UI.
-rw-r--r--core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php2
-rw-r--r--core/modules/locale/locale.pages.inc19
2 files changed, 14 insertions, 7 deletions
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
index 26769ff..d2f1579 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php
@@ -98,7 +98,7 @@ class LocaleTranslationUiTest extends WebTestBase {
);
// No t() here, it's surely not translated yet.
$this->assertText($name, t('name found on edit screen.'));
- $this->assertNoText('English', t('No way to translate the string to English.'));
+ $this->assertNoOption('edit-langcode', 'en', t('No way to translate the string to English.'));
$this->drupalLogout();
$this->drupalLogin($admin_user);
$this->drupalPost('admin/config/regional/language/edit/en', array('locale_translate_english' => TRUE), t('Save language'));
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 3400a3e..51a9e3a 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -297,9 +297,9 @@ function locale_translate_edit_form($form, &$form_state) {
);
$form['strings'][$string->lid]['original'] = array(
'#type' => 'item',
- '#title' => t('Source string'),
+ '#title' => t('Source string (@language)', array('@language' => t('Built-in English'))),
'#title_display' => 'invisible',
- '#markup' => check_plain($source_array[0]),
+ '#markup' => '<span lang="en">' . check_plain($source_array[0]) . '</span>',
);
}
else {
@@ -311,18 +311,19 @@ function locale_translate_edit_form($form, &$form_state) {
$form['strings'][$string->lid]['original_singular'] = array(
'#type' => 'item',
'#title' => t('Singular form'),
- '#markup' => check_plain($source_array[0]),
+ '#markup' => '<span lang="en">' . check_plain($source_array[0]) . '</span>',
+ '#prefix' => '<span class="visually-hidden">' . t('Source string (@language)', array('@language' => t('Built-in English'))) . '</span>',
);
$form['strings'][$string->lid]['original_plural'] = array(
'#type' => 'item',
'#title' => t('Plural form'),
- '#markup' => check_plain($source_array[1]),
+ '#markup' => '<span lang="en">' . check_plain($source_array[1]) . '</span>',
);
}
if (!empty($string->context)) {
$form['strings'][$string->lid]['context'] = array(
'#type' => 'value',
- '#value' => check_plain($string->context),
+ '#value' => '<span lang="en">' . check_plain($string->context) . '</span>',
);
}
// Approximate the number of rows to use in the default textarea.
@@ -330,10 +331,11 @@ function locale_translate_edit_form($form, &$form_state) {
if (empty($form['strings'][$string->lid]['plural']['#value'])) {
$form['strings'][$string->lid]['translations'][0] = array(
'#type' => 'textarea',
- '#title' => t('Translated string'),
+ '#title' => t('Translated string (@language)', array('@language' => $langname)),
'#title_display' => 'invisible',
'#rows' => $rows,
'#default_value' => $translation_array[0],
+ '#attributes' => array('lang' => $langcode),
);
}
else {
@@ -346,6 +348,8 @@ function locale_translate_edit_form($form, &$form_state) {
'#title' => ($i == 0 ? t('Singular form') : format_plural($i, 'First plural form', '@count. plural form')),
'#rows' => $rows,
'#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '',
+ '#attributes' => array('lang' => $langcode),
+ '#prefix' => $i == 0 ? ('<span class="visually-hidden">' . t('Translated string (@language)', array('@language' => $langname)) . '</span>') : '',
);
}
}
@@ -356,12 +360,15 @@ function locale_translate_edit_form($form, &$form_state) {
'#title' => t('Singular form'),
'#rows' => $rows,
'#default_value' => $translation_array[0],
+ '#attributes' => array('lang' => $langcode),
+ '#prefix' => '<span class="visually-hidden">' . t('Translated string (@language)', array('@language' => $langname)) . '</span>',
);
$form['strings'][$string->lid]['translations'][1] = array(
'#type' => 'textarea',
'#title' => t('Plural form'),
'#rows' => $rows,
'#default_value' => isset($translation_array[1]) ? $translation_array[1] : '',
+ '#attributes' => array('lang' => $langcode),
);
}
}