Site Meter

Reply to comment

How to force Drupal update the module translations?

If you are a Drupal developer, you could be translate some modules with localization Drupal system.

Maintain modules translations are not hard, but when you updates your translations,  Drupal doesn't know nothing about that. Always when we install new modules versions, we need to run the update.php script. The problem is translations are imported only when new modules or themes are installed or enabled. The Drupal ignores the translations updates. It's a big trouble for developers and users that not use the english as your main language.

The solution is use a hook_update_N() in your .install file. The main goal of hook_update_N() is update the database schemas, but at some cases we can use it to other kind of updates.

In your hook_update_N() call the locale_system_update() and your translations will be updated.

Follow the example bellow:

/**
 * Import new translations.
 */
function my_module_update_6001() {
  $ret = array();

  if (module_exists('locale')) {
    locale_system_update(array('my_module'));
    $ret[] = array('success' => TRUE, 'query' => 'New translations were imported.');
  } 

  return $ret;
}


work perfectly!

Trackback URL for this post:

http://www.tutolivre.net/en/trackback/162

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.