Operating System - HP-UX
1832251 Members
2713 Online
110041 Solutions
New Discussion

Internationalization on a SPI

 
koff
Frequent Advisor

Internationalization on a SPI

Hello.
I make my first SPI and this on provides templates and applications in english.
It is possible to make a SPI which contains templates and applications in several language : choose on the swinstall the language english, spanich, french... ?
How can i make this ?
Thk u for your help !
Big thanks.
1 REPLY 1
Kenneth Platz
Esteemed Contributor

Re: Internationalization on a SPI

You can provide different messages in different languages through the use of message catalogs. You can build them using the "gencat" command, and you can then access them using the catopen() and catgets() functions. For example, create a message catalog, hello.msg:

set 1
1 Hola, mundo!

Then you would compile this into a .cat file, by running the command:

# gencat hello.cat hello.msg

Next, you would copy the hello.cat file into the appropriate directory (for example, /usr/lib/nls/es_ES.iso88591). Now here is your application:

#include
#include

int main() {
nl_catd catid;
char *msg;
catid = catopen( "hello.cat", 0 );
if ( catid < 0 ) {
perror( "Unable to open message catalog" );
}

printf( "%s\n", catgets( catid, 1, 1, "Hello, world!" );
}

Now all you need to do is compile that hello.c file (using your choice of C compiler). If you set LANG=C, then you should get "Hello, world!" as output. However, if you set LANG=es_ES.iso88591, you should get "Hola, mundo!" as output.

Share and enjoy.
I think, therefore I am... I think!