1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML i18n//EN"> 2 3<!--Converted with jLaTeX2HTML 2002-2-1 (1.70) JA patch-1.4 4patched version by: Kenshi Muto, Debian Project. 5LaTeX2HTML 2002-2-1 (1.70), 6original 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"> 17 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"> 21 22<!-- 23<LINK REL="STYLESHEET" HREF="memo.css"> 24--> 25 26</HEAD> 27 28<BODY > 29 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> 40End of Navigation Panel--> 41 42<H1 ALIGN="CENTER">A tutorial on Native Language Support using GNU gettext</H1><DIV CLASS="author_info"> 43 44<P ALIGN="CENTER"><STRONG>G. Mohanty</STRONG></P> 45<P ALIGN="CENTER"><STRONG>Revision 0.3: 24 July 2004</STRONG></P> 46</DIV> 47 48<H3>Abstract:</H3> 49<DIV CLASS="ABSTRACT"> 50 The use of the GNU <TT>gettext</TT> utilities to implement support for native 51languages is described here. Though, the language to be supported is 52considered to be Oriya, the method is generally applicable. Likewise, while 53Linux was used as the platform here, any system using GNU <TT>gettext</TT> should work 54in a similar fashion. 55 56<P> 57We go through a step-by-step description of how to make on-screen messages 58from a toy program to appear in Oriya instead of English; starting from the 59programming and ending with the user's viewpoint. Some discussion is also made 60of how to go about the task of translation. 61</DIV> 62<P> 63<H1><A NAME="SECTION00010000000000000000"> 64Introduction</A> 65</H1> 66Currently, both commercial and free computer software is typically written and 67documented in English. Till recently, little effort was expended towards 68allowing them to interact with the user in languages other than English, thus 69leaving the non-English speaking world at a disadvantage. However, that 70changed with the release of the GNU <TT>gettext</TT> utilities, and nowadays most GNU 71programs are written within a framework that allows easy translation of the 72program message to languages other than English. Provided that translations 73are available, the language used by the program to interact with the user can 74be set at the time of running it. <TT>gettext</TT> manages to achieve this seemingly 75miraculous task in a manner that simplifies the work of both the programmer 76and the translator, and, more importantly, allows them to work independently 77of each other. 78 79<P> 80This article describes how to support native languages under a system using 81the 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 830.12.1. Another system, called <TT>catgets</TT>, described in the X/Open 84Portability Guide, is also in use, but we shall not discuss that here. 85 86<P> 87 88<H1><A NAME="SECTION00020000000000000000"> 89A 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, 92whose sole function is to print the phrase ``Hello, world!'' to the terminal. 93The internationalized version of this program might be saved in hello.c as: 94<PRE> 951 #include <libintl.h> 962 #include <locale.h> 973 #include <stdio.h> 984 #include <stdlib.h> 995 int main(void) 1006 { 1017 setlocale( LC_ALL, "" ); 1028 bindtextdomain( "hello", "/usr/share/locale" ); 1039 textdomain( "hello" ); 10410 printf( gettext( "Hello, world!\n" ) ); 10511 exit(0); 10612 } 107</PRE> 108Of course, a real program would check the return values of the functions and 109try to deal with any errors, but we have omitted that part of the code for 110clarity. Compile as usual with <TT>gcc -o hello hello.c</TT>. The program should 111be linked to the GNU libintl library, but as this is part of the GNU C 112library, this is done automatically for you under Linux, and other systems 113using glibc. 114 115<H2><A NAME="SECTION00021000000000000000"> 116The 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 120some initial setup work, the only additional burden faced by the programmer is 121to replace any string to be printed with <TT>gettext(string)</TT>, i.e., to 122instead pass the string as an argument to the <TT>gettext</TT> function. For lazy 123people like myself, the amount of extra typing can be reduced even further by 124a CPP macro, e.g., put this at the beginning of the source code file, 125<PRE> 126 #define _(STRING) gettext(STRING) 127</PRE> 128and then use <TT>_(string)</TT> instead of <TT>gettext(string)</TT>. 129 130<P> 131Let us dissect the program line-by-line. 132 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> 166with, 167<PRE> 168 printf( gettext( "Hello, world!\n" ) ); 169</PRE> 170(If you are unfamiliar with C, the <!-- MATH 171 $\backslash$ 172 --> 173<SPAN CLASS="MATH">\</SPAN>n at the end of the string 174produces a newline at the end of the output.) This simple modification to all 175translatable strings allows the translator to work independently from the 176programmer. <TT>gettextize</TT> eases the task of the programmer in adapting a 177package to use GNU <TT>gettext</TT> for the first time, or to upgrade to a newer 178version of <TT>gettext</TT>. 179</LI> 180</OL> 181 182<H2><A NAME="SECTION00022000000000000000"> 183Extracting translatable strings</A> 184</H2> 185 Now, it is time to extract the strings to be translated from the program 186source 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> 190This processes the source code in hello.c, saving the output in hello.pot (the 191argument to the -o option). 192The message domain for the program should be specified as the argument 193to 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.'' 196 197<P> 198A .pot (portable object template) file is used as the basis for translating 199program messages into any language. To start translation, one can simply copy 200hello.pot to oriya.po (this preserves the template file for later translation 201into a different language). However, the preferred way to do this is by 202use of the <TT>msginit</TT> program, which takes care of correctly setting up some 203default values, 204<PRE><FONT color="red"> 205 msginit -l or_IN -o oriya.po -i hello.pot 206</FONT></PRE> 207Here, the -l option defines the locale (an Oriya locale should have been 208installed on your system), and the -i and -o options define the input and 209output files, respectively. If there is only a single .pot file in the 210directory, it will be used as the input file, and the -i option can be 211omitted. 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 <gora_mohanty@yahoo.co.in>, 2004. 217 # 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 <gora_mohanty@yahoo.co.in>\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" 229 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 235from the system password file. It also filled in values such as the revision 236date, language, character set, presumably using information from the or_IN 237locale. 238 239<P> 240It is important to respect the format of the entries in the .po (portable 241object) 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> 251where, the initial white-space (spaces, tabs, newlines,...), and all 252comments might or might not exist for a particular entry. Comment lines start 253with a '#' as the first character, and there are two kinds: (i) manually 254added translator comments, that have some white-space immediately following the 255'#,' and (ii) automatic comments added and maintained by the <TT>gettext</TT> tools, 256with a non-white-space character after the '#.' The <TT>msgid</TT> line contains 257the untranslated (English) string, if there is one for that PO file entry, and 258the <TT>msgstr</TT> line is where the translated string is to be entered. More on 259this later. For details on the format of PO files see gettext::Basics::PO 260Files:: in the Emacs info-browser (see Appdx. <A HREF="#sec:emacs-info">A</A> for an 261introduction to using the info-browser in Emacs). 262 263<H2><A NAME="SECTION00023000000000000000"> 264Making translations</A> 265</H2> 266 The oriya.po file can then be edited to add the translated Oriya 267strings. While the editing can be carried out in any editor if one is careful 268to follow the PO file format, there are several editors that ease the task of 269editing PO files, among them being po-mode in Emacs, <TT>kbabel</TT>, gtranslator, 270poedit, etc. Appdx. <A HREF="#sec:pofile-editors">B</A> describes features of some of 271these editors. 272 273<P> 274The first thing to do is fill in the comments at the beginning and the header 275entry, parts of which have already been filled in by <TT>msginit</TT>. The lines in 276the header entry are pretty much self-explanatory, and details can be found in 277the gettext::Creating::Header Entry:: info node. After that, the remaining 278work consists of typing the Oriya text that is to serve as translations for 279the corresponding English string. For the <TT>msgstr</TT> line in each of the 280remaining entries, add the translated Oriya text between the double quotes; 281the translation corresponding to the English phrase in the <TT>msgid</TT> string 282for the entry. For example, for the phrase ``Hello world!<!-- MATH 283 $\backslash$ 284 --> 285<SPAN CLASS="MATH">\</SPAN>n'' in 286oriya.po, we could enter ``ନମସ୍କାର<!-- MATH 287 $\backslash$ 288 --> 289<SPAN CLASS="MATH">\</SPAN>n''. The final 290oriya.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 <gora_mohanty@yahoo.co.in>, 2004. 296 # 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 <gora_mohanty@yahoo.co.in>\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" 309 310 #: hello.c:10 311 msgid "Hello, world!\n" 312 msgstr "ନମସ୍କାର\n" 313</PRE> 314 315<P> 316For editing PO files, I have found the <TT>kbabel</TT> editor suits me the best. The 317only problem is that while Oriya text can be entered directly into <TT>kbabel</TT> 318using the xkb Oriya keyboard layouts [<A 319 HREF="memo.html#xkb-oriya-layout">1</A>] and the entries 320are saved properly, the text is not displayed correctly in the <TT>kbabel</TT> window 321if it includes conjuncts. Emacs po-mode is a little restrictive, but strictly 322enforces conformance with the PO file format. The main problem with it is that 323it does not seem currently possible to edit Oriya text in Emacs. <TT>yudit</TT> 324is the best at editing Oriya text, but does not ensure that the PO file format 325is followed. You can play around a bit with these editors to find one that 326suits your personal preferences. One possibility might be to first edit the 327header entry with <TT>kbabel</TT> or Emacs po-mode, and then use <TT>yudit</TT> to enter 328the Oriya text on the <TT>msgstr</TT> lines. 329 330<H2><A NAME="SECTION00024000000000000000"> 331Message catalogs</A> 332</H2> 333 <A NAME="sec:catalog"></A>After completing the translations in the oriya.po file, it must be compiled to 334a binary format that can be quickly loaded by the <TT>gettext</TT> tools. To do that, 335use: 336<PRE><FONT color="red"> 337 msgfmt -c -v -o hello.mo oriya.po 338</FONT></PRE> 339The -c option does detailed checking of the PO file format, -v makes the 340program verbose, and the output filename is given by the argument to the -o 341option. Note that the base of the output filename should match the message 342domain given in the first arguments to <TT>bindtextdomain</TT> and <TT>textdomain</TT> on 343lines 8 and 9 of the example program in Sec. <A HREF="#sec:simple">2</A>. The .mo 344(machine object) file should be stored in the location whose base directory is 345given by the second argument to <TT>bindtextdomain</TT>. The final location of the 346file will be in the sub-directory LL/LC_MESSAGES or LL_CC/LC_MESSAGES under 347the base directory, where LL stands for a language, and CC for a country. For 348example, as we have chosen the standard location, /usr/share/locale, for our 349base 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 351that you will need super-user privilege to copy hello.mo to this system 352directory. 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> 357 358<H2><A NAME="SECTION00025000000000000000"> 359The user's viewpoint</A> 360</H2> 361 Once the message catalogs have been properly installed, any user on the system 362can use the Oriya version of the Hello World program, provided an Oriya locale 363is available. First, change your locale with, 364<PRE><FONT color="red"> 365 echo $LANG 366 export LANG=or_IN 367</FONT></PRE> 368The first statement shows you the current setting of your locale (this is 369usually en_US, and you will need it to reset the default locale at the end), 370while the second one sets it to an Oriya locale. 371 372<P> 373A Unicode-capable terminal emulator is needed to view Oriya output 374directly. The new versions of both gnome-terminal and konsole (the KDE 375terminal emulator) are Unicode-aware. I will focus on gnome-terminal as it 376seems to have better support for internationalization. gnome-terminal needs to 377be told that the bytes arriving are UTF-8 encoded multibyte sequences. This 378can be done by (a) choosing Terminal <TT>-></TT> Character Coding <TT>-></TT> 379Unicode (UTF-8), or (b) typing ``/bin/echo -n -e 380'<!-- MATH 381 $\backslash$ 382 --> 383<SPAN CLASS="MATH">\</SPAN>033%<!-- MATH 384 $\backslash$ 385 --> 386<SPAN CLASS="MATH">\</SPAN>G''' in the terminal, or (c) by running 387/bin/unicode_start. Likewise, you can revert to the default locale by (a) 388choosing Terminal <TT>-></TT> Character Coding <TT>-></TT> Current Locale 389(ISO-8859-1), or (b) ``/bin/echo -n -e '<!-- MATH 390 $\backslash$ 391 --> 392<SPAN CLASS="MATH">\</SPAN>033%<!-- MATH 393 $\backslash$ 394 --> 395<SPAN CLASS="MATH">\</SPAN>@','' or 396(c) by running /bin/unicode_stop. Now, running the example program (after 397compiling with gcc as described in Sec. <A HREF="#sec:simple">2</A>) with, 398<PRE><FONT color="red"> 399 ./hello 400</FONT></PRE> 401should give you output in Oriya. Please note that conjuncts will most likely 402be displayed with a ``halant'' as the terminal probably does not render Indian 403language fonts correctly. Also, as most terminal emulators assume fixed-width 404fonts, the results are hardly likely to be aesthetically appealing. 405 406<P> 407An 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 > junk 411 yudit junk 412</FONT></PRE> 413Do not forget to reset the locale before resuming usual work in the 414terminal. Else, your English characters might look funny. 415 416<P> 417While all this should give the average user some pleasure in being able to see 418Oriya output from a program without a whole lot of work, it should be kept in 419mind that we are still far from our desired goal. Hopefully, one day the 420situation will be such that rather than deriving special pleasure from it, 421users take it for granted that Oriya should be available and are upset 422otherwise. 423 424<P> 425 426<H1><A NAME="SECTION00030000000000000000"> 427Adding complications: program upgrade</A> 428</H1> 429The previous section presented a simple example of how Oriya language support 430could be added to a C program. Like all programs, we might now wish to further 431enhance it. For example, we could include a greeting to the user by adding 432another <TT>printf</TT> statement after the first one. Our new hello.c source 433code might look like this: 434<PRE> 4351 #include <libintl.h> 4362 #include <locale.h> 4373 #include <stdio.h> 4384 #include <stdlib.h> 4395 int main(void) 4406 { 4417 setlocale( LC_ALL, "" ); 4428 bindtextdomain( "hello", "/usr/share/locale" ); 4439 textdomain( "hello" ); 44410 printf( gettext( "Hello, world!\n" ) ); 44511 printf( gettext( "How are you\n" ) ); 44612 exit(0); 44713 } 448</PRE> 449For such a small change, it would be simple enough to just repeat the above 450cycle of extracting the relevant English text, translating it to Oriya, and 451preparing a new message catalog. We can even simplify the work by cutting and 452pasting most of the old oriya.po file into the new one. However, real programs 453will have thousands of such strings, and we would like to be able to translate 454only the changed strings, and have the <TT>gettext</TT> utilities handle the drudgery 455of combining the new translations with the old ones. This is indeed possible. 456 457<H2><A NAME="SECTION00031000000000000000"> 458Merging old and new translations</A> 459</H2> 460 As before, extract the translatable strings from hello.c to a new portable 461object 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> 465Now, we use a new program, <TT>msgmerge</TT>, to merge the existing .po file with 466translations into the new template file, viz., 467<PRE><FONT color="red"> 468 msgmerge -U oriya.po hello-new.pot 469</FONT></PRE> 470The -U option updates the existing 471.po file, oriya.po. We could have chosen to instead create a new .po file by 472using ``-o <SPAN CLASS="MATH"><</SPAN>filename<SPAN CLASS="MATH">></SPAN>'' instead of -U. The updated .po file will still 473have 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> 480For the new translation, we could use, ``ଆପଣ 481କିପରି ଅଛନ୍ତି?'' in 482place of the English phrase ``How are you?'' The updated oriya.po file, 483including 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 <gora_mohanty@yahoo.co.in>, 2004. 489 # 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 <gora_mohanty@yahoo.co.in>\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" 502 503 #: hello.c:10 504 msgid "Hello, world!\n" 505 msgstr "ନମସ୍କାର\n" 506 507 #: hello.c:11 508 msgid "How are you?\n" 509 msgstr "ଆପଣ କିପରି ଅଛନ୍ତି?\n" 510</PRE> 511 512<P> 513Compile oriya.po to a machine object file, and install in the appropriate 514place as in Sec. <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> 520You can test the Oriya output as above, after recompiling hello.c and running 521it in an Oriya locale. 522 523<P> 524 525<H1><A NAME="SECTION00040000000000000000"> 526More about <TT>gettext</TT> </A> 527</H1> 528The GNU <TT>gettext</TT> info pages provide a well-organized and complete description 529of the <TT>gettext</TT> utilities and their usage for enabling Native Language 530Support. One should, at the very least, read the introductory material at 531gettext::Introduction::, and the suggested references in 532gettext::Conclusion::References::. Besides the <TT>gettext</TT> utilities described in 533this document, various other programs to manipulate .po files are discussed in 534gettext:Manipulating::. Finally, support for programming languages other than 535C/C++ is discussed in gettext::Programming Languages::. 536 537<P> 538 539<H1><A NAME="SECTION00050000000000000000"> 540The work of translation</A> 541</H1> 542 Besides the obvious program message strings that have been the sole focus of 543our discussion here, there are many other things that require translation, 544including GUI messages, command-line option strings, configuration files, 545program documentation, etc. Besides these obvious aspects, there are a 546significant number of programs and/or scripts that are automatically generated 547by other programs. These generated programs might also themselves require 548translation. So, in any effort to provide support for a given native language, 549carrying out the translation and keeping up with program updates becomes a 550major part of the undertaking, requiring a continuing commitment from the 551language team. A plan has been outlined for the Oriya localization 552project [<A 553 HREF="memo.html#url:oriya-trans-plan">2</A>]. 554 555<P> 556 557<H1><A NAME="SECTION00060000000000000000"> 558Acknowledgments</A> 559</H1> 560Extensive use has obviously been made of the GNU <TT>gettext</TT> manual in preparing 561this document. I have also been helped by an article in the Linux 562Journal [<A 563 HREF="memo.html#url:lj-translation">3</A>]. 564 565<P> 566This work is part of the project for enabling the use of Oriya under Linux. I 567thank my uncle, N. M. Pattnaik, for conceiving of the project. We have all 568benefited from the discussions amidst the group of people working on this 569project. On the particular issue of translation, the help of H. R. Pansari, 570A. Nayak, and M. Chand is much appreciated. 571 572<H1><A NAME="SECTION00070000000000000000"> 573The 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"><</SPAN>filename<SPAN CLASS="MATH">></SPAN>.'' It can be started from the menu in some desktops, e.g., on 577my GNOME desktop, it is under Main Menu <TT>-></TT> Programming <TT>-></TT> 578Emacs. 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 580top. Emacs makes extensive use of the Control (sometimes labelled as ``CTRL'' 581or ``CTL'') and Meta (sometimes labelled as ``Edit'' or ``Alt'') keys. In 582Emacs parlance, a hyphenated sequence, such as ``C-h'' means to press the 583Control and `h' key simultaneously, while ``C-h t'' would mean to press the 584Control 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 586the same time. 587 588<P> 589The info browser can be started by typing ``C-h i'' in Emacs. The first time 590you do this, it will briefly list some commands available inside the info 591browser, and present you with a menu of major topics. Each menu item, or 592cross-reference is hyperlinked to the appropriate node, and you can visit that 593node either by moving the cursor to the item and pressing Enter, or by 594clicking on it with the middle mouse button. To get to the <TT>gettext</TT> menu items, 595you can either scroll down to the line, 596<PRE> 597 * gettext: (gettext). GNU gettext utilities. 598</PRE> 599and 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 601for a string in the mini-buffer at the bottom of the window. This is an 602incremental search, so that Emacs will keep moving you forward through the 603buffer as you are entering your search string. If you have reached the last 604occurrence of the search string in the current buffer, you will get a message 605saying ``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. 608 609<P> 610Info nodes are listed in this document with a ``::'' separator, so 611that one can go to the gettext::Creating::Header Entry:: by visiting the 612``gettext'' node from the main info menu, navigating to the ``Creating'' 613node, and following that to the ``Header Entry'' node. 614 615<P> 616A stand-alone info browser, independent of Emacs, is also available on many 617systems. 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 619info browser, so that if it is installed, typing ``xinfo gettext'' from the 620command line will open a new browser window with the <TT>gettext</TT> info page. 621 622<P> 623 624<H1><A NAME="SECTION00080000000000000000"> 625PO 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 628planning on using that as it is platform-independent, and currently the best 629at rendering Oriya. This section describes some features of some editors that 630are specialized for editing PO files under Linux. This is still work in 631progress, as I am in the process of trying out different editors before 632settling on one. The ones considered here are: Emacs in po-mode, <TT>poedit</TT>, 633<TT>kbabel</TT>, and <TT>gtranslator</TT>. 634 635<H2><A NAME="SECTION00081000000000000000"> 636Emacs PO mode</A> 637</H2> 638 Emacs should automatically enter po-mode when you load a .po file, as 639indicated by ``PO'' in the modeline at the bottom. The window is made 640read-only, so that you can edit the .po file only through special commands. A 641description of Emacs po-mode can be found under the gettext::Basics info node, 642or type `h' or `?' in a po-mode window for a list of available commands. While 643I find Emacs po-mode quite restrictive, this is probably due to unfamiliarity 644with it. Its main advantage is that it imposes rigid conformance to the PO 645file format, and checks the file format when closing the .po file 646buffer. Emacs po-mode is not useful for Oriya translation, as I know of no way 647to directly enter Oriya text under Emacs. 648 649<H2><A NAME="SECTION00082000000000000000"> 650poedit</A> 651</H2> 652 XXX: in preparation. 653 654<H2><A NAME="SECTION00083000000000000000"> 655KDE: the kbabel editor</A> 656</H2> 657 <TT>kbabel</TT> [<A 658 HREF="memo.html#url:kbabel">4</A>] is a more user-friendly and configurable editor than 659either of Emacs po-mode or <TT>poedit</TT>. It is integrated into KDE, and offers 660extensive contextual help. Besides support for various PO file features, it 661has a plugin framework for dictionaries, that allows consistency checks and 662translation suggestions. 663 664<H2><A NAME="SECTION00084000000000000000"> 665GNOME: the gtranslator editor</A> 666</H2> 667 XXX: in preparation. 668 669<H2><A NAME="SECTION00090000000000000000"> 670Bibliography</A> 671</H2><DL COMPACT><DD><P></P><DT><A NAME="xkb-oriya-layout">1</A> 672<DD> 673G. 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. 6.2 describes the xkb layouts for Oriya. 678 679<P></P><DT><A NAME="url:oriya-trans-plan">2</A> 680<DD> 681G. 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. 686 687<P></P><DT><A NAME="url:lj-translation">3</A> 688<DD> 689Linux 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>. 692 693<P></P><DT><A NAME="url:kbabel">4</A> 694<DD> 695Features 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> 699 700<H1><A NAME="SECTION000100000000000000000"> 701About this document ...</A> 702</H1> 703 <STRONG>A tutorial on Native Language Support using GNU gettext</STRONG><P> 704This 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) 706<P> 707Copyright © 1993, 1994, 1995, 1996, 708<A HREF="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos Drakos</A>, 709Computer Based Learning Unit, University of Leeds. 710<BR>Copyright © 1997, 1998, 1999, 711<A HREF="http://www.maths.mq.edu.au/~ross/">Ross Moore</A>, 712Mathematics Department, Macquarie University, Sydney. 713<P> 714The command line arguments were: <BR> 715 <STRONG>latex2html</STRONG> <TT>-no_math -html_version 4.0,math,unicode,i18n,tables -split 0 memo</TT> 716<P> 717The translation was initiated by Gora Mohanty on 2004-07-24 718<DIV CLASS="navigation"><HR> 719 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> 728End of Navigation Panel--> 729 730<ADDRESS> 731Gora Mohanty 7322004-07-24 733</ADDRESS> 734</BODY> 735</HTML> 736