Localizing Your Sites Interface

You can localize (translate) the interface to a single language or to multiple languages. The basic steps to localizing your interface are as follows:

1. Enable the Locale module.

2. Add a new language at Configuration C> Languages.

3. Upload an existing translation or create one yourself.

A translation is added to Drupal through one or more Portable Object (.po) file. If these are already present on your site they will be automatically imported when a new language is added thus eliminating step three. Before jumping to the exercises on adding a translation take a few minutes to learn about these important .po files.

Portable Object (.po) Files

Portable Object (.po) files are web standard files used to translate a set of strings from a base language to a second language in what is known as the Gettext Portable Object Template format. These files are language-specific and relate to a specific set of strings. Each contributed module or theme you download may include a translations folder that contains language-specific .po files for translating the strings used by the module or theme.

TYPE5 FORMATS LOCALIZE

+ Add date type

TYPE5 FORMATS LOCALIZE

+ Add date type

DATE TYPE

FORMAT

OPERATIONS

Lang

Friday, December 31, 20K

-12:13 jJ

Medium

Fri, 12/31JM10- 12:13

3

Short

12/31/2010 - 12:13

a

Save configuration

FIGURE 12-2

For example the Spanish translation for the core Node module contains the following string and translation:

msgid "Read more" msgstr "Leer más"

When you add a new language Drupal will scan the directories searching for .po files and copy the strings and translations into a Strings table in your database. If a .po file corresponding to one of your site's enabled languages is included with the module, it will be automatically imported. If you enable a language after installing a module, you will have to manually add the .po files, demonstrated in this chapter's exercise, Localizing Your Site's Interface using http://localize.drupal.org.

The Current State of Drupal Translation

Translations in Drupal are in a transition phase moving from a static translation to a more dynamic, up-to-date, and community managed translation system. In the past a single team of translators would collaborate to create a translation of Drupal, releasing their work on drupal.org. Problems arose when the team couldn't keep up with the rapid pace of Drupal development or the translation of thousands of Drupal modules. A new approach was taken.

In the new approach the team model shifted to a distributed model, enlisting every translated Drupal site. The L10N Client and Server modules were developed, which allow site owners (like you) to submit translations to a central server. When you translate your own site you can also contribute to the translation of other Drupal sites, without having to do extra work. When these modules are fully developed they will also download translations to your site, making the process of translating your site easier.

This chapter will start by guiding you through the current method of adding a translation, then in a second exercise introduce you to the new method of adding a translation. The method you will use is dependent on the language of your site. For example, the Spanish translation has already transi-tioned to the new method. Many other languages have not yet made the transition

You are encouraged to do both exercises to familiarize yourself with how Drupal is translated. Performing both exercises will cause no harm to your website because Drupal simply ignores string translations that have already been imported.

Follow along in this first exercise to learn how to use the translations available at http://drupal.org/ project/Translations. The Ukrainian translation is used for this example but you may choose any other available language.

QQQQQQUg Localizing Your Site's Interface using drupai org/project/Transiations In this exercise, you add the Ukrainian translation to your site.

1. Enable the Locale module.

2. Navigate to http://drupal.org/project/Translations then find the Ukrainian Language project page. Languages are listed alphabetically.

Alternatively you can navigate directly to the project's page at http://drupal.org/project/uk.

3. Download the Drupal 7 translation and place the downloaded .tar.gz file in your site's root directory, as shown in Figure 12-3. Note the additional uk-7.x-1.1.tar.gz file in the lower right corner.

FIGURE 12-3

4. From a command line, navigate to your Drupal directory and type in the following command: tar zxvf uk-7.x-1.1.tar.gz

¿y) NOTE Replace uk-7.x.1.1. tar.gz with the downloaded file name. This will place numerous .po files throughout your Drupal install.

5. Navigate to Configuration C> Languages (under Regional and Language), and then click Add Language at the top of the page as shown in Figure 12-4.

Home * Administer ■ Configuration * Regional and language

Languages o

LIST DETECTION AND SELECTION

With multiple languages enabled, interface text can be translated, registered users may select their preferred language, and authors can assign a specific language to content. Download contributed translations from Drupal.org

ENGLISH MAME

NATIVE NAME

CODE

DIRECTION

ENABLED

DEFAULT

OPERATIONS

English

English

en

Left to right

3!

8

edit

5ave configuration

5ave configuration

6. Select Ukrainian from the predefined languages list, select Add language, as shown in Figure 12-5. Drupal will import the string translations from the .po files you added in this exercise.

Home * Administer * Configuration • Regional and language » Languages

Languages o ai detection and selec"

:tion

Add a language to be supported by your site. If your desired language is not available r the Language name drop-down, dick Custom language and provide a language code and other details manually. When providing a language eode manually, be sure to enter a standardi?ed language code, since this code may be used by browsers to determine an appropriate display language.

-PREDEFINED LANGUAGE Language name

