Locale: multi-language support

The locale module allows you to present your Drupal site in a language other than the default English. You can use it to set up a multi-lingual web site or replace given built-in text with text which has been customized for your site. Whenever the locale module encounters text which needs to be displayed, it tries to translate it into the currently selected language. If a translation is not available, then the string is remembered, so you can look up untranslated strings easily.

The locale module provides two options for providing translations. The first is the integrated web interface, via which you can search for untranslated strings, and specify their translations. An easier and less time-consuming method is to import existing translations for your language. These translations are available as GNU gettext Portable Object files (.po files for short). Translations for many languages are available for download from the translation page.

If an existing translation does not meet your needs, the .po files are easily edited with special editing tools. The locale module's import feature allows you to add strings from such files into your site's database. The export functionality enables you to share your translations with others, generating Portable Object files from your site strings.

You can

  • administer localization at administer >> localization.
  • manage strings for the localization: administer >> localization >> manage strings.
  • add a locale language: administer >> localization >> add language.
  • download translation files from the Drupal translations page.

Enable localization module

augustofagioli - August 29, 2007 - 17:28

We have to say that:

  • the localization module is part of the core drupal (you don't have to download it!)
  • since it is default disabled - you have to enable the Locale module at administer >> modules.

If you start to implement

michael_hun - January 1, 2008 - 17:23

If you start to implement your own local version, and you replace the built-in text with via Administer>>Localization>>Manage strings with your 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...

For Drupal 5.x Translating

michael_hun - January 1, 2008 - 22:30

For Drupal 5.x

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.

wrong plurals setting for EN locale?

wouter99999 - January 18, 2008 - 13:18

In the table locales_meta for EN, plurals is 0 in my Drupal installation (with EN as default language). Should that not be 2 with formula ($n!=1) ?

Wouter

Internationalization

riskone - January 22, 2008 - 10:49

This should probably point to the Internationalization module: http://drupal.org/project/i18n , for people who want to translate content as well as interface strings.

 
 

Drupal is a registered trademark of Dries Buytaert.