diff --git a/core/modules/locale/locale.css b/core/modules/locale/locale.css index 87f6941..09ddcc6 100644 --- a/core/modules/locale/locale.css +++ b/core/modules/locale/locale.css @@ -29,3 +29,6 @@ vertical-align: top } +#locale-translate-edit-form tr.changed { + background: #FFB; +} diff --git a/core/modules/locale/locale.js b/core/modules/locale/locale.js new file mode 100644 index 0000000..15a9760 --- /dev/null +++ b/core/modules/locale/locale.js @@ -0,0 +1,39 @@ +(function ($) { + +"use strict"; + +/** + * Markes changes of translations + */ +Drupal.behaviors.localetranslatedirty = { + attach: function (context, settings) { + $("#edit-strings textarea").change(function(){ + // Marking the row. + $(this).parents("tr") + .addClass('changed') + .each(function() { + var marker = Drupal.theme('localeTranslateChangedMarker'); + var cell = $(this).find('td:first div.form-item'); + if (cell.find('abbr.tabledrag-changed').length == 0) { + cell.append(marker); + } + }); + // Help text on top of table. + if (!$(this).parents("table").hasClass("changed")) { + $(this).parents("table") + .addClass("changed") + .before($(Drupal.theme('localeTranslateChangedWarning')).hide().fadeIn('slow')); + } + }); + } +}; + +Drupal.theme.prototype.localeTranslateChangedMarker = function () { + return '*'; +}; + +Drupal.theme.prototype.localeTranslateChangedWarning = function () { + return '
' + Drupal.theme('localeTranslateChangedMarker') + ' ' + Drupal.t('Changes made in this table will not be saved until the form is submitted.') + '
'; +}; + +})(jQuery); diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index ab2b67f..91e1308 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -13,7 +13,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; function locale_translate_screen() { // Add CSS. drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css'); - + drupal_add_js(drupal_get_path('module', 'locale') . '/locale.js'); return array( 'filter' => drupal_get_form('locale_translate_filter_form'), 'form' => drupal_get_form('locale_translate_edit_form'), @@ -29,7 +29,7 @@ function locale_translate_query() { $sql_query = db_select('locales_source', 's'); // Language is sanitized to be one of the possible options in // locale_translate_filter_values(). - $sql_query->leftJoin('locales_target', 't', "t.lid = s.lid AND t.language = '" . $filter_values['langcode'] . "'"); + $sql_query->leftJoin('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", array(':langcode' => $filter_values['langcode'])); $sql_query->fields('s', array('source', 'location', 'context', 'lid')); $sql_query->fields('t', array('translation', 'language', 'customized')); @@ -232,6 +232,8 @@ function locale_translate_filter_form_submit($form, &$form_state) { function locale_translate_edit_form($form, &$form_state) { $filter_values = locale_translate_filter_values(); $langcode = $filter_values['langcode']; + drupal_static_reset('language_list'); + $languages = language_list(); $form['langcode'] = array( '#type' => 'value', @@ -241,6 +243,7 @@ function locale_translate_edit_form($form, &$form_state) { $form['strings'] = array( '#type' => 'item', '#tree' => TRUE, + '#language' => $languages[$filter_values['langcode']]->name, '#theme' => 'locale_translate_edit_form_strings', ); @@ -299,6 +302,7 @@ 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 text'), '#title_display' => 'invisible', '#rows' => $rows, '#default_value' => $translation_array[0], @@ -421,9 +425,9 @@ function locale_translate_edit_form_submit($form, &$form_state) { */ function theme_locale_translate_edit_form_strings($variables) { $output = ''; - $header = array(t('Source string'), t('Translation')); - $rows = array(); $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']) {