HTML Template Translation Tables - jcobban/Genealogy GitHub Wiki
Up: Home
Support for Internationalization requires the ability to translate words and phrases into the language of the client. Translation tables which are common to the entire application are contained in templates named "Trantab_ll_.html" where "ll" is an IETF BCP 47 language tag. For example the template "Trantabde.html" contains common translations for German. Translation tables which are specific to a page are contained within the templates for that page.
Each of these translation tables is available to application code as if it was an array.
Simple tables, which are indexed numerically, are used for functions such as translating a numeric month number into the name in the target language. For example:
<div id="LMonths">
<span></span> <!-- 0 -->
<span>Januar</span> <!-- 1 -->
<span>Februar</span>
<span>Marz</span>
<span>April</span>
<span>Mai</span>
<span>Juni</span>
<span>Juli</span>
<span>August</span>
<span>September</span>
<span>Oktober</span>
<span>November</span>
<span>Dezember</span>
</div> <!-- id="LMonths" -->
Can be used as follows:
$translate = $template->getTranslate();
$lmonths = $translate['LMonths'];
$july = $lmonths[7];
More complex translations utilize a user-defined attribute "data-key". In particular the table 'tranTab' is defined as the general translation between English words and phrases and their translation in the client's preferred language:
<!-- general I18N translate table -->
<div id="tranTab">
<span data-key=""></span>
...
<span data-key="brother">
Bruder
</span>
<span data-key="calculated as">
berechnet als
</span>
<span data-key="Cancelled">
abgebrochen
</span>
<span data-key="CE">
GĂ</span>
...
This common translation table is usually accessed as follows:
$translate = $template->getTranslate();
$t = $translate['tranTab'];
...
$malePronoun = $t['He'];
$femalePronoun = $t['She'];
$otherPronoun = $t['He/She'];
$maleChildRole = $t['son'];
$femaleChildRole = $t['daughter'];
$unknownChildRole = $t['child'];
Next: Help Page Guide