Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Apress.Pro.Drupal.7.Development.3rd.Edition.Dec.2010.pdf
Скачиваний:
73
Добавлен:
14.03.2016
Размер:
12.64 Mб
Скачать

CHAPTER 19 LOCALIZATION AND TRANSLATION

Caution The method we are introducing here is for touching up Drupal sites and targeting certain interface elements for string replacement, and it is not complete. For example, if a module containing the word “blog” were not enabled, we would miss the translation of those strings. A more complete method is introduced in the “Starting a New Translation” section of this chapter.

That change is all well and good, but it’s bothersome that the URL for creating a new journal entry is still http://example.com/?q=node/add/blog; shouldn’t it be http:// example.com/?q=node/add/journal instead? Sure, it should. We can fix that quickly by enabling the path module and adding an alias with node/add/blog as the existing system path and node/add/journal as the alias. Presto! All references to “blog” have disappeared, and you can use the site without shuddering at seeing the word “blog.”

Tip A third-party module that will make string translation easier is the Localization client module, available at http://drupal.org/project/l10n_client. The module provides an on-page localization editor interface and makes extensive use of AJAX.

Exporting Your Translation

After you’ve gone through the work of selecting and translating the strings you want to change, it would be a shame to have to do it all over again when you set up your next Drupal site. By using the Export tab at Configuration -> Translate interface, you can save the translation to a special file called a portable object (.po) file. This file will contain all of the strings that Drupal has passed through t(), as well as any replacement strings you have defined.

Portable Object Files

The first few lines of the file that results from exporting our English-custom translation follow:

#English-Custom translation of Drupal 7

#Generated by admin <toddtomlinson@serverlogic.com>

msgid "" msgstr ""

"Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2010-08-08 06:01-0700\n" "PO-Revision-Date: 2010-08-08 06:01-0700\n" "Last-Translator: NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n" "MIME-Version: 1.0\n"

"Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n"

428

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]