Software Internationalization Guide

POSIX and XPG Internationalization Model
Software Internationalization Guide526225-002
3-11
Messaging System Example
NLSPATH identifies the search path to the appropriate directory for finding the message
catalog; it also identifies message catalog naming conventions.
Messaging System Example
The following example shows code modified to incorporate the XPG messaging
system. It contains calls that access messages in a message catalog. A default
message string is defined in the fourth parameter of the catgets() function and is
used if the message cannot be located.
/*Program source code using the XPG messaging system*/
#include <stdio.h>
#include <locale.h>
#include <nl_types.h>
main()
{
char response;
nl_catd catd;
setlocale(LC_ALL,"");
catd = catopen("EngFile.cat",NL_CAT_LOCALE);
printf("%s",catgets(catd,1,1,"Main Menu"));
printf("%s",catgets(catd,1,2,"1 - Add Record\n"));
printf("%s",catgets(catd,1,3,"2 - Delete Record\n"));
printf("%s",catgets(catd,1,4,"3 - Modify Record\n"));
printf("%s",catgets(catd,1,5,"4 - Quit\n\n\n\n\n"));
printf("%s",catgets(catd,1,6,"Make A Selection:"));
scanf("%c",&response);
switch (response)
{
case '1': add_record_module();
break;
case '2': delete_record_module();
break;
case '3': modify_record_module();
break;
case '4': break;
default: printf("%s",catgets(catd,1,7,"You pressed an invalid key.
Try again\n"));
}
catclose(catd);
}
Code-Set Conversion
Because many codes sets exist, characters are often encoded in different ways on
different systems. Code-set conversion converts a character set from one encoding to
another encoding.
Code-set conversion converts from one code set to another code set by using
algorithms or tables. The genxlt utility takes as input two different code sets and
builds a code-set conversion table. The code-set conversion table is then accessed by
internationalized programs using the iconv() function.