Translating Modules

Flexy templates can optionally be integrated with gettext, or in its absence, PEAR's File_Gettext - there's more details on this subject here:

However the recommended approach is to use the translate() method made available to templates which transforms source strings and translates them into the target language currently set to active in the session.

For example, if you have the string "Type of enquiry" in your template and you want Seagull to display the equivalent for your German users, you would code your template as follows:

<td>{translate(#Type of enquiry#)}</td>

passing the literal string as the argument to the translate method. Seagull will detect that the current language is set to 'de-iso-8859-1' for German, then scan for that string in the german-iso-8859-1.php translation file for that module, and replace it appropriately.

Obviously you can do the same for variables, take the example of $pageTitle which is set in every manager class.

<h1 class="pageTitle">{translate(pageTitle)}</h1>

In this case we'll presume you had set $this->pageTitle = 'Hello World', and that you had completed a French translation file with the line:

'Hello World' => 'Bonjour monde'

Now if you call the page as follows

note: the parameter is: ?lang=[language]-[charset]

You would dynamically switch into French mode, and all your translated strings would appear in the target language with tranlations you specified in the lang file, french-iso-8859-1.php.

The language-files are here:

  • module-specific: /modules/your-module-name/lang/
  • default: /modules/default/lang

If you want to start a new translation for Seagull, just copy the "english-iso-8859-1.php" in the lang-directory and rename it to "yourLanguage-<charset>.php". Then start translating. We use the ""phpMyAdmin"" convention for naming lang files, just ask the list if you don't have access to this source code.

Feel free to send us your work ;) See Code/SubmittingTranslations? for more info.

See Also