DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Internationalization

Message handling

As the examples in earlier sections may have suggested, the general approach behind the message handling feature is to separate messages from program source code, replacing hard-coded character strings with function calls that fetch the strings from a file. You supply the file, which contains your program's messages in whatever language the locale implements. You can adapt your applications to different locales, then, without having to change and recompile source code.

In this section we will look at the SCO OpenServer-specific and X/Open message handling facilities as they might be used to adapt an ``English-speaking'' program to a French locale. The code fragment below queries the English-speaking user for an affirmative or negative response, and reads the response:

#include <stdio.h>

main() { int yes();

while(1) { puts("Choose (y/n)"); if (yes()) puts("yes"); else puts("no"); } }

static int yes() { int i, b;

i = b = getchar(); while (b != '\n' && b != '\0' && b != EOF) b = getchar(); return(i == 'y'); }


Next topic: mkmsgs and gettxt (OS-specific)
Previous topic: String collation

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005