Implementation of gettext translations
From Xibo
Contents |
Summary
The chosen method of translations in Xibo is gettext. By default the application will try to use PHP Gettext.
Implementation
Xibo will automatically detect gettext and set the locale. If there is a problem it will fail-safe to English.
Including the Xibo implementation
Any page that is not hosted within the Xibo application itself will need to include the Xibo translation classes. This can be done by including:
require_once("lib/app/translationengine.class.php");
The Translation class will also require access to a database object.
TranslationEngine::InitLocale($db);
Determine the Locale
The locale will be configured to check in 3 places for available locale information.
- The $_REQUEST
- The User table in the database - this will allow for a user to set their default language
- The Accept-Language header provided by the browser as a HTTP header
- Fail-safe to the English string
This is done automatically via the "Including the Xibo implementation" code.
Gettext Function
Gettext shall be called using
__("String to Translate")
PO Files
I am currently not sure how to best deal with PO files. Obviously they will need to be imported into Launchpad and should not be located inside your own personal branches.
More notes to follow on this.
Convention
It is always desirable to remove similar phrases to make translations as generic as possible. This will mostly be down to the English implementation

