| 1 | == Writing translatable web pages == |
| 2 | |
| 3 | Translatable web pages must be PHP, and must include |
| 4 | |
| 5 | {{{ |
| 6 | require_once("../inc/translation.inc"); |
| 7 | }}} |
| 8 | |
| 9 | Literal text is replaced with `tra("text")`. For example, |
| 10 | |
| 11 | {{{ |
| 12 | page_head("Current version"); |
| 13 | }}} |
| 14 | |
| 15 | is replaced with |
| 16 | |
| 17 | {{{ |
| 18 | page_head(tra("Current version")); |
| 19 | }}} |
| 20 | |
| 21 | For BOINC projects, the directory [source:trunk/boinc/html/languages/translations/ 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. |
| 22 | |
| 23 | 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 |
| 24 | |
| 25 | {{{ |
| 26 | msgid "Already have an original 'Classic' account as of May 14, 2004?" |
| 27 | "%1We've transferred it, just %2activate it%3. " |
| 28 | "%4Otherwise %5create a new account%6." |
| 29 | msgstr "" |
| 30 | }}} |
| 31 | |
| 32 | with the corresponding PHP: |
| 33 | |
| 34 | {{{ |
| 35 | 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."), |
| 36 | "<br>", "<a href=\"sah_email_form.php\">", "</a>", |
| 37 | "<p><img src=\"images/arrow_right.gif\">", |
| 38 | "<a href=create_account_form.php>", "</a>" |
| 39 | ); |
| 40 | }}} |
| 41 | |
| 42 | == Project-specific translations == |
| 43 | |
| 44 | The web site of a BOINC-based project involves both |
| 45 | |
| 46 | * BOINC pages, such as the forms for creating accounts. These are part of the BOINC source code distribution, and are updated periodically by BOINC. |
| 47 | * Project-specific pages (and BOINC pages that are modified by the project). |
| 48 | |
| 49 | To allow translations of both types of pages, a project can haves its own 'project-specific translation files'. These are stored in a directory [source:trunk/boinc/html/user/project_specific_translations html/user/project_specific_translations]. Project-specific translation files override BOINC translation files. |