Version 2 (modified by 16 years ago) (diff) | ,
---|
Writing translatable web pages
Translatable web pages must be PHP, and must include
require_once("../inc/translation.inc");
Literal text is replaced with tra("text")
. For example,
page_head("Current version");
is replaced with
page_head(tra("Current version"));
For BOINC projects, the directory html/languages/translations contains a number of 'translation files'. When a person accesses the page, the browser passes a list of languages. The BOINC PHP code finds the first of these languages for which a translation is available, or English if none. As the page is generated, each call to tr()
replaces the token with the corresponding translated text.
In developing web pages, keep in mind that word order differs between languages, so you should avoid breaking a sentence up into multiple translation units. For example, use constructs like
msgid "Already have an original 'Classic' account as of May 14, 2004?" "%1We've transferred it, just %2activate it%3. " "%4Otherwise %5create a new account%6." msgstr ""
with the corresponding PHP:
printf(tra("Already have an original 'Classic' account as of May 14, 2004? %1We've transferred it, just %2activate it%3. %4Otherwise %5create a new account%6."), "<br>", "<a href=\"sah_email_form.php\">", "</a>", "<p><img src=\"images/arrow_right.gif\">", "<a href=create_account_form.php>", "</a>" );
Project-specific translations
The web site of a BOINC-based project involves both
- BOINC pages, such as the forms for creating accounts. These are part of the BOINC source code distribution, and are updated periodically by BOINC.
- Project-specific pages (and BOINC pages that are modified by the project).
To allow translations of both types of pages, a project can have its own 'project-specific translation files'. These are stored in a directory html/user/project_specific_translations. Project-specific translation files override BOINC translation files.