by the word or the sentence in the blog language. To do this, the plugin must have a translation in the given language. You will find below the detail of all the files used.
==== Files organization ====
=== The locales directory ===
The directory named **locales** contains one sub-directory per language the plugin is translated in. For instance it can contain:
* an **en** directory that will contain the English translation files
* an **es** directory that will be for the Spanish version (optional)
* etc.
==== The main.po file ====
Localization example:
# French translation of DotClear
# Copyright (C) 2006.
# Olivier Meunier , 2006.
#
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
...
#: plugins/maintenance/index.php:74
#, php-format
msgid "Indexing entry %d to %d."
msgstr "Index des billets %d à %d"
...
The three first lines contain the translator comments:
* The translation language,
* The license associated to the file,
* The author's name and e-mail address as well as the date of translation.
Let's break down this piece of code to define the use of each line:
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
These two lines define the file format as well as the character encoding method. Here it's using text type and UTF-8 enconding.
#: plugins/maintenance/index.php:74
This line indicates in which file the translation is used and in which line of that file it is used.
If the same translation is used several times, you just have to indicate all the lines like in the following example:
#: plugins/maintenance/index.php:87 plugins/maintenance/index.php:111
If it is really used a lot, you can also use the following syntax that fits on several lines:
#: inc//core/class.dc.blog.php:1497 inc//core/class.dc.blog.php:1503
#: inc//core/class.dc.blog.php:1565
msgid "No such comment ID"
msgstr "Identifiant du commentaire inconnu"
Optionally, you can indicate that the translation contains PHP variables:
#, php-format
In this case, the %d is an integer PHP variable:
msgid "Indexing entry %d to %d."
msgstr "Index des billets %d à %d"
Finally the **msgstr** keyword contains the translation.
If we have a look at the index.php file, line 74... err 90 ;-):
echo ''.sprintf(__('Indexing entry %d to %d.'),$start,$start+$limit).'
';
Voici donc l'appel de la traduction. À la place de "%d to %d", elle contiendra le contenu des variables **$start** et **$start+$limit**.
Here is where the translation is called. The two ''%d'' will be replaced by the content of **$start** and **$start+$limit** variables, respectively.
$GLOBALS['__l10n']['Newsletter'] = 'Lettre d\'informations';