Upload
joe-turner
View
4.141
Download
0
Embed Size (px)
DESCRIPTION
A brief talk I gave to a small group of developers introducing GNU gettext and various localization topics.
Citation preview
GNU Internationalizationand localization
-Joe Turner
8 March 2007
04/10/23 - Joe Turner
Agenda• What is i18n, l10n, and a
locale?• Linux and l10n• The GNU process• Programmers’ View of the
Process• Translator’s View
04/10/23 - Joe Turner
Internationalization (i18n)• Internationalization is the process of planning and
implementing products and services so that they can easily be adapted to specific local languages and cultures, a process called localization.
• Internationalization comes in several variants:
– Monolingual internationalization - Enables the creation of localized versions of a product, where each localized version supports only its target locale. This is no longer sufficient for business requirements.
– Internationalization for multilocalization - Supports localization and data processing for multiple locales, where the actual locale is selected on execution of the product or at runtime.
– Multilingualization - Enables data processing and
display in multiple languages and locales simultaneously, for example, mixing Chinese and Arabic text in a single document.
04/10/23 - Joe Turner
Localization (L10n) • Localization is the process of adapting software for a
particular country or region; The adaptation of a product, application or document content to meet the language, cultural, and other requirements of a specific target market.
• Examples of Localization:
– Translation of the user interface and documentation into a different language.
– Altering some format fields in resource files according to the locale conventions, for example, changing a date format from mm/dd/yy to yy/mm/dd.
– Adding code modules that implement locale-specific functionality, such as an input method editor for Japanese or a module that calculates Hebrew calendar dates.
04/10/23 - Joe Turner
Locale• A locale is a set of parameters that defines the
user's language, country and cultural rules.• A locale is a specific geographical, political, or
cultural region. It is usually identified by a combination of language and country, for example, en_US represents the locale US English. – es is Spanish; es_MX is Mexican Spanish– pt is Portuguese, pt_BR is Brazilian Portuguese– en is English; en_US is US English
04/10/23 - Joe Turner
Linux and L10n• The Linux l10n software architecture is based on
the GNU “gettext” tool suite, together with a range of gettext compatible translator’s tools such as KBabel, PO-Edit, GTranslator and others.
• Gettext allows identifying translatable strings in the Linux source code and extracting them into a format suitable for KBabel and the other l10n tools. This l10n architecture is shared by the majority of open-source projects, forming the de-facto standard in open-source related l10n.
• The l10n “market” of gettext is organized as groups of volunteers from the target language countries. Most of these volunteers are university students who are using the software for their own purposes.
04/10/23 - Joe Turner
Linux l10n Process
04/10/23 - Joe Turner
Professional Translator
My_Application.mo
Java Sources
keys.pot
C++ Sources
es_MX.po fr.po pt_br.po en.po
xgettext
msgmerge
msgfmt
Linux l10n Process
04/10/23 - Joe Turner
GNU gettext• Included with glibc• Supports: C, C++, PHP, Java,
Others• Utilities:
– gettext– msgmerge– msgfmt
04/10/23 - Joe Turner
Users’ View
• $LANG environment variable points to native language:$ echo $LANG
en_US.UTF-8
• Applications set locale and pick up the translation files.
04/10/23 - Joe Turner
Where are the files?• gettext works by expecting a
locale directory where all of the translated strings are kept, in the following structure:
• /locale (/usr/share/locale)– /en <-language code
• /LC_MESSAGES • messages.po • messages.mo
04/10/23 - Joe Turner
Programmers’ Role
• Mark text that needs to be translated for each shared object
• Example:– #include <libintl.h>– printf(gettext(“temperature :%d\n”), temp);
04/10/23 - Joe Turner
Special Casesstatic const char *messages[] = {
"some very meaningful message", "and another one"
}; const char *string; ... string = index > 1 ? "a default message" :
messages[index]; fputs (string);
...
04/10/23 - Joe Turner
Special Cases#define gettext_noop(String) (String)
static const char *messages[] = { gettext_noop ("some very meaningful message"), gettext_noop ("and another one")
}; const char *string; ... string = index > 1 ? gettext ("a default message") :
gettext (messages[index]); fputs (string); ... }
04/10/23 - Joe Turner
Plural Forms• English:
– I have 1 apple. – I have 2 apples.
• C/English: if (n==1) printf(“I have %d apple.”, n)else printf (“I have %d apples.”, n);
• Other languages have multiple plural forms. Our solution: let the translator handle it. printf( ngettext(“I have %d apple.”, “I have %d apples.”, n), n);
04/10/23 - Joe Turner
Translators’ Role
• Translate the files and return them to us.
• Several free utilities to help
04/10/23 - Joe Turner
04/10/23 - Joe Turner
Java Support