My client wanted the ability to translate the source string inside the table. I see no reason why that shouldn't be possible so I threw together a quick hack for him.

I changed this at line 40:

$form['source'] = array(
  '#type' => 'markup',
  '#value' => check_plain($source->source),
);

to this:

$form['source'] = array(
  '#type' => 'textfield',
  '#default_value' => check_plain($source->source),
  '#size' => 35,
  '#maxlength' => NULL,
);

And I added the part between the #### Hack comments inside this function

/**
 * Submit handler for the translation table.
 */
function translation_table_submit_translations($form, &$form_state) {
  switch ($form_state['clicked_button']['#id']) {
    case 'edit-submit':
      $language_list = locale_language_list('language', TRUE);
      db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $translation, $lid, $lang_code);
      foreach ($form_state['values']['strings'] as $lid => $values) {
######### Start Hack
        $tid = str_replace('term:', '', $values['location']);
        $tid = str_replace(':name', '', $tid);
        $term = (array)taxonomy_get_term($tid);
        if ($values['source'] != $term['name']) {
          $term['name'] = $values['source'];
          $taxonomy_term_form_state = array();
          $taxonomy_term_form_state['values']['tid'] = $tid;
          $taxonomy_term_form_state['values']['name'] = $values['source'];
          
          //include the file containing the required functions
          module_load_include('inc', 'taxonomy', 'taxonomy.admin');

          drupal_execute('taxonomy_form_term', $taxonomy_term_form_state, taxonomy_vocabulary_load($term['vid']), $term);
        }
######### End Hack
        foreach ($values as $lang_code => $translation) {
          if (in_array($lang_code, $language_list)) {
            _translation_table_update_translation($lid, $lang_code, $translation);
          }
        }
      }
      break;
  }
}

I don't know how to create a patch, but I'm posting it here for you or anyone else to take a look at if you're interested. :)

I'm a pretty poor programmer so some things are probably pretty hacky, but it works and me and my client is happy. :D

It sets an error message if you try to submit the form with an empty source string field and all the set_messages it spits out if you edit a lot of fields at once can be a bit annoying, but those things can probably be fixed rather easily. I don't want my client to delete terms by emptying the field so that's actually fine for my use.

If you spot some major problems with my approach then please let me know because this code is in use now. :)

Comments

TwiiK’s picture

Component: Code » User interface
Pasqualle’s picture

Status: Active » Closed (won't fix)

We will not duplicate the Drupal admin functionality for updating every source type for dynamic string. This module is for translating dynamic string, nothing more. The only option when I would consider such feature if Drupal has a general function for updating displayed stings, but I doubt it will be ever implemented..

TwiiK’s picture

Status: Closed (won't fix) » Active

I don't see how providing a quick interface for renaming multiple term names at once "duplicating Drupal functionality".

I find there is no straight forward way for end users to translate the drupal interface (the core search for strings is abysmal and the localization client is a little hard to use) so I really liked this module when I first tried it out. My goal for it is a page where the end user can manage more or less every string in the interface without having to use any other mode of translation.

My local version of the module is already so different from the official that I may just start my own project then if we're already on separate paths. :)

My next milestone is getting every single string into the table so I won't have to use the string search ever again.

Pasqualle’s picture

you are putting taxonomy module specific code into translation table, that is not the scope of this module. This module works with the db tables: {locales_source}, {locales_target} and {i18n_strings}. It does not have to know where the strings come from and how they are used in Drupal.

string search and the translation table are 2 different things also. Translation table works with dynamic strings only so you can't translate everything with it..