FtTemplate::getTranslate - jcobban/Genealogy GitHub Wiki
Up: class FtTemplate
This method returns a language-specific instance of class Template
which includes tables for translating from English and internal numeric codes to the language selected by the template name passed to the constructor for FtTemplate. These translation templates are kept in the templates library in files “Trantabll.html” where “ll” is the ISO 689-1 language code or a language code and qualifier as described in Internet Best Common Practices 47. The existing translate tables include:
-
Trantabde.html
for German -
Trantaben.html
for English -
Trantaben-US.html
for American English -
Trantabes.html
for Spanish -
Trantabfr.html
for French
Access to the translate table for the current context is obtained by:
$translate = $template->getTranslate();
There are a number of sub-tables in these templates:
-
$translate[‘Months’]
is an instance ofclass TemplateTag
that translates an ordinal month number into a 3-character month name abbreviations. For example$translate[‘Months’][3]
contains the abbreviation for the month of March in the target language. -
$translate[‘LMonths’]
is an instance ofclass TemplateTag
that translates an ordinal month number into a full month name. For example$translate[‘LMonths’][8]
contains the full name of the month of August in the target language. -
$translate['tranTab']
is an instance ofclass TemplateTag
which contains a translation between specific English words and phrases and the equivalent in the target language. For example$translate['tranTab']['before']
in the French version contains 'avant'. This table is typically saved in a variable$t
so that translating words or phrases can be represented by$t['word or phrase']
. -
$translate['srcTypes']
is an instance ofclass TemplateTag
containing the descriptions of the types of Source records corresponding to the values of 'idst' in an instance of class Source. -
$translate['typeText']
is an instance ofclass TemplateTag
containing the descriptions of the citation types corresponding to the values of 'cittype' in an instance of class Citation. For example$translate['typeText'][4]
in the French version contains 'Évenement de Mort'. -
$translate['eventText']
is an instance ofclass TemplateTag
that provides a translation from an event type to the text to display to the user corresponding to the values of 'idet' in an instance of class Event. -
$translate['idetTitleText']
is an instance ofclass TemplateTag
that provides a translation from an event type to the text to display to the user as the heading when editing an event, corresponding to the values of 'idet' in an instance of class Event. -
$translate['personEvents']
is an instance ofclass TemplateTag
that provides a translation from an event type to the text to display to the user in a selection list of event types, corresponding to the values of 'idet' in an instance of class Event. -
$translate['marriageEvents']
is an instance ofclass TemplateTag
containing the descriptions of the citation types corresponding to the values of 'cittype' in a Citation record for events relating to an instance of class Family. For example$translate['marriageEvents'][37]
in the French version contains 'Licence de Mariage'. -
$translate['cpRelType']
is an instance ofclass TemplateTag
that provides a translation from a child to parent relationship type to the text to display to the user corresponding to the values of 'idcpdad' and 'idcpmom' in an instance of class Child. -
$translate['idtdText']
is an instance ofclass TemplateTag
that provides a translation from a ToDo type to the text to display to the user corresponding to the value of 'idtd' in an instance of class ToDo. -
$translate['idtcText']
is an instance ofclass TemplateTag
that provides a translation from a ToDo document category to the text to display to the user corresponding to the value of 'idtc' in an instance of class ToDo.
For example:
$template = new FtTemplate("mypagede.html");
$translate = $template->getTranslate();
$t = $translate['tranTab']; // the main localization table
$months = $translate['Months']; // the month name abbreviations
print "<p>deleted -> " . $t['deleted'];
print "<p>Oct -> " . $months[10];
Displays
deleted -> gelöscht
Oct -> Okt