How to set GTK/App locale in Windows?



I have GTK program that has support for gettext l10n and it is working great 
in Linux. But I want to port it to Windows.

I need to set gtk locale based on user settings (ignoring "regional settings" 
in windows). I have following dirs:

$prefix\lang\de_DE\LC_MESSAGES\app.mo
$prefix\lang\sr_YU\LC_MESSAGES\app.mo
$prefix\lang\...\LC_MESSAGES\app.mo

where $prefix is someting like "C:\Program Files\app\" and it is taken from 
windows registry - so at runtime I have full path as a char pointer.
 
I keep user language preferences as a string (char *) in database so I also 
have "de_DE" at runtime.

Then I load it like this:

>>>>>>>>>>>>>>>>>>.
int main() {
...
#ifdef ENABLE_NLS
  /* langpath is char * langpath = "$prefix\lang\" at this point */
  bindtextdomain (GETTEXT_PACKAGE, (char*) langpath);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif
...

/* locale is char * locale = "de_DE" at this point */
setlocale(LC_ALL,locale);
gtk_disable_setlocale();
g_free(locale);

// gtk init, gtk main and so on..
}
<<<<<<<<<<<<<<<<

In Linux all works great. This code selectes GTK/App locale based on user 
settings (locale var). But in Windows setlocale(LC_ALL, locale) returns NULL 
and locale is not selected! But, GTK locale is selected based on "regional 
settings" in Windows - Serbian in mine case.

How can I load GTK/application locale in Windows, and is the "de_DE" right 
value for German locale to be passed to setlocale()?


Bye,
Goran






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]