diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 05ea1037924435a9769cf2afc30c0da79182d85e..c5add1d21b0539b287a2b4d63ef91336cbd0dff5 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 7a3ee6acdf16e49d1f7243d3793401abb972fe7f..a2b7677283264d0917c6b928d9b4df5262b3e222 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -37,54 +37,6 @@ function locale_translation_manual_status() { return new RedirectResponse(\Drupal::url('locale.translate_status', array(), array('absolute' => TRUE))); } -/** - * 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']) . '
' . drupal_render($string['original_plural']); - } - else { - $source = drupal_render($string['original']); - } - $source .= empty($string['context']) ? '' : '
' . t('In Context') . ': ' . $string['context']['#value'] . ''; - $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. * diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php index a14983c77d7d68d72fc140f3a0ce96d91079cf48..fc7126347f07c0fd2790fac809827d8005ba7327 100644 --- a/core/modules/locale/src/Form/TranslateEditForm.php +++ b/core/modules/locale/src/Form/TranslateEditForm.php @@ -44,10 +44,15 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); $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 @@ public function buildForm(array $form, FormStateInterface $form_state) { $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 @@ public function buildForm(array $form, FormStateInterface $form_state) { } 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' => '' . String::checkPlain($source_array[0]) . '', '#prefix' => '' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '', - ); - $form['strings'][$string->lid]['original_plural'] = array( + ]; + $original_plural = [ '#type' => 'item', '#title' => $this->t('Plural form'), '#markup' => '' . String::checkPlain($source_array[1]) . '', - ); + ]; + $form['strings'][$string->lid]['original'] = [ + $original_singular, + ['#markup' => '
'], + $original_plural, + ]; } if (!empty($string->context)) { - $form['strings'][$string->lid]['context'] = array( - '#type' => 'value', - '#value' => '' . String::checkPlain($string->context) . '', - ); + $form['strings'][$string->lid]['original'][] = [ + '#type' => 'inline_template', + '#template' => '
{{ context_title }}: {{ context }}', + '#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 @@ public function buildForm(array $form, FormStateInterface $form_state) { ); } } + $form['pager']['#theme'] = 'pager'; return $form; }