How to use translating tool in Drupal 5

Last modified: September 16, 2008 - 22:26

First backup

When you start to implement your own local version, and you replace the built-in text, is a good idea to make a backup regularly. Every time you upgrade a module to a new version, your text for that module is deleted from the database, and is replaced by the module's own translation. This could happen even you disable a modul, and reenable it later (for testing purposes, say).

For Drupal 5.x:

  • go to Administer>>Site configuration>>Localization
  • click on the Export link and save your .po file to your hard disk
  • disable the module you want to upgrade it - or uninstall it, if it has this feature - at Administer>>Site building>>Modules
  • install the new version of your module
  • enable it at Administer>>Site building>>Modules
  • go to Administer>>Site configuration>>Localization
  • click on Import link, browse for your .po file
  • select Mode: Strings in the uploaded file replace existing ones, new ones are added
  • hit the Import button, and you have done
  • and don't forget to make your backup next time you modify some strings...

Translating

Translating strings is not always obvious. In most cases you have to search the string you want to translate at Administer >> Site configuration >> Localization >> Manage strings tab.

Run a search for your string, and select edit. Enter your version and Save translation. If you refresh the page now, you have to see the translated string.

Some of the menu items could be translated editing the menu item at Administer >> Site building >> Menus.

If you try to translate some strings for a contributed module, well, this could be a little complicated. The string you search for could, or could not exist in the translation table. Maybe you find it and translate it, and no result - nothing is changing after page refresh.

You could try to export all strings to a .po file, and edit it with Poedit. You import then back to Drupal, but no way. What's happening?

The contributed modules comes with theirs translation table in a .po file. Enabling a module, the install script load the .po file to the menu table. Your translation usually goes to the same place. More than that, at first time you visit a page, all strings from that page are filled in the menu_cache table, and stored there for further use. You could translate a string, but the page still use the old one from cache.

Now you have to go to the database, and manually empty the cache tables - usually I clean all of them, for sure.

You could try to run the update script (yoursite_url/update.php).

Updating frequently is not recommended, however this may help you to wipe out some unneeded record from tables. They appear especially if you play around with modules - enabling and disabling them, installing and uninstalling at random.

You may find no way to translate your string. If you have programming knowledge, you could have a look at the php code.

The translatable strings usually are enclosed by the t() function like this - t('your translatable string'). You may have unfinished modules, beta versions, having hardcoded strings - they could appear in the translation table, you could export them to the .po file, but they are untranslatable by the Locale module. You may correct the script, or you may open an issue to the developer, and expect he will include them in the next stable version.

All of these I found by hard try - if there is anybody who knows the short way, please feel free to show it.

Note: for Drupal 4.x you find the translate function at: Administer >> Localization >> Manage strings .

 
 

Drupal is a registered trademark of Dries Buytaert.