22.07.2013 Views

Sausalito Developer's Guide - Parent Directory

Sausalito Developer's Guide - Parent Directory

Sausalito Developer's Guide - Parent Directory

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4—4 Chapter 4: Using i18n and l10n in <strong>Sausalito</strong><br />

Beta Draft 11. Copyright ' 2001.Cobalt Networks, Inc. All Rights Reserved.<br />

In summary, the grammar for a locale identifier is:<br />

locale_id := lang-code [ ’_’ country-code [ ’_’ variant-code ] ]<br />

where lang-code, country-code, and variant-code are all alphanumeric codes<br />

defined in ISO-639.<br />

Following are some example locale identifiers:<br />

¥ en: Generic english<br />

¥ en_US: English, American dialect<br />

¥ ja_JP_EUC: Japanese, as spoken in Japan, the EUC variant<br />

When the i18n library is initialized by an application, a comma-delimited list of locales is<br />

supplied to the i18n library. This list of locales indicates the various locales that the user can<br />

understand, in order of preference. The i18n library uses an intelligent algorithm to attempt<br />

to select the best available locale for each domain because not all domains support the same<br />

set of locales, for example: en_US or en, ja.<br />

How Strings Are Added to the System<br />

Using Interpolation<br />

Adding new strings to the system in a three-step process:<br />

1. A new .po file is created. This .po file defined all the message strings for one domain and<br />

one locale.<br />

2. The .po file is compiled into an .mo file using the msgfmt tool.<br />

3. The .mo file is placed in the appropriate directory beneath<br />

/usr/share/locale/locale/LC_MESSAGES.<br />

Whenever a string is fetched from the i18n library, it is subject to a process called<br />

interpolation. Interpolation allows user-supplied variables to be intelligently substituted into<br />

the string in various places. It also allows a string to contain references to other messages in<br />

the i18n database, with are expanded to full messages when interpolation occurs.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!