The previous section presented a simple example of how Oriya language support
could be added to a C program. Like all programs, we might now wish to further
enhance it. For example, we could include a greeting to the user by adding
another printf statement after the first one. Our new hello.c source
code might look like this:
1 #include <libintl.h>
2 #include <locale.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 int main(void)
6 {
7 setlocale( LC_ALL, "" );
8 bindtextdomain( "hello", "/usr/share/locale" );
9 textdomain( "hello" );
10 printf( gettext( "Hello, world!\n" ) );
11 printf( gettext( "How are you\n" ) );
12 exit(0);
13 }
For such a small change, it would be simple enough to just repeat the above
cycle of extracting the relevant English text, translating it to Oriya, and
preparing a new message catalog. We can even simplify the work by cutting and
pasting most of the old oriya.po file into the new one. However, real programs
will have thousands of such strings, and we would like to be able to translate
only the changed strings, and have the gettext utilities handle the drudgery
of combining the new translations with the old ones. This is indeed possible.
Subsections
Gora Mohanty
2004-07-24