Principles GPT logo

GPT uses its own translation system because using gettext would raise several technical issues. Every installed language is contained in a separate file containing all strings, either to translate or already translated.

These files are located in the lang/ subdirectory of GPT, each of them being named after the two letter international code of the language they represent, plus a .php extension. I.e French translation file should be named fr.php and British translation file should be named en.php (note that this is just a convention and it is possible to name the files differently).

Obtaining a translation file

There is two ways to get an empty translation file:

  1. Point your browser to http://domain.org/gpt/admin/ (assuming this is where you installed GPT) and click on the "Languages" entry. Then, either select your language by clicking on the associated "Download updated" link or do that on the English language if your language does not exist yet.
  2. Unpack the GPT distribution (you can grab it at the Gna project page of GPT) and use the lang/en.php file as a template.

In any case, the first lines of the file should look like the following :

<?php

// Language file for GPT
// Updated by benj on 2009-02-20 16:33:40

$lang = Array ( 

	// In files editer_initiative.tpl
	'Editing initiative %s' => '',

	// In files editer_initiative.tpl
	'Editing initiative' => '',

	...

Doing the translation

You should open the translation file in any convenient text editor of your preference. Every translation string is constitued of a key associated with a value. The key is the original string and the value is the translated version.

For instance, in the following example, Registration done is the original English string and Inscription effectuée is the French version.

	'Registration done' => 'Instription effectuée',

So to translate, you just have to insert your translations between the two quotes. It is as simple as filling a form!

The %s keyword

In some cases, you will notice the presence of a %s or %d keyword in the translation file. They both are special keywords used to insert dynamical content in the translation. For instance, if we want to display a translatable sentence to count the number of signatories, we would create a translation string like this :

	'There are %d signatories of the pact' => '',

So you would just have to translate it and use the %d keyword at the right place in your translation (next example is in French):

	'There are %d signatories of the pact' => 'Il y a %d signataires du pacte',

Testing the translation

Once you have translated some sentences, you may want to test your translation. That is not difficult, you just have to

  1. put your newly translated file in the lang/ subdirectory of the GPT installation
  2. declare it in the translated languages

To put your file in the GPT installation, either copy it to your webserver path either locally if you have installed GPT locally on your computer or transfer it with your FTP or SCP client at the right place, using the same procedure as when you installed GPT first.

Be sure to name it after the language and use the .php extension for your translation file. I.e. the Italian translation should be named lang/it.php.

Then, to declare the language, open the include/options.php file of your GPT installation and search for the language paragraph, which should look like:

// Languages
$langs = Array ( Array ( 'id' => 'fr',
			 'name' => 'Français' ),
		 Array ( 'id' => 'en',
			 'name' => 'English' ),
		 Array ( 'id' => 'nl',
			 'name' => 'Nederlands' ),
//		 Array ( 'id' => 'xx',
//			 'name' => 'Your language' ),
);

Then, uncomment the last entry (remove the two slashes on both lines) and replace xx with your national language code (this should be exactly the name of the file, i.e. it for the Italian translation). Replace the full name (Your language in the template) with the full name of your language. You can also remove declaration of other languages if that does not suit your needs or translate their names to your language if you prefer.

Problems?

If you encounter any problem doing the translation, don't hesitate to drop us a line at gpt-support@gna.org. We would be glad to help you and answer any technical problem.

Contributing the translation

If you want your translation to be included into GPT, please let us know by sending a mail to gpt-dev@gna.org.

Special considerations

Election name

GPT can also translate the election name, which is needed for multi-language instances of GPT (and which could be useful in countries like Belgium or Switzerland). The language file should automatically contain an entry for the election name if you update it after having configured GPT. If it is not the case, update your language file.

You now just have to normally translate the name into your language. For instance, if you set the election name to Presidential election 2009, you would translate it like that :

	// In files global configuration file
	'Presidential election 2009' => 'Élection présidentielle 2009',

Constituencies name

The name of constituencies can be translated as well with the same mechanism.