_locale_string_save

Versions
4.6
_locale_string_save($lid)

Action handler for string editing

Saves all translations of one string submitted from a form

Code

includes/locale.inc, line 921

<?php
function _locale_string_save($lid) {

  $edit =& $_POST['edit'];
  foreach ($edit as $key => $value) {
    $trans = db_fetch_object(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $key));
    if (isset($trans->translation)) {
      db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND locale = '%s'", $value, $lid, $key);
    }
    else {
      db_query("INSERT INTO {locales_target}  (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid, $value, $key);
    }
  }
  // refresh the locale cache
  locale_refresh_cache();
  // rebuild the menu, strings may have changed
  menu_rebuild();
  // delete form data so it will remember where it came from
  $edit = '';

  drupal_set_message(t('Saved string'));
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.