I'm having difficulty running a simple example using MinGW gettext.
My setup (from http://www.mingw.org/download.shtml):
-- main.cpp --
#define i18n(s) gettext(s)
using namespace std;
// Specify that translations are stored in directory
// Switch to russian locale.
// Output localized message.
std::cout << i18n("hello");
.mo file at 'messages\ru_RU.KOI8-R\LC_MESSAGES\main.mo':
msgunfmt this file produces:
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2003-07-01 15:45+0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@...>\n"
"Language-Team: LANGUAGE <LL@...>\n"
"Content-Type: text/plain; charset=CHARSET\n"
msgstr "international hello"
The "international hello" string is never printed out when I execute
the program main.exe at the directory containing the messages
I am linking with libintl.dll.a and libiconv.dll.a. I would prefer
not to use the .dll.a files but i can't find libiconv.a library.
Please help guide me to get this simple example working. Thanks.
From: Tor Lillqvist <tml@ik...> - 2004-09-25 10:38:46
Chyi Pin Lim writes:
> setlocale(LC_MESSAGES, "ru_RU.KOI8-R");
The setlocale() in the Microsoft C library doesn't know anything about
LC_MESSAGES (which is defined in the libintl.h from GNU gettext), this
hardly has any effect. And even if you change it to LC_ALL, the second
parameter would be wrong, as the Microsoft C library doesn't use those
Unixish locale names. Instead it uses stuff like "russian_Russia.1251".
I don't know about the 0.11.5 version of GNU gettext available from
the mingw page, but at least version 0.12.1 and later doesn't look at
the C library locale information at all on Win32. Instead it looks for
LC_ALL or LANG environment variables, and if no such are set, at the
language of in the thread locale, from GetThreadLocale(). This is then
translated into a Unixish locale name used to form the path to the
My advice is to remove the setlocale() call, and instead set the LANG
environment variable to ro_RU.KOI8-r.