Act was developed from the beginning to support multilingual conferences. When an organizer starts a conference, they just have to decide which languages will be supported. This usually includes at least English and their own language.
If your language is not yet supported by Act, don't panic. That just means you'll have to help us translate all the localized strings used by Act.
Multilingual templates are set up directly in the HTML, with the help
of the special tag <t> ... </t>
.
find templates -type f | xargs grep -c '<t>' |grep -v :0
Will list the template files that contain the <t>
tag.
Here's a very simple example:
<t> <en>Welcome to the YAPC::Europe web site!</en> <pt>Boa vinda no web site de YAPC::Europe!</pt> <fr>Bienvenue sur le site de YAPC::Europe !</fr> <de>Willkommen auf der YAPC::Europe web site!</de> <it>Benvenuto sul Web site di YAPC::Europe!</it> </t>
You'll also have to add the languages you need to all your specific static pages.
This is specific to each conference "static" templates and doesn't require any addition to the Act core.
The following sections apply to adding a new language to Act iself.
All localized strings used by Act are stored in po/*.po files, one
file per language. A .po file is a simple text file which contains
a list of strings. Each string has an identifier (msgid
),
and the localized string itself (msgstr
). Here's an example
from the French lexicon fr.po:
msgid "City" msgstr "Ville"
Usually the identifier is the English version of the string.
.po files are in UTF-8 encoding.
Most strings are used by HTML templates. In those strings,
any embedded occurences of the characters >
, <
and &
must be replaced by the corresponding HTML entity
(>
, <
and &
).
Some strings take parameters:
msgid "To register to the <name> conference" msgstr "" "To register to the %1 conference,\n" "simply push the button below.\n"
The parameters are simply numbered so that the order in which they
are output can change between translations (this is better than
printf()
).
msgid "Congratulations, you are now registered" msgstr "" "Congratulations, <b>%1</b>, you are now registered.\n" "Your password is <b>%2</b> .\n"
Since localization is actually handled by Locale::Maketext
,
it can handle plurals very easily:
msgid "There are n registered people" msgstr "" "There are %1 registered people\n" "coming from %quant(%2,country,countries)\n" "and %quant(%3,monger group).\n" "There are %4 committed users,\n" "that is to say, people that either paid their\n" "conference ticket or will give a talk.\n"
Act core template do not and should not ever contain text in any language other than HTML and TT2. Localization is achieved by replacing all human-readable text by special strings:
Here's an example from templates/core/user/register:
[% IF date.now > end_date %] <p> {{Sorry, this conference is over.}} </p> [% ELSE %] <p> [% loc('To register to the <name> conference', global.conference.name) %] </p> ... [% END %]
The first string ({{Sorry, this conference is over.}}
) is "static" text.
The text between double curly braces is a msgid
and it will be replaced
by the corresponding text in the .po file for the requested language.
The loc()
macro in the template is used for localized strings that take
parameters.
The Act::Util module contains some information about how dates are handled in each supported language. The structure needs to be updated for any new language.
Here's the structure for English:
en => { name => 'English', fmt_datetime_full => '%A %B %e, %Y %H:%M', fmt_datetime_short => '%m/%d/%y %H:%M', fmt_date_full => '%A %B %e, %Y', fmt_date_short => '%m/%d/%y', fmt_time => '%H:%M', },
The name
value is the name of the language, in that language.
The date and time formats use strftime()
compatible specifiers,
see http://search.cpan.org/perldoc?DateTime#strftime_Specifiers
for a complete list.