Question: I'm writing a game that is mainly geared for GNU/Linux and Mac OS X systems, but I've been keeping things fairly portable in most of my code.

I've ported nearly all of the OS-specific stuff to Windows; the only thing remaining is i18n. 

My question is this

> 
> How am I supposed to use Win32's `setlocale()` function along with gettext?
> 
> 
> 

Until now, I've been using ISO 638/ISO 3166 codes (ex. `de_DE.utf8`), but these don't seem to work on Windows.

I've tried setlocale(LC\_ALL, "German"), which succeeds, but gettext can't find the translated strings correctly, even after using bindtextdomain. 

Any hints? I'd like to stick with GNU gettext to avoid rewriting heaps of code.

Answer: 
Well, after some digging, I found the answer: setlocale() on Windows does nothing for gettext. gettext uses the user's environment and the thread's locale (see GetThreadLocale, SetThreadLocale). If the thread's locale is used, the returned LCID is transformed into a language string with ISO 639 and 3166 (ex. en\_US) and the lookup proceeds as on \*nix.
If you can read Python example there is my tiny project which helps to convert windows locale ids to gettext language codes like `de_DE`: <https://launchpad.net/gettext-py-windows>

In short you need to obtain `LCID` with function `GetUserDefaultLCID()` which returns you an integer id. Then you need to map this value to string code. In Python there is map in the standard module `locale.py`: see `windows_locale` dictionary near the bottom of the file <http://svn.python.org/view/python/trunk/Lib/locale.py?view=markup>

The list of Windows locale ids you can find here: <http://msdn.microsoft.com/en-us/library/dd318693%28VS.85%29.aspx>

Once you will have language code (`de_DE`) you need to pass it either directly to gettext library or indirectly using environment variable LANGUAGE.