diff --git a/core/modules/locale/locale-rtl.css b/core/modules/locale/locale-rtl.css
index aaf1988..a2ec4c1 100644
--- a/core/modules/locale/locale-rtl.css
+++ b/core/modules/locale/locale-rtl.css
@@ -7,6 +7,6 @@
padding-right: 0;
}
#locale-translation-filter-form .form-actions {
- float: right;
- padding: 3ex 1em 0 0;
+ left: 0;
+ right: 41em;
}
diff --git a/core/modules/locale/locale.css b/core/modules/locale/locale.css
index 6c03945..fc2aa84 100644
--- a/core/modules/locale/locale.css
+++ b/core/modules/locale/locale.css
@@ -10,16 +10,28 @@
padding-right: .8em; /* LTR */
margin: 0.1em;
/**
- * In Opera 9, DOM elements with the property of "overflow: auto"
- * will partially hide its contents with unnecessary scrollbars when
- * its immediate child is floated without an explicit width set.
- */
+ * In Opera 9, DOM elements with the property of "overflow: auto"
+ * will partially hide its contents with unnecessary scrollbars when
+ * its immediate child is floated without an explicit width set.
+ */
width: 15em;
}
-#locale-translation-filter-form .form-type-select select {
- width: 100%;
+
+#locale-translation-filter-search-dropdowns .form-item-search {
+ float: left;
+ width: 35%;
}
-#locale-translation-filter-form .form-actions {
- float: left; /* LTR */
- padding: 3ex 0 0 1em; /* LTR */
+
+#locale-translation-filter-search-dropdowns div#locale-translation-filter-actions {
+ float: left;
+ width: 62%;
+ margin: 2% 0 0 2%;
+}
+
+#locale-translation-filter-search-dropdowns .form-item-language {
+ clear: left;
+}
+
+#edit-strings td {
+ vertical-align: top;
}
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 4351342..a5f2470 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -139,20 +139,6 @@ function locale_menu() {
'type' => MENU_LOCAL_TASK,
'file' => 'locale.bulk.inc',
);
- $items['admin/config/regional/translate/edit/%'] = array(
- 'title' => 'Edit string',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('locale_translate_edit_form', 5),
- 'access arguments' => array('translate interface'),
- 'file' => 'locale.pages.inc',
- );
- $items['admin/config/regional/translate/delete/%'] = array(
- 'title' => 'Delete string',
- 'page callback' => 'locale_translate_delete_page',
- 'page arguments' => array(5),
- 'access arguments' => array('translate interface'),
- 'file' => 'locale.pages.inc',
- );
// Localize date formats.
$items['admin/config/regional/date-time/locale'] = array(
@@ -265,6 +251,10 @@ function locale_theme() {
'locale_date_format_form' => array(
'render element' => 'form',
),
+ 'locale_translation_edit_form_strings' => array(
+ 'render element' => 'form',
+ 'file' => 'locale.pages.inc',
+ ),
);
}
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 8f26052..ab197ec 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -12,23 +12,28 @@ function locale_translate_seek_screen() {
// Add CSS.
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
- $elements = drupal_get_form('locale_translation_filter_form');
- $output = drupal_render($elements);
- $output .= _locale_translate_seek();
- return $output;
+ return array(
+ 'filter' => drupal_get_form('locale_translation_filter_form'),
+ 'form' => drupal_get_form('locale_translation_edit_form'),
+ );
}
/**
* Perform a string search and display results in a table
*/
function _locale_translate_seek() {
- $output = '';
// We have at least one criterion to match
if (!($query = _locale_translate_seek_query())) {
+ $languages = language_list(TRUE);
+ $default = language_default();
+ /* if ($default->langcode == 'en' && !locale_translate_english() && count($languages) > 1) { */
+ /* unset($languages['en']); */
+ /* } */
+ $default_language = array_shift($languages);
$query = array(
'translation' => 'all',
- 'language' => 'all',
+ 'language' => $default_language->langcode,
'customized' => 'all',
'string' => '',
);
@@ -40,95 +45,52 @@ function _locale_translate_seek() {
$sql_query->fields('t', array('translation', 'language', 'customized'));
// Compute LIKE section.
- switch ($query['translation']) {
- case 'translated':
- $sql_query->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
- $sql_query->orderBy('t.translation', 'DESC');
- if ($query['customized'] != 'all') {
- $sql_query->condition('t.customized', $query['customized']);
- }
- break;
- case 'untranslated':
- $sql_query->condition(db_and()
- ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE')
- ->isNull('t.translation')
- );
- $sql_query->orderBy('s.source');
- break;
- case 'all' :
- default:
- $condition = db_or()
- ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');
- if ($query['language'] != LANGUAGE_SYSTEM) {
- // Only search in translations if the language is not forced to system language.
- $condition->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
- }
+ // Translated and Untranslated strings
+ if ($query['translation'] == 'all') {
+ if (!empty($query['string'])) {
+ $condition = db_or()->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');
+ $condition->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
$sql_query->condition($condition);
- break;
+ }
+ if ($query['customized'] != 'all') {
+ $sql_query->condition('t.customized', $query['customized']);
+ }
}
-
- $limit_language = NULL;
- if ($query['language'] != LANGUAGE_SYSTEM && $query['language'] != 'all') {
- $sql_query->condition('language', $query['language']);
- $limit_language = $query['language'];
+ // Only translated string
+ if ($query['translation'] == 'translated') {
+ if (!empty($query['string'])) {
+ $sql_query->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
+ }
+ $sql_query->orderBy('t.translation', 'DESC');
+ if ($query['customized'] != 'all') {
+ $sql_query->condition('t.customized', $query['customized']);
+ }
}
-
- $sql_query = $sql_query->extend('PagerDefault')->limit(50);
- $locales = $sql_query->execute();
-
- $header = array(t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2'));
-
- $strings = array();
- foreach ($locales as $locale) {
- if (!isset($strings[$locale->lid])) {
- $strings[$locale->lid] = array(
- 'languages' => array(),
- 'location' => $locale->location,
- 'source' => $locale->source,
- 'context' => $locale->context,
- );
+ // Only untranslated strings
+ if ($query['translation'] == 'untranslated') {
+ if (empty($query['string'])) {
+ $sql_query->isNull('t.translation');
}
- if (isset($locale->language)) {
- $strings[$locale->lid]['languages'][$locale->language] = $locale->translation;
+ else {
+ $sql_query->condition(db_and()
+ ->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE')
+ ->isNull('t.translation')
+ );
}
+ $sql_query->orderBy('s.source');
}
- $rows = array();
- foreach ($strings as $lid => $string) {
- $rows[] = array(
- array('data' => check_plain(truncate_utf8(str_replace(LOCALE_PLURAL_DELIMITER, ', ', $string['source']), 150, FALSE, TRUE)) . '
' . $string['location'] . ''),
- $string['context'],
- array('data' => _locale_translate_language_list($string['languages'], $limit_language), 'align' => 'center'),
- array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
- array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
- );
+ if ($query['translation'] == 'translated') {
+ $sql_query->condition('t.language', $query['language']);
}
-
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No strings available.')));
- $output .= theme('pager');
-
- return $output;
-}
-
-/**
- * List languages in search result table
- */
-function _locale_translate_language_list($translation, $limit_language) {
- // Add CSS.
- drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
-
- $languages = language_list();
- if (!locale_translate_english()) {
- unset($languages['en']);
- }
- $output = '';
- foreach ($languages as $langcode => $language) {
- if (!$limit_language || $limit_language == $langcode) {
- $output .= (!empty($translation[$langcode])) ? $langcode . ' ' : "$langcode ";
- }
+ else {
+ $condition = db_or()->condition('t.language', $query['language']);
+ $condition->isNull('t.language');
+ $sql_query->condition($condition);
}
- return $output;
+ $sql_query = $sql_query->extend('PagerDefault')->limit(variable_get('locale_translations_edit_limit', 6));
+ return $sql_query->execute();
}
/**
@@ -158,43 +120,50 @@ function locale_translation_filters() {
drupal_static_reset('language_list');
$languages = language_list();
$language_options = array();
+ $default_language = '';
foreach ($languages as $langcode => $language) {
- if ($langcode != 'en' || locale_translate_english()) {
- $language_options[$langcode] = $language->name;
+ // if ($langcode != 'en' || locale_translate_english()) {
+ $language_options[$langcode] = $language->name;
+ if ($language->default) {
+ $default_language = $langcode;
}
+ // }
}
$filters['string'] = array(
'title' => t('String contains'),
- 'description' => t('Leave blank to show all strings. The search is case sensitive.'),
+ 'description' => t('Search is case sensitive.'),
);
$filters['language'] = array(
'title' => t('Language'),
- 'options' => array_merge(array('all' => t('All languages'), LANGUAGE_SYSTEM => t('System (English)')), $language_options),
+ 'options' => $language_options,
+ 'default_value' => $default_language,
);
$filters['translation'] = array(
- 'title' => t('Search in'),
+ 'title' => t('With/without translation'),
'options' => array(
- 'all' => t('Both translated and untranslated strings'),
- 'translated' => t('Only translated strings'),
+ 'all' => t('All strings'),
+ 'translated' => t('Translated strings'),
'untranslated' => t('Untranslated strings')
),
+ 'default_value' => 'all',
);
$filters['customized'] = array(
'title' => t('Translation type'),
'options' => array(
- 'all' => t('All'),
+ 'all' => t('Both customized and non-customized'),
LOCALE_NOT_CUSTOMIZED => t('Non-customized translation'),
LOCALE_CUSTOMIZED => t('Customized translation'),
),
'states' => array(
'visible' => array(
- ':input[name=translation]' => array('value' => 'translated'),
- )
+ ':input[name="translation"]' => array('!value' => 'untranslated'),
+ ),
),
+ 'default_value' => 'all',
);
return $filters;
@@ -211,26 +180,41 @@ function locale_translation_filter_form() {
$form['filters'] = array(
'#type' => 'fieldset',
'#title' => t('Filter translatable strings'),
- '#collapsible' => TRUE,
+ '#collapsible' => FALSE,
'#collapsed' => FALSE,
+ '#prefix' => '
',
+ '#suffix' => '
',
);
foreach ($filters as $key => $filter) {
// Special case for 'string' filter.
if ($key == 'string') {
- $form['filters']['status']['string'] = array(
+ $form['filters']['status']['string']['search'] = array(
'#type' => 'search',
'#title' => $filter['title'],
'#description' => $filter['description'],
);
+ $form['filters']['status']['string']['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Filter'),
+ '#prefix' => '',
+ );
+ if (!empty($_SESSION['locale_translation_filter'])) {
+ $form['filters']['status']['string']['reset'] = array(
+ '#type' => 'submit',
+ '#value' => t('Reset'),
+ '#suffix' => '
',
+ );
+ }
+ else {
+ $form['filters']['status']['string']['submit']['#suffix'] = '';
+ }
}
else {
$form['filters']['status'][$key] = array(
'#title' => $filter['title'],
'#type' => 'select',
- '#empty_value' => 'all',
- '#empty_option' => $filter['options']['all'],
- '#size' => 0,
'#options' => $filter['options'],
+ '#default_value' => isset($filter['default_value']) ? $filter['default_value'] : '',
);
if (isset($filter['states'])) {
$form['filters']['status'][$key]['#states'] = $filter['states'];
@@ -241,34 +225,10 @@ function locale_translation_filter_form() {
}
}
- $form['filters']['actions'] = array(
- '#type' => 'actions',
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['filters']['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Filter'),
- );
- if (!empty($_SESSION['locale_translation_filter'])) {
- $form['filters']['actions']['reset'] = array(
- '#type' => 'submit',
- '#value' => t('Reset')
- );
- }
-
return $form;
}
/**
- * Validate result from locale translation filter form.
- */
-function locale_translation_filter_form_validate($form, &$form_state) {
- if ($form_state['values']['op'] == t('Filter') && empty($form_state['values']['language'])) {
- form_set_error('type', t('You must select something to filter by.'));
- }
-}
-
-/**
* Process result from locale translation filter form.
*/
function locale_translation_filter_form_submit($form, &$form_state) {
@@ -296,143 +256,129 @@ function locale_translation_filter_form_submit($form, &$form_state) {
*
* @ingroup forms
*/
-function locale_translate_edit_form($form, &$form_state, $lid) {
- // Fetch source string, if possible.
- $source = db_query('SELECT source, context, location FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
- if (!$source) {
- drupal_set_message(t('String not found.'), 'error');
- drupal_goto('admin/config/regional/translate/translate');
- }
- // Split source to work with plural values.
- $source_array = explode(LOCALE_PLURAL_DELIMITER, $source->source);
- if (count($source_array) == 1) {
- // Add original text value and mark as non-plural.
- $form['plural'] = array(
- '#type' => 'value',
- '#value' => 0
- );
- $form['original'] = array(
- '#type' => 'item',
- '#title' => t('Original text'),
- '#markup' => check_plain($source_array[0]),
- );
+function locale_translation_edit_form($form, &$form_state) {
+ $locales = _locale_translate_seek();
+
+ $plural_formulas = variable_get('locale_translation_plurals', array());
+ if (isset($_SESSION['locale_translation_filter']['language'])) {
+ $langcode = $_SESSION['locale_translation_filter']['language'];
}
else {
- // Add original text value and mark as plural.
- $form['plural'] = array(
- '#type' => 'value',
- '#value' => 1
- );
- $form['original_singular'] = array(
- '#type' => 'item',
- '#title' => t('Original singular form'),
- '#markup' => check_plain($source_array[0]),
- );
- $form['original_plural'] = array(
- '#type' => 'item',
- '#title' => t('Original plural form'),
- '#markup' => check_plain($source_array[1]),
- );
- }
- if (!empty($source->context)) {
- $form['context'] = array(
- '#type' => 'item',
- '#title' => t('Context'),
- '#markup' => check_plain($source->context),
- );
- }
- $form['lid'] = array(
- '#type' => 'value',
- '#value' => $lid
- );
- $form['location'] = array(
- '#type' => 'value',
- '#value' => $source->location
- );
-
- // Include default form controls with empty values for all languages.
- // This ensures that the languages are always in the same order in forms.
- $languages = language_list();
- if (!locale_translate_english()) {
- unset($languages['en']);
+ $default = language_default();
+ $langcode = $default->langcode;
}
- // Store languages to iterate for validation and submission of the form.
- $form_state['langcodes'] = array_keys($languages);
- $plural_formulas = variable_get('locale_translation_plurals', array());
- $form['translations'] = array(
- '#type' => 'vertical_tabs',
- '#tree' => TRUE
+ $form['langcode'] = array(
+ '#type' => 'value',
+ '#value' => $langcode,
);
-
- // Approximate the number of rows to use in the default textarea.
- $rows = min(ceil(str_word_count($source_array[0]) / 12), 10);
- foreach ($languages as $langcode => $language) {
- $form['translations'][$langcode] = array(
- '#type' => 'fieldset',
- '#title' => $language->name,
+ $form['strings'] = array(
+ '#type' => 'item',
+ '#tree' => TRUE,
+ '#theme' => 'locale_translation_edit_form_strings',
+ );
+ foreach ($locales as $locale) {
+ // Split source to work with plural values.
+ $source_array = explode(LOCALE_PLURAL_DELIMITER, $locale->source);
+ $translation_array = explode(LOCALE_PLURAL_DELIMITER, $locale->translation);
+ if (count($source_array) == 1) {
+ // Add original text value and mark as non-plural.
+ $form['strings'][$locale->lid]['plural'] = array(
+ '#type' => 'value',
+ '#value' => 0
+ );
+ $form['strings'][$locale->lid]['original'] = array(
+ '#type' => 'item',
+ '#title' => t('Original text'),
+ '#title_display' => 'invisible',
+ '#markup' => check_plain($source_array[0]),
+ );
+ }
+ else {
+ // Add original text value and mark as plural.
+ $form['strings'][$locale->lid]['plural'] = array(
+ '#type' => 'value',
+ '#value' => 1
+ );
+ $form['strings'][$locale->lid]['original_singular'] = array(
+ '#type' => 'item',
+ '#title' => t('Singular form'),
+ '#markup' => check_plain($source_array[0]),
+ );
+ $form['strings'][$locale->lid]['original_plural'] = array(
+ '#type' => 'item',
+ '#title' => t('Plural form'),
+ '#markup' => check_plain($source_array[1]),
+ );
+ }
+ if (!empty($locale->context)) {
+ $form['strings'][$locale->lid]['context'] = array(
+ '#type' => 'value',
+ '#value' => check_plain($locale->context),
+ );
+ }
+ $form['strings'][$locale->lid]['location'] = array(
+ '#type' => 'value',
+ '#value' => $locale->location,
);
- if (empty($form['plural']['#value'])) {
- $form['translations'][$langcode][0] = array(
+
+ // 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'][$locale->lid]['plural']['#value'])) {
+ $form['strings'][$locale->lid]['translations'][0] = array(
'#type' => 'textarea',
- '#title' => $language->name,
+ '#title' => t('Translation'),
+ '#title_display' => 'invisible',
'#rows' => $rows,
- '#default_value' => '',
+ '#default_value' => $translation_array[0],
);
}
else {
// Dealing with plural strings.
- if (isset($plural_formulas[$langcode]['plurals']) && $plural_formulas[$langcode]['plurals'] > 1) {
+ if (isset($plural_formulas[$locale->language]['plurals']) && $plural_formulas[$locale->language]['plurals'] > 1) {
// Add a textarea for each plural variant.
- for ($i = 0; $i < $plural_formulas[$langcode]['plurals']; $i++) {
- $form['translations'][$langcode][$i] = array(
+ for ($i = 0; $i < $plural_formulas[$locale->language]['plurals']; $i++) {
+ $form['strings'][$locale->lid]['translations'][$i] = array(
'#type' => 'textarea',
'#title' => ($i == 0 ? t('Singular form') : format_plural($i, 'First plural form', '@count. plural form')),
'#rows' => $rows,
- '#default_value' => '',
+ '#default_value' => $translation_array[$i],
);
}
}
else {
// Fallback for unknown number of plurals.
- $form['translations'][$langcode][0] = array(
+ $form['strings'][$locale->lid]['translations'][0] = array(
'#type' => 'textarea',
'#title' => t('Sigular form'),
'#rows' => $rows,
- '#default_value' => '',
+ '#default_value' => $translation_array[0],
);
- $form['translations'][$langcode][1] = array(
+ $form['strings'][$locale->lid]['translations'][1] = array(
'#type' => 'textarea',
'#title' => t('Plural form'),
'#rows' => $rows,
- '#default_value' => '',
+ '#default_value' => isset($translation_array[1]) ? $translation_array[1] : '',
);
}
}
}
- // Fetch translations and fill in default values in the form.
- $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = :lid", array(':lid' => $lid));
- foreach ($result as $translation) {
- $translation_array = explode(LOCALE_PLURAL_DELIMITER, $translation->translation);
- for ($i = 0; $i < count($translation_array); $i++) {
- $form['translations'][$translation->language][$i]['#default_value'] = $translation_array[$i];
- }
+ if (count(element_children($form['strings']))) {
+ $form['actions'] = array('#type' => 'actions');
+ $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
}
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save translations'));
return $form;
}
/**
* Validate string editing form submissions.
*/
-function locale_translate_edit_form_validate($form, &$form_state) {
- foreach ($form_state['langcodes'] as $langcode) {
- foreach ($form_state['values']['translations'][$langcode] as $key => $value) {
+function locale_translation_edit_form_validate($form, &$form_state) {
+ foreach ($form_state['values']['strings'] as $lid => $translations) {
+ foreach ($translations['translations'] as $key => $value) {
if (!locale_string_is_safe($value)) {
- form_set_error("translations][$langcode][$key", t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
+ form_set_error("strings][$lid][translations][$key", t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
watchdog('locale', 'Attempted submission of a translation string with disallowed HTML: %string', array('%string' => $value), WATCHDOG_WARNING);
}
}
@@ -444,15 +390,15 @@ function locale_translate_edit_form_validate($form, &$form_state) {
*
* Saves all translations of one string submitted from a form.
*/
-function locale_translate_edit_form_submit($form, &$form_state) {
- $lid = $form_state['values']['lid'];
- foreach ($form_state['langcodes'] as $langcode) {
+function locale_translation_edit_form_submit($form, &$form_state) {
+ $langcode = $form_state['values']['langcode'];
+ foreach ($form_state['values']['strings'] as $lid => $translations) {
// Serialize plural variants in one string by LOCALE_PLURAL_DELIMITER.
- $value = implode(LOCALE_PLURAL_DELIMITER, $form_state['values']['translations'][$langcode]);
- $translation = db_query("SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $langcode))->fetchField();
+ $translation_new = implode(LOCALE_PLURAL_DELIMITER, $translations['translations']);
+ $translation_old = db_query("SELECT translation FROM {locales_target} WHERE lid = :lid AND language = :language", array(':lid' => $lid, ':language' => $langcode))->fetchField();
// No translation when all strings are empty.
$has_translation = FALSE;
- foreach ($form_state['values']['translations'][$langcode] as $string) {
+ foreach ($translations['translations'] as $string) {
if (!empty($string)) {
$has_translation = TRUE;
break;
@@ -460,28 +406,28 @@ function locale_translate_edit_form_submit($form, &$form_state) {
}
if ($has_translation) {
// Only update or insert if we have a value to use.
- if (!empty($translation) && $translation != $value) {
+ if (!empty($translation_old) && $translation_old != $translation_new) {
db_update('locales_target')
->fields(array(
- 'translation' => $value,
- 'customized' => LOCALE_CUSTOMIZED,
- ))
+ 'translation' => trim($translation_new),
+ 'customized' => LOCALE_CUSTOMIZED,
+ ))
->condition('lid', $lid)
->condition('language', $langcode)
->execute();
}
- if (empty($translation)) {
+ if (empty($translation_old)) {
db_insert('locales_target')
->fields(array(
- 'lid' => $lid,
- 'translation' => $value,
- 'language' => $langcode,
- 'customized' => LOCALE_CUSTOMIZED,
- ))
+ 'lid' => $lid,
+ 'translation' => trim($translation_new),
+ 'language' => $langcode,
+ 'customized' => LOCALE_CUSTOMIZED,
+ ))
->execute();
}
}
- elseif (!empty($translation)) {
+ elseif (!empty($translation_old)) {
// Empty translation entered: remove existing entry from database.
db_delete('locales_target')
->condition('lid', $lid)
@@ -489,55 +435,42 @@ function locale_translate_edit_form_submit($form, &$form_state) {
->execute();
}
- // Force JavaScript translation file recreation for this language.
- _locale_invalidate_js($langcode);
}
- drupal_set_message(t('The string has been saved.'));
+ drupal_set_message(t('The strings have been saved.'));
+ // Force JavaScript translation file recreation for this language.
+ _locale_invalidate_js($langcode);
// Clear locale cache.
- _locale_invalidate_js();
cache()->deletePrefix('locale:');
- $form_state['redirect'] = 'admin/config/regional/translate/translate';
return;
}
-/**
- * String deletion confirmation page.
- */
-function locale_translate_delete_page($lid) {
- if ($source = db_query('SELECT lid, source FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject()) {
- return drupal_get_form('locale_translate_delete_form', $source);
- }
- else {
- return drupal_not_found();
+function theme_locale_translation_edit_form_strings($variables) {
+ $output = '';
+ $header = array(t('Source string'), t('Translation'), t('Operations'));
+ $rows = array();
+ $form = $variables['form'];
+ 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'] .'';
+ if ($string['location']['#value']) {
+ $source .= '
'. $string['location']['#value'] .'';
+ }
+ $rows[] = array(
+ array('data' => $source),
+ array('data' => $string['translations']),
+ array('data' => ''),//TODO: add operations
+ );
}
-}
-
-/**
- * User interface for the string deletion confirmation screen.
- *
- * @ingroup forms
- */
-function locale_translate_delete_form($form, &$form_state, $source) {
- $form['lid'] = array('#type' => 'value', '#value' => $source->lid);
- return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel'));
-}
-
-/**
- * Process string deletion submissions.
- */
-function locale_translate_delete_form_submit($form, &$form_state) {
- db_delete('locales_source')
- ->condition('lid', $form_state['values']['lid'])
- ->execute();
- db_delete('locales_target')
- ->condition('lid', $form_state['values']['lid'])
- ->execute();
- // Force JavaScript translation file recreation for all languages.
- _locale_invalidate_js();
- cache()->deletePrefix('locale:');
- drupal_set_message(t('The string has been removed.'));
- $form_state['redirect'] = 'admin/config/regional/translate/translate';
+ $output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No strings available.')));
+ $output .= theme('pager');
+ return $output;
}