mNo edit summary |
No edit summary |
||
Line 91: | Line 91: | ||
Create a new directory named po/<langcode>. For hindi I will write: | Create a new directory named po/<langcode>. For hindi I will write: | ||
< | <pre> | ||
mkdir po/hi/ | mkdir po/hi/ | ||
</ | </pre> | ||
.....editing on----- | .....editing on----- |
Revision as of 12:59, 27 April 2010
Author: Naveen Kumar
Internationalization (i18n) refers to an application's/package's support for multiple languages. This support comes from a kind of generalization on part of application/package that helps Localize it in different languages.
Localization or (l10n) here refers to the process of adapting, translating or customising that application/package for a particular locale.
Locale
is a term used to define a set of information corresponding to a given language & country. A locale
information is used by a software application (or operating system) to exhibit a localised behaviour. This localised behaviour is in the form of displaying Application's/package's text in local language or other things pertaining to a locale convention such as localized date, currency format, color conventions, etc.
In this tutorial we will cover i18n & l10n only with respect to text i18n/l10n.
Gettext framework is one such approach to do text i18n. It refers to a collection of tools which are used to internationalize and localize an application/package. Apart from internationalization of applications/packages these tools assist in translating the strings on menus, messages boxes or icons on the applications in the language that the user is interested in.
For a detailed information on text internationalization you can refer to Gettext manual
Development Environment
To internationalize an application we need a set of development tools. This is a one-time-only setup,
installed by running those commands from a system administration (root
) account:
yum install @development-tools yum groupinstall <langname>-support
The <langname> above refers to the name of your language. For hindi
I would write something like:
yum groupinstall hindi-support
Hello World
#include<stdio.h> int main() { printf("Hello World"); return 0; }
Internationalized Hello World
#include<libintl.h> #include<locale.h> #include<stdio.h> #define _(String) gettext (String) #define _t(String1,String2,n) ngettext (String1,String2,n) int main() { setlocale(LC_ALL,""); bindtextdomain("helloworld","/usr/share/locale"); textdomain("helloworld"); printf(_("Hello World")); return 0; }
Extract the strings in a POT (helloworld.pot) file using the following command
xgettext -d helloworld -o helloworld.pot --keyword=_t:1,2 -k_ -s helloworld.c
PO(T) files
helloworld.pot
# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2010-04-27 17:42+0530\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: helloworld.c:13 #, c-format msgid "Hello World" msgstr ""
Create a new directory named po/<langcode>. For hindi I will write:
mkdir po/hi/
.....editing on-----