| ERW: The Manual | ||
|---|---|---|
| <<< Previous | Next >>> | |
All ERW strings can be easily localised using the GNU gettext package. It is a fairly standard way of giving translations of literal strings in various languages, and you can find documentation about it at the GNU site. Moreover, there is limited support for some locale-dependent quirks such as the decimal point.
There is also support for UTF-8, using the PHP mbstring extension.
Locales (country-specific languages) are specified in ERW as in RFC 2616 for the Accept-Language HTTP header, that is, a two-letter language code, a hyphen and a two-letter country code. Thus, it-IT is the Italian spoken in Italy, whereas en-UK is British English.
If you want to support some languages, you must specify them in the
$_ERW_supportedLocales
configuration variable. Then, for each language, you have to
provide a file that, for each string used in ERW, provides a
translation. An example of such a file for Italian is given in the file
ERW.it.po that comes with the distribution. You
should write a similar file for your language (and possibly send it to me), compile it using the
msgfmt utility coming with
gettext, and finally installing the resulting
ERW.mo file in the proper directory (e.g.,
it/LC_MESSAGES for Italian) inside the path
specified by the $_ERW_localePath configuration
variable. Then, ERW will fetch from the browser the preferred
language and try to match it with one of those supported. You can also
set a default locale (instead of en-US) or a fixed
locale (see the Chapter called Installation and Configuration).
The translation file above accounts for all strings built into
ERW. However, you may want to translate other parts of the user
interface, such as labels, enumerative types and help attributes. This is
possible simply by creating translation files named
ERW-id-labels,
ERW-id-displays,
ERW-id-enums and
ERW-id-help, where
id is the identifier of the root element of
your ERL file (e.g., "library" in our main example). These files should
contain translations for all labels, display customisation strings,
enumerative-type labels and help text (i.e., content of help attributes), respectively.
The translation files are usually derived from templates produced by ERtool (as it happens with templates produced by xgettext). Note that gettext offers several utilities that makes translations much easier (automatic compendia, comparison of translation and template files, and so on).
| <<< Previous | Home | Next >>> |
| JavaScript Functions | Other Localisation Variables |