Jkrainian {yKpaiHCbKaJ

Use the Custom language section below If your desired language does not appear In this list. Add language

FIGURE 12-5

How It Works

Drupal can simultaneously provide its interface and content in multiple languages. Before it can do so, it needs to know the languages to be offered and how those languages are identified (their RFC 4646 identifiers), and it must create a repository for the language. You did all of this by simply selecting the predefined Ukrainian language. Whenever possible, you should use Drupal's predefined languages, because they are based on RFC standards.

When a new language is added, Drupal searches all directories for .po files. In this exercise you downloaded the files from http://drupal.org/project/Translations and added them to your Drupal directory with the tar zxvf command. Later, when you update Drupal you will not need to repeat this exercise, as the translation is already available. The .po files are only required for the initial import.

The previous exercise demonstrated the much more ubiquitous but deprecated method of adding a new language. The next exercise demonstrates the newer method that at the time of writing was still under development. This method works with the new centralized translation server at http:// localize.drupal.org, where you can find the most up to date information and translations. It is also designed to compliment the localization client, available at http://drupal.org/project/ l10n_client and discussed later in this chapter.

TRY IT OUT

_ Localizing Your Site's Interface using http://locali ze.drupal.org

In this exercise, you add the Spanish translation to your site using http://localize.drupal.org.

1. Navigate to Configuration C> Languages (under Regional and Language), then click Add Language at the top of the page.

2. Select Spanish from the Predefined Language list, then click Add Language. Note that no strings will be imported because Drupal does not have .po files to import. You will retrieve these from http://localize.drupal.org.

3. Navigate to http://localize.drupal.org and login with your Drupal.org username and password. Create an account on drupal.org if you do not have one.

4. Select the Spanish language from the frontpage, then click the Choose button, as shown in Figure 12-6.

FIGURE 12-6

Join the Spanish group by clicking the Join link on the project's home page. Click the Export tab and select the following options as shown in Figure 12-7:

Project: Drupal

Release: Drupal 7 (Drupal 6 is also acceptable)

Type: Include both English original and translations

Packaging: All in one file

Verbosity: Compact file optimized for size, not desktop editing

Click the Export button and save the resulting file to your local disk.

On your Drupal site, navigate to Configuration C> Translate Interface (under Regional and Language), and click Import. On the Import Translation page, add the Spanish translation file you downloaded in step 1 as shown in Figure 12-8.

Export Spanish translations

Overview I Browse I Export

Export Spanish translations

Overview I Browse I Export

Project: »

1 Dru pal

ol

Release:

1 6.14 only

~3

@ Include both English originals and translations

O Just export English originals

Packaging:

Format-Tvpe:

@ Include both English originals and translations

O Just export English originals

Packaging:

O Drupal 6 package format (translations directories) O Drupal 5 package format (for autolocale module} O nat package far CVS commit fuse for Drupal core) 8 All in ore file Verbosity:

O Verbose riles useful toe desktop translation © Compact files optimized for size, not desktop editing

Home » Administer » Configuration and modules » Regional and language » Translate interface Skip to main content

Translate interface o overv.ew translate import export

IMPORT TRANSLATION

Language fife_

l/Users/jfeddingj/Downloads/dru pal -a I l-es. po Browse...

A Gettext Portable Object file. Import into

Spanish v |

Choose the language you want to add strings into. If you choose a language which is not yet set up, it will be added.

Text group

© Built-in interface

Imported translations will be added to this text group. Mode

O Strings in the uploaded file replace existing ones, new ones are added 0 Existing strings are kept, only new strings are added Import

FIGURE 12-8

8. After importing, you should be redirected to the Overview page. Verify that the translation was properly added by reviewing the Translation Status column on this page, as shown in Figure 12-9.

Home a Administer » Configuration » Regional and language

Translate interface o

TRANSLATE

• The translation was successfully imported. There are 3266 newly created translated strings, 0 strings were updated and 0 strings were removed.

• 4 translation strings were skipped because they contain disallowed HTML.

This page provides an overview of available translatable strings. Drupal displays translatable strings in text groups; modules may define additional text groups containing other translatable strings. Because text groups provide a method of grouping related strings, they are often used to focus translation efforts on specific areas of the Drupal interface.

See the Languages page for more information on adding support for additional languages.

LANGUAGE

BUILT-IN INTERFACE

English (built-in)

n/a

Spanish (

^5549/6348 (87^41^)

Ukrainian

4206/6348 (66.2696)

FIGURE 12-9

How It Works

Self-organized community groups located all over the world maintain translations of Drupal. Beginning in late 2009, these groups began to use the centralized website http://localize.drupal.org to collaborate on and to share their translations. (Previously, these groups collaborated at http://drupal.org/proj-ect/Translations, and although translations still exist at that site, it's best to use localize.drupal.org instead.) In this exercise, you downloaded the latest translation of the Drupal project. Note that you could have just as easily downloaded a translation of any contributed module or theme available on Drupal.org.

The translations are graciously donated and worked on by groups of community volunteers. This centralized worldwide collaboration often leads to translations being more readily available in more languages and for more projects. However, this also means that a translation may not be 100-percent complete, as shown in Figure 12-9. At the time of this writing, the Spanish translation was only 87-percent complete. The untranslated portions are output in English.

Was this article helpful?

0 0

Post a comment