Home > Back-end >  GNU gettext ignores set locale
GNU gettext ignores set locale

Time:03-01

I'm trying to use GNU gettext in a C program running on MS Windows. I manage to set the locale as for instance char *locale = setlocale(LC_ALL, "French_France.1252");

I check the returned string so I know it took.

Then I set the environment as

textdomain("Test");
bindtextdomain("Test", "C:\\develop\\test\\executablesdebug\\Language\\");

Then I do an experimental translation, like

char *test = gettext("Hello world");

And the translated string gets the Swedish translation (the operating system setting) and not the French string I wanted.

CodePudding user response:

As far as I can remember in Windows you also have to set the thread locale using SetThreadLocale (you will have to map to the locale ID, take a look at this webpage).

Finally, take into consideration that in Windows each thread has its own locale; set it for all threads using translations.

  • Related