I have a program where i18n is handled by gettext. The program works fine, however for some reason I need to know the name of the locale used by gettext at runtime (something like ‘fr_FR’) under win32.
I looked into gettext sources, and there is a quite frightening function that computes it on all platforms (gl_locale_name, in a C file called “localename.h/c”). However, this file does not seem to be installed alongside gettext or libintl, so I can’t seem to call the function. Is there another function provided by gettext to get this value ? Or in another package (boost, glib, anything ?)
(On a related note, there is a thing called std::locale in the C++ standard library, and according to the doc calling std::locale(“”) should create a locale with the settings of the system, unless I am mistaken … but then the name is ‘C’ under windows. Is it a viable way of getting the locale name ? What I am doing wrong ?)
Turns out the “gl_locale_name” function was not part of gettext directly, but rather part of gnulib – http://www.gnu.org/software/gnulib. I just discovered the package today.
So getting the infamous localename.h header in my project was a matter of
Then the gl_locale_name function works just fine when cross-compiling.
Thanks to everyone for the answers !