summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-11-28 13:13:57 (GMT)
committerAlex Pott2014-11-28 13:13:57 (GMT)
commitd4e8abd840ca8bb0fb299ec85118193f7816d3fa (patch)
treec90973eda72f588fe3ab97fef9725367153c7f4f
parent23b70dfb16d60478ecaff9286804e65c1cc0c38f (diff)
Issue #1938916 by joelpittet, akalata, a-fro, duellj, InternetDevels, lauriii: Convert locale theme tables to table #type
-rw-r--r--core/modules/locale/locale.module5
-rw-r--r--core/modules/locale/locale.pages.inc48
-rw-r--r--core/modules/locale/src/Form/TranslateEditForm.php47
3 files changed, 28 insertions, 72 deletions
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 05ea103..c5add1d 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -180,11 +180,6 @@ function locale_help($route_name, RouteMatchInterface $route_match) {
*/
function locale_theme() {
return array(
- 'locale_translate_edit_form_strings' => array(
- 'render element' => 'form',
- 'file' => 'locale.pages.inc',
- 'function' => 'theme_locale_translate_edit_form_strings',
- ),
'locale_translation_last_check' => array(
'variables' => array('last' => NULL),
'file' => 'locale.pages.inc',
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 7a3ee6a..a2b7677 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -38,54 +38,6 @@ function locale_translation_manual_status() {
}
/**
- * Returns HTML for translation edit form.
- *
- * @param array $variables
- * An associative array containing:
- * - form: The form that contains the language information.
- *
- * @return string
- * The themed output.
- *
- * @see locale_translate_edit_form()
- * @ingroup themeable
- */
-function theme_locale_translate_edit_form_strings(array $variables) {
- $output = '';
- $form = $variables['form'];
- $header = array(
- t('Source string'),
- t('Translation for @language', array('@language' => $form['#language'])),
- );
- $rows = array();
- foreach (Element::children($form) as $lid) {
- $string = $form[$lid];
- if ($string['plural']['#value']) {
- $source = drupal_render($string['original_singular']) . '<br />' . drupal_render($string['original_plural']);
- }
- else {
- $source = drupal_render($string['original']);
- }
- $source .= empty($string['context']) ? '' : '<br /><small>' . t('In Context') . ':&nbsp;' . $string['context']['#value'] . '</small>';
- $rows[] = array(
- array('data' => SafeMarkup::set($source)),
- array('data' => $string['translations']),
- );
- }
- $table = array(
- '#type' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#empty' => t('No strings available.'),
- '#attributes' => array('class' => array('locale-translate-edit-table')),
- );
- $output .= drupal_render($table);
- $pager = array('#theme' => 'pager');
- $output .= drupal_render($pager);
- return $output;
-}
-
-/**
* Prepares variables for translation status information templates.
*
* Translation status information is displayed per language.
diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php
index a14983c..fc71263 100644
--- a/core/modules/locale/src/Form/TranslateEditForm.php
+++ b/core/modules/locale/src/Form/TranslateEditForm.php
@@ -44,10 +44,15 @@ class TranslateEditForm extends TranslateFormBase {
);
$form['strings'] = array(
- '#type' => 'item',
+ '#type' => 'table',
'#tree' => TRUE,
'#language' => $langname,
- '#theme' => 'locale_translate_edit_form_strings',
+ '#header' => [
+ $this->t('Source string'),
+ $this->t('Translation for @language', ['@language' => $langname]),
+ ],
+ '#empty' => $this->t('No strings available.'),
+ '#attributes' => ['class' => ['locale-translate-edit-table']],
);
if (isset($langcode)) {
@@ -63,10 +68,7 @@ class TranslateEditForm extends TranslateFormBase {
$translation_array = $string->getPlurals();
if (count($source_array) == 1) {
// Add original string value and mark as non-plural.
- $form['strings'][$string->lid]['plural'] = array(
- '#type' => 'value',
- '#value' => 0,
- );
+ $plural = FALSE;
$form['strings'][$string->lid]['original'] = array(
'#type' => 'item',
'#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
@@ -76,31 +78,37 @@ class TranslateEditForm extends TranslateFormBase {
}
else {
// Add original string value and mark as plural.
- $form['strings'][$string->lid]['plural'] = array(
- '#type' => 'value',
- '#value' => 1,
- );
- $form['strings'][$string->lid]['original_singular'] = array(
+ $plural = TRUE;
+ $original_singular = [
'#type' => 'item',
'#title' => $this->t('Singular form'),
'#markup' => '<span lang="en">' . String::checkPlain($source_array[0]) . '</span>',
'#prefix' => '<span class="visually-hidden">' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '</span>',
- );
- $form['strings'][$string->lid]['original_plural'] = array(
+ ];
+ $original_plural = [
'#type' => 'item',
'#title' => $this->t('Plural form'),
'#markup' => '<span lang="en">' . String::checkPlain($source_array[1]) . '</span>',
- );
+ ];
+ $form['strings'][$string->lid]['original'] = [
+ $original_singular,
+ ['#markup' => '<br>'],
+ $original_plural,
+ ];
}
if (!empty($string->context)) {
- $form['strings'][$string->lid]['context'] = array(
- '#type' => 'value',
- '#value' => '<span lang="en">' . String::checkPlain($string->context) . '</span>',
- );
+ $form['strings'][$string->lid]['original'][] = [
+ '#type' => 'inline_template',
+ '#template' => '<br><small>{{ context_title }}: <span lang="en">{{ context }}</span></small>',
+ '#context' => [
+ 'context_title' => $this->t('In Context'),
+ 'context' => $string->context,
+ ],
+ ];
}
// Approximate the number of rows to use in the default textarea.
$rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
- if (empty($form['strings'][$string->lid]['plural']['#value'])) {
+ if (!$plural) {
$form['strings'][$string->lid]['translations'][0] = array(
'#type' => 'textarea',
'#title' => $this->t('Translated string (@language)', array('@language' => $langname)),
@@ -153,6 +161,7 @@ class TranslateEditForm extends TranslateFormBase {
);
}
}
+ $form['pager']['#theme'] = 'pager';
return $form;
}