The localization procedure
First, thank you! the localization work is long and not the more fancy work, but this is really appreciated at the end by a lot of people. You can always get some help in this process by subscribing in the mailing lists.
Localization system
The system of localization is based on files like the GNU gettext files. They are grouped by language and by part of PLUME CMS.
Main part and installer locale files
These files are in manager/locale/(XX|XX_src)/, replace XX with the 2 letter iso code of your language. For example:
manager/locale/fr/ manager/locale/sk_src/
The files are plume.lang and install.lang for the main language translations and the installer language translations.
Plugins locale files
The locale files are in each plugin folder. Each plugin has a locale folder and then the locale files, like the main part.
manager/tools/smart404/locale/fr/smart404.lang manager/tools/plumeconf/locale/fr/plumeconf.lang
Format of the locale files
The format is very simple, you have first 2 lines of headers, and then the translations.
Here are the first lines of the /locale/fr/plume.lang file:
# -*- coding: iso-8859-1 -*- # (C) 2004 Loïc d'Anterroches, Cédric Arrabie ;There is an error with your login or your password. Il y a une erreur dans votre identifiant ou votre mot de passe. ;Login: Identifiant :
The first line contains the encoding of the file. This is very important to have it right so that PLUME CMS can handle the file correctly. If you do a translation with an encoding which is not iso-8859-1 or utf-8 you must put the files in the folder locale/XX_src/. This is because PHP handles only those two encodings by default. That way when we create a new release of PLUME CMS we can convert your file in your encoding into locale/XX/ with the utf-8 encoding.
The second line is a copyright line, just put your name and the date.
Then you have the translations. The translations are in block of 3 lines, the original string, the localized string and an empty line.
That way it is very easy to translate, as you can directly see the orginal string.
Tools
To help you in the process you have the script getlocale.php available in the manager folder. If you run it from your installation you will have something like:
Usage: getlocale.php?w=(plume|install|help|pluginname)&l=(fr|dk|sk_src|...)[&c=1] Can only be run from localhost or 127.0.0.1
The script can only be run from a server on localhost or 127.0.0.1, this is to prevent abuse of it when uploaded on a public webserver.
The purpose of this script is to update the .lang files or to create a new one if you start a new localization. If you had to go through all the PHP files of PLUME CMS to look for strings to be translated, you would easily get mad very fast. This script is doing the ugly work for you.
How to use getlocale.php
We will consider that you want to do the translation in German. The iso code of German is de as German is Deutsch.
- Create the folder /manager/locale/de/.
- Run the script getlocale.php?w=plume&l=de (this is a lowercase L) it will create the file plume.lang in the folder.
- Run the script getlocale.php?w=install&l=de it will create the file install.lang in the folder.
Then for each plugin:
- Create the folder /manager/tools/myplugin/locale/de/.
- Run the script getlocale.php?w=myplugin&l=de it will create the file myplugin.lang in the folder.
You can start the localization...
Update an already existing .lang file
You can simply run again the getlocale.php script with the correct arguments. The script will keep the valid strings, add the new strings to be translated and put as comments at the end of the file the old strings not used anymore. The old .lang file is kept in backup as a .lang.back file. If a backup file exists no backup is made, this is to prevent the run twice effect.
The localization is not really a funny work, we try to provide the tools to help you as much as possible. Your feedback is really important so we can provide the best tools to help you in this process.
Conversion from a XX_src to XX
When you have .lang files and help files in a XX_src folder, you can convert them by running the same way getlocale.php but with the optional argument &c=1 it will create the XX folder and put the translations encoded in utf-8 in this folder.
Share your ideas about this article.


