Index: l10n_community/translate.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/l10n_server/l10n_community/Attic/translate.inc,v retrieving revision 1.1.2.7.2.31.2.2 diff -u -p -r1.1.2.7.2.31.2.2 translate.inc --- l10n_community/translate.inc 26 Jan 2010 15:49:44 -0000 1.1.2.7.2.31.2.2 +++ l10n_community/translate.inc 3 Feb 2010 15:33:45 -0000 @@ -167,7 +167,7 @@ function l10n_community_filter_form_subm } } -// = Translation view ========================================================== +// = Translation form building ================================================= /** * Menu callback: List translations and suggestions. @@ -219,39 +219,57 @@ function l10n_community_translate_form(& $redirect_url = $_GET; unset($redirect_url['q']); + // The form will show but the submit buttons will only appear if the user has + // permissions to submit suggestions. This allows the use of this form to review + // strings in the database. $form = array( - '#submit' => array('l10n_community_translate_submit'), - '#redirect' => array($_GET['q'], $redirect_url), - 'langcode' => array('#type' => 'value', '#value' => $language->language), - 'pager_top' => array('#weight' => -10, '#value' => $pager), - 'submit_top' => array('#type' => 'submit', '#value' => t('Save changes'), '#access' => user_access('submit suggestions')), - 'strings' => array('#tree' => TRUE, '#theme' => 'l10n_community_translate_table'), - 'submit' => array('#type' => 'submit', '#value' => t('Save changes'), '#access' => user_access('submit suggestions')), - 'pager_bottom' => array('#weight' => 10, '#value' => $pager), + '#redirect' => array( + $_GET['q'], + $redirect_url + ), + 'langcode' => array( + '#type' => 'value', + '#value' => $language->language + ), + 'pager_top' => array( + '#weight' => -10, + '#value' => $pager + ), + 'submit_top' => array( + '#type' => 'submit', + '#value' => t('Save changes'), + '#access' => user_access('submit suggestions') + ), + 'strings' => array( + '#tree' => TRUE, + '#theme' => 'l10n_community_translate_table' + ), + 'submit' => array( + '#type' => 'submit', + '#value' => t('Save changes'), + '#access' => user_access('submit suggestions') + ), + 'pager_bottom' => array( + '#weight' => 10, + '#value' => $pager + ), ); + // Fill in string values for the editor. foreach ($strings as $string) { - $form['strings'][$string->sid] = _l10n_community_translate_string($form_state, $string, $language); + $form['strings'][$string->sid] = _l10n_community_translate_form_item($form_state, $string, $language); } - return $form; -} -/** - * Return a marked-up string. - */ -function _l10n_community_translate_render_strings($strings, $empty = '') { - if ($empty) { - $empty = ' data-empty="'. check_plain($empty) .'"'; - } - return "". implode("
", array_map('check_plain', $strings)) .''; + return $form; } /** * Creates the form fragment for a source string. */ -function _l10n_community_translate_string(&$form_state, $source, $language) { - // Normalize empty default translation. +function _l10n_community_translate_form_item(&$form_state, $source, $language) { + if (!$source->translation) { + // If there is no picked translation yet, simulate with a visible placeholder. $source->tid = '0'; $source->translation = array(t('(not translated)')); $source->is_active = '1'; @@ -260,26 +278,25 @@ function _l10n_community_translate_strin else { $source->translation = l10n_community_unpack_string($source->translation); } - $source->value = l10n_community_unpack_string($source->value); $form = array( '#string' => $source, '#langcode' => $language->language, 'source' => array( - 'string' => array('#value' => _l10n_community_translate_render_strings($source->value)), + 'string' => array('#value' => _l10n_community_translate_render_textarray($source->value)), ), ); if (user_access('submit suggestions')) { $form['source']['edit'] = array( - '#value' => t('Edit Copy'), - '#prefix' => '