Pelles C forum

C language => Tips & tricks => Topic started by: TimoVJL on May 11, 2016, 11:18:56 AM

Title: Multi language example for console program.
Post by: TimoVJL on May 11, 2016, 11:18:56 AM
Simple multi language example for console program.
I can't recall if is it shown before?
Code: [Select]
#include <stdio.h>
#include <stdlib.h>

char *aMsgEN[] = {"MsgEN1\n","MsgEN2\n"};
char *aMsgGE[] = {"MsgGE1\n","MsgGE2\n"};
char **aMsg = aMsgEN;
int main(int argc, char **argv)
{
char *lang = getenv("LANG");
printf(aMsg[0]);
printf("%s %04X\n", lang, *(unsigned short*)lang);
//if (lang[0] == 'G' && lang[1] == 'E') {
if (*(unsigned short*)lang == *(unsigned short*)"GE") {
aMsg = aMsgGE;
printf(aMsg[0]);
}
return 0;
}