Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / doc / gettext / tutorial.html
blob45e80ce5e8de2f2450a25ed31c3ac69f75e89f60
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML i18n//EN">
3 <!--Converted with jLaTeX2HTML 2002-2-1 (1.70) JA patch-1.4
4 patched version by: Kenshi Muto, Debian Project.
5 LaTeX2HTML 2002-2-1 (1.70),
6 original version by: Nikos Drakos, CBLU, University of Leeds
7 * revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
8 * with significant contributions from:
9 Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
10 <HTML>
11 <HEAD>
12 <TITLE>A tutorial on Native Language Support using GNU gettext</TITLE>
13 <META NAME="description" CONTENT="A tutorial on Native Language Support using GNU gettext">
14 <META NAME="keywords" CONTENT="memo">
15 <META NAME="resource-type" CONTENT="document">
16 <META NAME="distribution" CONTENT="global">
18 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
19 <META NAME="Generator" CONTENT="jLaTeX2HTML v2002-2-1 JA patch-1.4">
20 <META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
22 <!--
23 <LINK REL="STYLESHEET" HREF="memo.css">
24 -->
26 </HEAD>
28 <BODY >
30 <!--Navigation Panel
31 <DIV CLASS="navigation">
32 <IMG WIDTH="81" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next_inactive"
33 SRC="file:/usr/share/latex2html/icons/nx_grp_g.png">
34 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
35 SRC="file:/usr/share/latex2html/icons/up_g.png">
36 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
37 SRC="file:/usr/share/latex2html/icons/prev_g.png">
38 <BR>
39 <BR><BR></DIV>
40 End of Navigation Panel-->
42 <H1 ALIGN="CENTER">A tutorial on Native Language Support using GNU gettext</H1><DIV CLASS="author_info">
44 <P ALIGN="CENTER"><STRONG>G.&nbsp;Mohanty</STRONG></P>
45 <P ALIGN="CENTER"><STRONG>Revision 0.3: 24 July 2004</STRONG></P>
46 </DIV>
48 <H3>Abstract:</H3>
49 <DIV CLASS="ABSTRACT">
50 The use of the GNU <TT>gettext</TT> utilities to implement support for native
51 languages is described here. Though, the language to be supported is
52 considered to be Oriya, the method is generally applicable. Likewise, while
53 Linux was used as the platform here, any system using GNU <TT>gettext</TT> should work
54 in a similar fashion.
56 <P>
57 We go through a step-by-step description of how to make on-screen messages
58 from a toy program to appear in Oriya instead of English; starting from the
59 programming and ending with the user's viewpoint. Some discussion is also made
60 of how to go about the task of translation.
61 </DIV>
62 <P>
63 <H1><A NAME="SECTION00010000000000000000">
64 Introduction</A>
65 </H1>
66 Currently, both commercial and free computer software is typically written and
67 documented in English. Till recently, little effort was expended towards
68 allowing them to interact with the user in languages other than English, thus
69 leaving the non-English speaking world at a disadvantage. However, that
70 changed with the release of the GNU <TT>gettext</TT> utilities, and nowadays most GNU
71 programs are written within a framework that allows easy translation of the
72 program message to languages other than English. Provided that translations
73 are available, the language used by the program to interact with the user can
74 be set at the time of running it. <TT>gettext</TT> manages to achieve this seemingly
75 miraculous task in a manner that simplifies the work of both the programmer
76 and the translator, and, more importantly, allows them to work independently
77 of each other.
79 <P>
80 This article describes how to support native languages under a system using
81 the GNU <TT>gettext</TT> utilities. While it should be applicable to other versions of
82 <TT>gettext</TT>, the one actually used for the examples here is version
83 0.12.1. Another system, called <TT>catgets</TT>, described in the X/Open
84 Portability Guide, is also in use, but we shall not discuss that here.
86 <P>
88 <H1><A NAME="SECTION00020000000000000000">
89 A simple example</A>
90 </H1>
91 <A NAME="sec:simple"></A>Our first example of using <TT>gettext</TT> will be the good old Hello World program,
92 whose sole function is to print the phrase ``Hello, world!'' to the terminal.
93 The internationalized version of this program might be saved in hello.c as:
94 <PRE>
95 1 #include &lt;libintl.h&gt;
96 2 #include &lt;locale.h&gt;
97 3 #include &lt;stdio.h&gt;
98 4 #include &lt;stdlib.h&gt;
99 5 int main(void)
101 7 setlocale( LC_ALL, "" );
102 8 bindtextdomain( "hello", "/usr/share/locale" );
103 9 textdomain( "hello" );
104 10 printf( gettext( "Hello, world!\n" ) );
105 11 exit(0);
106 12 }
107 </PRE>
108 Of course, a real program would check the return values of the functions and
109 try to deal with any errors, but we have omitted that part of the code for
110 clarity. Compile as usual with <TT>gcc -o hello hello.c</TT>. The program should
111 be linked to the GNU libintl library, but as this is part of the GNU C
112 library, this is done automatically for you under Linux, and other systems
113 using glibc.
115 <H2><A NAME="SECTION00021000000000000000">
116 The programmer's viewpoint</A>
117 </H2>
118 As expected, when the <TT>hello</TT> executable is run under the default locale
119 (usually the C locale) it prints ``Hello, world!'' in the terminal. Besides
120 some initial setup work, the only additional burden faced by the programmer is
121 to replace any string to be printed with <TT>gettext(string)</TT>, i.e., to
122 instead pass the string as an argument to the <TT>gettext</TT> function. For lazy
123 people like myself, the amount of extra typing can be reduced even further by
124 a CPP macro, e.g., put this at the beginning of the source code file,
125 <PRE>
126 #define _(STRING) gettext(STRING)
127 </PRE>
128 and then use <TT>_(string)</TT> instead of <TT>gettext(string)</TT>.
131 Let us dissect the program line-by-line.
133 <OL>
134 <LI><TT>locale.h</TT> defines C data structures used to hold locale
135 information, and is needed by the <TT>setlocale</TT> function. <TT>libintl.h</TT>
136 prototypes the GNU text utilities functions, and is needed here by
137 <TT>bindtextdomain</TT>, <TT>gettext</TT>, and <TT>textdomain</TT>.
138 </LI>
139 <LI>The call to <TT>setlocale</TT> () on line 7, with LC_ALL as the first argument
140 and an empty string as the second one, initializes the entire current locale
141 of the program as per environment variables set by the user. In other words,
142 the program locale is initialized to match that of the user. For details see
143 ``man <TT>setlocale</TT>.''
144 </LI>
145 <LI>The <TT>bindtextdomain</TT> function on line 8 sets the base directory for the
146 message catalogs for a given message domain. A message domain is a set of
147 translatable messages, with every software package typically having its own
148 domain. Here, we have used ``hello'' as the name of the message domain for
149 our toy program. As the second argument, /usr/share/locale, is the default
150 system location for message catalogs, what we are saying here is that we are
151 going to place the message catalog in the default system directory. Thus, we
152 could have dispensed with the call to <TT>bindtextdomain</TT> here, and this
153 function is useful only if the message catalogs are installed in a
154 non-standard place, e.g., a packaged software distribution might have
155 the catalogs under a po/ directory under its own main directory. See ``man
156 <TT>bindtextdomain</TT>'' for details.
157 </LI>
158 <LI>The <TT>textdomain</TT> call on line 9 sets the message domain of the current
159 program to ``hello,'' i.e., the name that we are using for our example
160 program. ``man textdomain'' will give usage details for the function.
161 </LI>
162 <LI>Finally, on line 10, we have replaced what would normally have been,
163 <PRE>
164 printf( "Hello, world!\n" );
165 </PRE>
166 with,
167 <PRE>
168 printf( gettext( "Hello, world!\n" ) );
169 </PRE>
170 (If you are unfamiliar with C, the <!-- MATH
171 $\backslash$
173 <SPAN CLASS="MATH">&#92;</SPAN>n at the end of the string
174 produces a newline at the end of the output.) This simple modification to all
175 translatable strings allows the translator to work independently from the
176 programmer. <TT>gettextize</TT> eases the task of the programmer in adapting a
177 package to use GNU <TT>gettext</TT> for the first time, or to upgrade to a newer
178 version of <TT>gettext</TT>.
179 </LI>
180 </OL>
182 <H2><A NAME="SECTION00022000000000000000">
183 Extracting translatable strings</A>
184 </H2>
185 Now, it is time to extract the strings to be translated from the program
186 source code. This is achieved with <TT>xgettext</TT>, which can be invoked as follows:
187 <PRE><FONT color="red">
188 xgettext -d hello -o hello.pot hello.c
189 </FONT></PRE>
190 This processes the source code in hello.c, saving the output in hello.pot (the
191 argument to the -o option).
192 The message domain for the program should be specified as the argument
193 to the -d option, and should match the domain specified in the call to
194 <TT>textdomain</TT> (on line 9 of the program source). Other details on how to use
195 <TT>gettext</TT> can be found from ``man gettext.''
198 A .pot (portable object template) file is used as the basis for translating
199 program messages into any language. To start translation, one can simply copy
200 hello.pot to oriya.po (this preserves the template file for later translation
201 into a different language). However, the preferred way to do this is by
202 use of the <TT>msginit</TT> program, which takes care of correctly setting up some
203 default values,
204 <PRE><FONT color="red">
205 msginit -l or_IN -o oriya.po -i hello.pot
206 </FONT></PRE>
207 Here, the -l option defines the locale (an Oriya locale should have been
208 installed on your system), and the -i and -o options define the input and
209 output files, respectively. If there is only a single .pot file in the
210 directory, it will be used as the input file, and the -i option can be
211 omitted. For me, the oriya.po file produced by <TT>msginit</TT> would look like:
212 <PRE>
213 # Oriya translations for PACKAGE package.
214 # Copyright (C) 2004 THE PACKAGE'S COPYRIGHT HOLDER
215 # This file is distributed under the same license as the PACKAGE package.
216 # Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;, 2004.
218 msgid ""
219 msgstr ""
220 "Project-Id-Version: PACKAGE VERSION\n"
221 "Report-Msgid-Bugs-To: \n"
222 "POT-Creation-Date: 2004-06-22 02:22+0530\n"
223 "PO-Revision-Date: 2004-06-22 02:38+0530\n"
224 "Last-Translator: Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;\n"
225 "Language-Team: Oriya\n"
226 "MIME-Version: 1.0\n"
227 "Content-Type: text/plain; charset=UTF-8\n"
228 "Content-Transfer-Encoding: 8bit\n"
230 #: hello.c:10
231 msgid "Hello, world!\n"
232 msgstr ""
233 </PRE>
234 <TT>msginit</TT> prompted for my email address, and probably obtained my real name
235 from the system password file. It also filled in values such as the revision
236 date, language, character set, presumably using information from the or_IN
237 locale.
240 It is important to respect the format of the entries in the .po (portable
241 object) file. Each entry has the following structure:
242 <PRE>
243 WHITE-SPACE
244 # TRANSLATOR-COMMENTS
245 #. AUTOMATIC-COMMENTS
246 #: REFERENCE...
247 #, FLAG...
248 msgid UNTRANSLATED-STRING
249 msgstr TRANSLATED-STRING
250 </PRE>
251 where, the initial white-space (spaces, tabs, newlines,...), and all
252 comments might or might not exist for a particular entry. Comment lines start
253 with a '#' as the first character, and there are two kinds: (i) manually
254 added translator comments, that have some white-space immediately following the
255 '#,' and (ii) automatic comments added and maintained by the <TT>gettext</TT> tools,
256 with a non-white-space character after the '#.' The <TT>msgid</TT> line contains
257 the untranslated (English) string, if there is one for that PO file entry, and
258 the <TT>msgstr</TT> line is where the translated string is to be entered. More on
259 this later. For details on the format of PO files see gettext::Basics::PO
260 Files:: in the Emacs info-browser (see Appdx.&nbsp;<A HREF="#sec:emacs-info">A</A> for an
261 introduction to using the info-browser in Emacs).
263 <H2><A NAME="SECTION00023000000000000000">
264 Making translations</A>
265 </H2>
266 The oriya.po file can then be edited to add the translated Oriya
267 strings. While the editing can be carried out in any editor if one is careful
268 to follow the PO file format, there are several editors that ease the task of
269 editing PO files, among them being po-mode in Emacs, <TT>kbabel</TT>, gtranslator,
270 poedit, etc. Appdx.&nbsp;<A HREF="#sec:pofile-editors">B</A> describes features of some of
271 these editors.
274 The first thing to do is fill in the comments at the beginning and the header
275 entry, parts of which have already been filled in by <TT>msginit</TT>. The lines in
276 the header entry are pretty much self-explanatory, and details can be found in
277 the gettext::Creating::Header Entry:: info node. After that, the remaining
278 work consists of typing the Oriya text that is to serve as translations for
279 the corresponding English string. For the <TT>msgstr</TT> line in each of the
280 remaining entries, add the translated Oriya text between the double quotes;
281 the translation corresponding to the English phrase in the <TT>msgid</TT> string
282 for the entry. For example, for the phrase ``Hello world!<!-- MATH
283 $\backslash$
285 <SPAN CLASS="MATH">&#92;</SPAN>n'' in
286 oriya.po, we could enter ``&#x0b28;&#x0b2e;&#x0b38;&#x0b4d;&#x0b15;&#x0b3e;&#x0b30;<!-- MATH
287 $\backslash$
289 <SPAN CLASS="MATH">&#92;</SPAN>n''. The final
290 oriya.po file might look like:
291 <PRE>
292 # Oriya translations for hello example package.
293 # Copyright (C) 2004 Gora Mohanty
294 # This file is distributed under the same license as the hello example package.
295 # Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;, 2004.
297 msgid ""
298 msgstr ""
299 "Project-Id-Version: oriya\n"
300 "Report-Msgid-Bugs-To: \n"
301 "POT-Creation-Date: 2004-06-22 02:22+0530\n"
302 "PO-Revision-Date: 2004-06-22 10:54+0530\n"
303 "Last-Translator: Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;\n"
304 "Language-Team: Oriya\n"
305 "MIME-Version: 1.0\n"
306 "Content-Type: text/plain; charset=UTF-8\n"
307 "Content-Transfer-Encoding: 8bit\n"
308 "X-Generator: KBabel 1.3\n"
310 #: hello.c:10
311 msgid "Hello, world!\n"
312 msgstr "&#x0b28;&#x0b2e;&#x0b38;&#x0b4d;&#x0b15;&#x0b3e;&#x0b30;\n"
313 </PRE>
316 For editing PO files, I have found the <TT>kbabel</TT> editor suits me the best. The
317 only problem is that while Oriya text can be entered directly into <TT>kbabel</TT>
318 using the xkb Oriya keyboard layouts&nbsp;[<A
319 HREF="memo.html#xkb-oriya-layout">1</A>] and the entries
320 are saved properly, the text is not displayed correctly in the <TT>kbabel</TT> window
321 if it includes conjuncts. Emacs po-mode is a little restrictive, but strictly
322 enforces conformance with the PO file format. The main problem with it is that
323 it does not seem currently possible to edit Oriya text in Emacs. <TT>yudit</TT>
324 is the best at editing Oriya text, but does not ensure that the PO file format
325 is followed. You can play around a bit with these editors to find one that
326 suits your personal preferences. One possibility might be to first edit the
327 header entry with <TT>kbabel</TT> or Emacs po-mode, and then use <TT>yudit</TT> to enter
328 the Oriya text on the <TT>msgstr</TT> lines.
330 <H2><A NAME="SECTION00024000000000000000">
331 Message catalogs</A>
332 </H2>
333 <A NAME="sec:catalog"></A>After completing the translations in the oriya.po file, it must be compiled to
334 a binary format that can be quickly loaded by the <TT>gettext</TT> tools. To do that,
335 use:
336 <PRE><FONT color="red">
337 msgfmt -c -v -o hello.mo oriya.po
338 </FONT></PRE>
339 The -c option does detailed checking of the PO file format, -v makes the
340 program verbose, and the output filename is given by the argument to the -o
341 option. Note that the base of the output filename should match the message
342 domain given in the first arguments to <TT>bindtextdomain</TT> and <TT>textdomain</TT> on
343 lines 8 and 9 of the example program in Sec.&nbsp;<A HREF="#sec:simple">2</A>. The .mo
344 (machine object) file should be stored in the location whose base directory is
345 given by the second argument to <TT>bindtextdomain</TT>. The final location of the
346 file will be in the sub-directory LL/LC_MESSAGES or LL_CC/LC_MESSAGES under
347 the base directory, where LL stands for a language, and CC for a country. For
348 example, as we have chosen the standard location, /usr/share/locale, for our
349 base directory, and for us the language and country strings are ``or'' and
350 ``IN,'' respectively, we will place hello.mo in /usr/share/locale/or_IN. Note
351 that you will need super-user privilege to copy hello.mo to this system
352 directory. Thus,
353 <PRE><FONT color="red">
354 mkdir -p /usr/share/locale/or_IN/LC_MESSAGES
355 cp hello.mo /usr/share/locale/or_IN/LC_MESSAGES
356 </FONT></PRE>
358 <H2><A NAME="SECTION00025000000000000000">
359 The user's viewpoint</A>
360 </H2>
361 Once the message catalogs have been properly installed, any user on the system
362 can use the Oriya version of the Hello World program, provided an Oriya locale
363 is available. First, change your locale with,
364 <PRE><FONT color="red">
365 echo $LANG
366 export LANG=or_IN
367 </FONT></PRE>
368 The first statement shows you the current setting of your locale (this is
369 usually en_US, and you will need it to reset the default locale at the end),
370 while the second one sets it to an Oriya locale.
373 A Unicode-capable terminal emulator is needed to view Oriya output
374 directly. The new versions of both gnome-terminal and konsole (the KDE
375 terminal emulator) are Unicode-aware. I will focus on gnome-terminal as it
376 seems to have better support for internationalization. gnome-terminal needs to
377 be told that the bytes arriving are UTF-8 encoded multibyte sequences. This
378 can be done by (a) choosing Terminal <TT>-&gt;</TT> Character Coding <TT>-&gt;</TT>
379 Unicode (UTF-8), or (b) typing ``/bin/echo -n -e
380 '<!-- MATH
381 $\backslash$
383 <SPAN CLASS="MATH">&#92;</SPAN>033%<!-- MATH
384 $\backslash$
386 <SPAN CLASS="MATH">&#92;</SPAN>G''' in the terminal, or (c) by running
387 /bin/unicode_start. Likewise, you can revert to the default locale by (a)
388 choosing Terminal <TT>-&gt;</TT> Character Coding <TT>-&gt;</TT> Current Locale
389 (ISO-8859-1), or (b) ``/bin/echo -n -e '<!-- MATH
390 $\backslash$
392 <SPAN CLASS="MATH">&#92;</SPAN>033%<!-- MATH
393 $\backslash$
395 <SPAN CLASS="MATH">&#92;</SPAN>@','' or
396 (c) by running /bin/unicode_stop. Now, running the example program (after
397 compiling with gcc as described in Sec.&nbsp;<A HREF="#sec:simple">2</A>) with,
398 <PRE><FONT color="red">
399 ./hello
400 </FONT></PRE>
401 should give you output in Oriya. Please note that conjuncts will most likely
402 be displayed with a ``halant'' as the terminal probably does not render Indian
403 language fonts correctly. Also, as most terminal emulators assume fixed-width
404 fonts, the results are hardly likely to be aesthetically appealing.
407 An alternative is to save the program output in a file, and view it with
408 <TT>yudit</TT> which will render the glyphs correctly. Thus,
409 <PRE><FONT color="red">
410 ./hello &gt; junk
411 yudit junk
412 </FONT></PRE>
413 Do not forget to reset the locale before resuming usual work in the
414 terminal. Else, your English characters might look funny.
417 While all this should give the average user some pleasure in being able to see
418 Oriya output from a program without a whole lot of work, it should be kept in
419 mind that we are still far from our desired goal. Hopefully, one day the
420 situation will be such that rather than deriving special pleasure from it,
421 users take it for granted that Oriya should be available and are upset
422 otherwise.
426 <H1><A NAME="SECTION00030000000000000000">
427 Adding complications: program upgrade</A>
428 </H1>
429 The previous section presented a simple example of how Oriya language support
430 could be added to a C program. Like all programs, we might now wish to further
431 enhance it. For example, we could include a greeting to the user by adding
432 another <TT>printf</TT> statement after the first one. Our new hello.c source
433 code might look like this:
434 <PRE>
435 1 #include &lt;libintl.h&gt;
436 2 #include &lt;locale.h&gt;
437 3 #include &lt;stdio.h&gt;
438 4 #include &lt;stdlib.h&gt;
439 5 int main(void)
441 7 setlocale( LC_ALL, "" );
442 8 bindtextdomain( "hello", "/usr/share/locale" );
443 9 textdomain( "hello" );
444 10 printf( gettext( "Hello, world!\n" ) );
445 11 printf( gettext( "How are you\n" ) );
446 12 exit(0);
447 13 }
448 </PRE>
449 For such a small change, it would be simple enough to just repeat the above
450 cycle of extracting the relevant English text, translating it to Oriya, and
451 preparing a new message catalog. We can even simplify the work by cutting and
452 pasting most of the old oriya.po file into the new one. However, real programs
453 will have thousands of such strings, and we would like to be able to translate
454 only the changed strings, and have the <TT>gettext</TT> utilities handle the drudgery
455 of combining the new translations with the old ones. This is indeed possible.
457 <H2><A NAME="SECTION00031000000000000000">
458 Merging old and new translations</A>
459 </H2>
460 As before, extract the translatable strings from hello.c to a new portable
461 object template file, hello-new.pot, using <TT>xgettext</TT>,
462 <PRE><FONT color="red">
463 xgettext -d hello -o hello-new.pot hello.c
464 </FONT></PRE>
465 Now, we use a new program, <TT>msgmerge</TT>, to merge the existing .po file with
466 translations into the new template file, viz.,
467 <PRE><FONT color="red">
468 msgmerge -U oriya.po hello-new.pot
469 </FONT></PRE>
470 The -U option updates the existing
471 .po file, oriya.po. We could have chosen to instead create a new .po file by
472 using ``-o <SPAN CLASS="MATH">&lt;</SPAN>filename<SPAN CLASS="MATH">&gt;</SPAN>'' instead of -U. The updated .po file will still
473 have the old translations embedded in it, and new entries with untranslated
474 <TT>msgid</TT> lines. For us, the new lines in oriya.po will look like,
475 <PRE>
476 #: hello.c:11
477 msgid "How are you?\n"
478 msgstr ""
479 </PRE>
480 For the new translation, we could use, ``&#x0b06;&#x0b2a;&#x0b23;
481 &#x0b15;&#x0b3f;&#x0b2a;&#x0b30;&#x0b3f; &#x0b05;&#x0b1b;&#x0b28;&#x0b4d;&#x0b24;&#x0b3f;?'' in
482 place of the English phrase ``How are you?'' The updated oriya.po file,
483 including the translation might look like:
484 <PRE>
485 # Oriya translations for hello example package.
486 # Copyright (C) 2004 Gora Mohanty
487 # This file is distributed under the same license as the hello examplepackage.
488 # Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;, 2004.
490 msgid ""
491 msgstr ""
492 "Project-Id-Version: oriya\n"
493 "Report-Msgid-Bugs-To: \n"
494 "POT-Creation-Date: 2004-06-23 14:30+0530\n"
495 "PO-Revision-Date: 2004-06-22 10:54+0530\n"
496 "Last-Translator: Gora Mohanty &lt;gora_mohanty@yahoo.co.in&gt;\n"
497 "Language-Team: Oriya\n"
498 "MIME-Version: 1.0\n"
499 "Content-Type: text/plain; charset=UTF-8\n"
500 "Content-Transfer-Encoding: 8bit\n"
501 "X-Generator: KBabel 1.3\n"
503 #: hello.c:10
504 msgid "Hello, world!\n"
505 msgstr "&#x0b28;&#x0b2e;&#x0b38;&#x0b4d;&#x0b15;&#x0b3e;&#x0b30;\n"
507 #: hello.c:11
508 msgid "How are you?\n"
509 msgstr "&#x0b06;&#x0b2a;&#x0b23; &#x0b15;&#x0b3f;&#x0b2a;&#x0b30;&#x0b3f; &#x0b05;&#x0b1b;&#x0b28;&#x0b4d;&#x0b24;&#x0b3f;?\n"
510 </PRE>
513 Compile oriya.po to a machine object file, and install in the appropriate
514 place as in Sec.&nbsp;<A HREF="#sec:catalog">2.4</A>. Thus,
515 <PRE><FONT color="red">
516 msgfmt -c -v -o hello.mo oriya.po
517 mkdir -p /usr/share/locale/or_IN/LC_MESSAGES
518 cp hello.mo /usr/share/locale/or_IN/LC_MESSAGES
519 </FONT></PRE>
520 You can test the Oriya output as above, after recompiling hello.c and running
521 it in an Oriya locale.
525 <H1><A NAME="SECTION00040000000000000000">
526 More about <TT>gettext</TT> </A>
527 </H1>
528 The GNU <TT>gettext</TT> info pages provide a well-organized and complete description
529 of the <TT>gettext</TT> utilities and their usage for enabling Native Language
530 Support. One should, at the very least, read the introductory material at
531 gettext::Introduction::, and the suggested references in
532 gettext::Conclusion::References::. Besides the <TT>gettext</TT> utilities described in
533 this document, various other programs to manipulate .po files are discussed in
534 gettext:Manipulating::. Finally, support for programming languages other than
535 C/C++ is discussed in gettext::Programming Languages::.
539 <H1><A NAME="SECTION00050000000000000000">
540 The work of translation</A>
541 </H1>
542 Besides the obvious program message strings that have been the sole focus of
543 our discussion here, there are many other things that require translation,
544 including GUI messages, command-line option strings, configuration files,
545 program documentation, etc. Besides these obvious aspects, there are a
546 significant number of programs and/or scripts that are automatically generated
547 by other programs. These generated programs might also themselves require
548 translation. So, in any effort to provide support for a given native language,
549 carrying out the translation and keeping up with program updates becomes a
550 major part of the undertaking, requiring a continuing commitment from the
551 language team. A plan has been outlined for the Oriya localization
552 project&nbsp;[<A
553 HREF="memo.html#url:oriya-trans-plan">2</A>].
557 <H1><A NAME="SECTION00060000000000000000">
558 Acknowledgments</A>
559 </H1>
560 Extensive use has obviously been made of the GNU <TT>gettext</TT> manual in preparing
561 this document. I have also been helped by an article in the Linux
562 Journal&nbsp;[<A
563 HREF="memo.html#url:lj-translation">3</A>].
566 This work is part of the project for enabling the use of Oriya under Linux. I
567 thank my uncle, N.&nbsp;M.&nbsp;Pattnaik, for conceiving of the project. We have all
568 benefited from the discussions amidst the group of people working on this
569 project. On the particular issue of translation, the help of H.&nbsp;R.&nbsp;Pansari,
570 A.&nbsp;Nayak, and M.&nbsp;Chand is much appreciated.
572 <H1><A NAME="SECTION00070000000000000000">
573 The Emacs info browser</A>
574 </H1>
575 <A NAME="sec:emacs-info"></A>You can start up Emacs from the command-line by typing ``emacs,'' or ``emacs
576 <SPAN CLASS="MATH">&lt;</SPAN>filename<SPAN CLASS="MATH">&gt;</SPAN>.'' It can be started from the menu in some desktops, e.g., on
577 my GNOME desktop, it is under Main Menu <TT>-&gt;</TT> Programming <TT>-&gt;</TT>
578 Emacs. If you are unfamiliar with Emacs, a tutorial can be started by typing
579 ``C-h t'' in an Emacs window, or from the Help item in the menubar at the
580 top. Emacs makes extensive use of the Control (sometimes labelled as ``CTRL''
581 or ``CTL'') and Meta (sometimes labelled as ``Edit'' or ``Alt'') keys. In
582 Emacs parlance, a hyphenated sequence, such as ``C-h'' means to press the
583 Control and `h' key simultaneously, while ``C-h t'' would mean to press the
584 Control and `h' key together, release them, and press the `t' key. Similarly,
585 ``M-x'' is used to indicate that the Meta and `x' keys should be pressed at
586 the same time.
589 The info browser can be started by typing ``C-h i'' in Emacs. The first time
590 you do this, it will briefly list some commands available inside the info
591 browser, and present you with a menu of major topics. Each menu item, or
592 cross-reference is hyperlinked to the appropriate node, and you can visit that
593 node either by moving the cursor to the item and pressing Enter, or by
594 clicking on it with the middle mouse button. To get to the <TT>gettext</TT> menu items,
595 you can either scroll down to the line,
596 <PRE>
597 * gettext: (gettext). GNU gettext utilities.
598 </PRE>
599 and visit that node. Or, as it is several pages down, you can locate it using
600 ``I-search.'' Type ``C-s'' to enter ``I-search'' which will then prompt you
601 for a string in the mini-buffer at the bottom of the window. This is an
602 incremental search, so that Emacs will keep moving you forward through the
603 buffer as you are entering your search string. If you have reached the last
604 occurrence of the search string in the current buffer, you will get a message
605 saying ``Failing I-search: ...'' on pressing ``C-s.'' At that point, press
606 ``C-s'' again to resume the search at the beginning of the buffer. Likewise,
607 ``C-r'' incrementally searches backwards from the present location.
610 Info nodes are listed in this document with a ``::'' separator, so
611 that one can go to the gettext::Creating::Header Entry:: by visiting the
612 ``gettext'' node from the main info menu, navigating to the ``Creating''
613 node, and following that to the ``Header Entry'' node.
616 A stand-alone info browser, independent of Emacs, is also available on many
617 systems. Thus, the <TT>gettext</TT> info page can also be accessed by typing
618 ``info gettext'' in a terminal. <TT>xinfo</TT> is an X application serving as an
619 info browser, so that if it is installed, typing ``xinfo gettext'' from the
620 command line will open a new browser window with the <TT>gettext</TT> info page.
624 <H1><A NAME="SECTION00080000000000000000">
625 PO file editors</A>
626 </H1>
627 <A NAME="sec:pofile-editors"></A>While the <TT>yudit</TT> editor is adequate for our present purposes, and we are
628 planning on using that as it is platform-independent, and currently the best
629 at rendering Oriya. This section describes some features of some editors that
630 are specialized for editing PO files under Linux. This is still work in
631 progress, as I am in the process of trying out different editors before
632 settling on one. The ones considered here are: Emacs in po-mode, <TT>poedit</TT>,
633 <TT>kbabel</TT>, and <TT>gtranslator</TT>.
635 <H2><A NAME="SECTION00081000000000000000">
636 Emacs PO mode</A>
637 </H2>
638 Emacs should automatically enter po-mode when you load a .po file, as
639 indicated by ``PO'' in the modeline at the bottom. The window is made
640 read-only, so that you can edit the .po file only through special commands. A
641 description of Emacs po-mode can be found under the gettext::Basics info node,
642 or type `h' or `?' in a po-mode window for a list of available commands. While
643 I find Emacs po-mode quite restrictive, this is probably due to unfamiliarity
644 with it. Its main advantage is that it imposes rigid conformance to the PO
645 file format, and checks the file format when closing the .po file
646 buffer. Emacs po-mode is not useful for Oriya translation, as I know of no way
647 to directly enter Oriya text under Emacs.
649 <H2><A NAME="SECTION00082000000000000000">
650 poedit</A>
651 </H2>
652 XXX: in preparation.
654 <H2><A NAME="SECTION00083000000000000000">
655 KDE: the kbabel editor</A>
656 </H2>
657 <TT>kbabel</TT>&nbsp;[<A
658 HREF="memo.html#url:kbabel">4</A>] is a more user-friendly and configurable editor than
659 either of Emacs po-mode or <TT>poedit</TT>. It is integrated into KDE, and offers
660 extensive contextual help. Besides support for various PO file features, it
661 has a plugin framework for dictionaries, that allows consistency checks and
662 translation suggestions.
664 <H2><A NAME="SECTION00084000000000000000">
665 GNOME: the gtranslator editor</A>
666 </H2>
667 XXX: in preparation.
669 <H2><A NAME="SECTION00090000000000000000">
670 Bibliography</A>
671 </H2><DL COMPACT><DD><P></P><DT><A NAME="xkb-oriya-layout">1</A>
672 <DD>
673 G.&nbsp;Mohanty,
674 <BR>A practical primer for using Oriya under Linux, v0.3,
675 <BR><TT><A NAME="tex2html1"
676 HREF="http://oriya.sarovar.org/docs/getting_started/index.html">http://oriya.sarovar.org/docs/getting_started/index.html</A></TT>, 2004,
677 <BR>Sec.&nbsp;6.2 describes the xkb layouts for Oriya.
679 <P></P><DT><A NAME="url:oriya-trans-plan">2</A>
680 <DD>
681 G.&nbsp;Mohanty,
682 <BR>A plan for Oriya localization, v0.1,
683 <BR><TT><A NAME="tex2html2"
684 HREF="http://oriya.sarovar.org/docs/translation_plan/index.html">http://oriya.sarovar.org/docs/translation_plan/index.html</A></TT>,
685 2004.
687 <P></P><DT><A NAME="url:lj-translation">3</A>
688 <DD>
689 Linux Journal article on internationalization,
690 <BR><TT><A NAME="tex2html3"
691 HREF="http://www.linuxjournal.com/article.php?sid=3023">http://www.linuxjournal.com/article.php?sid=3023</A></TT>.
693 <P></P><DT><A NAME="url:kbabel">4</A>
694 <DD>
695 Features of the kbabel editor,
696 <BR><TT><A NAME="tex2html4"
697 HREF="http://i18n.kde.org/tools/kbabel/features.html">http://i18n.kde.org/tools/kbabel/features.html</A></TT>.
698 </DL>
700 <H1><A NAME="SECTION000100000000000000000">
701 About this document ...</A>
702 </H1>
703 <STRONG>A tutorial on Native Language Support using GNU gettext</STRONG><P>
704 This document was generated using the
705 <A HREF="http://www.latex2html.org/"><STRONG>LaTeX</STRONG>2<tt>HTML</tt></A> translator Version 2002-2-1 (1.70)
707 Copyright &#169; 1993, 1994, 1995, 1996,
708 <A HREF="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos Drakos</A>,
709 Computer Based Learning Unit, University of Leeds.
710 <BR>Copyright &#169; 1997, 1998, 1999,
711 <A HREF="http://www.maths.mq.edu.au/~ross/">Ross Moore</A>,
712 Mathematics Department, Macquarie University, Sydney.
714 The command line arguments were: <BR>
715 <STRONG>latex2html</STRONG> <TT>-no_math -html_version 4.0,math,unicode,i18n,tables -split 0 memo</TT>
717 The translation was initiated by Gora Mohanty on 2004-07-24
718 <DIV CLASS="navigation"><HR>
720 <!--Navigation Panel
721 <IMG WIDTH="81" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next_inactive"
722 SRC="file:/usr/share/latex2html/icons/nx_grp_g.png">
723 <IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up"
724 SRC="file:/usr/share/latex2html/icons/up_g.png">
725 <IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous"
726 SRC="file:/usr/share/latex2html/icons/prev_g.png">
727 <BR></DIV>
728 End of Navigation Panel-->
730 <ADDRESS>
731 Gora Mohanty
732 2004-07-24
733 </ADDRESS>
734 </BODY>
735 </HTML>