Has anyone used gettext() with success (C++,Windows)?

Started by
5 comments, last by Acharis 6 years, 9 months ago

I have been using gettext() in PHP and it works great. Tried to do so in C++ and... there are numerous problems. Tried to google it but could not find any solution only a list of similar problems other people had (primarily ).

Have you used gettext() in your C/C++ project? Had you make it work?

I'm using Windows+MINGW+Code::Blocks.

 

 

At this point I'm considering writing my own .mo file parser, maybe that would be simplier :)

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

I'm assuming this is some sort of library? Can you list the actual problems you're having?

Worked with it long ago with no problems, used in a portable win32/linux app.

See quick tutorial here: http://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html

The main "problem" you can hit with gettext - is when you want to change language explicitly. It's important to call setlocale(LC_ALL, "") and have LANGUAGE environment variable set to desired language. Normally gettext returns translations depending on system's settings, so if you want to change language from within the app - just putenv() LANGUAGE var explicitly.

Also pay attention to .mo files final location. It must be as described in tutorial, e.g. "top_translations_dir/language/LC_MESSAGES/domain.mo". In bold there's your language (en/fr/ja, etc), and text domain, top_translations_dir is location passed to bindtextdomain()

4 hours ago, vstrakh said:

Worked with it long ago with no problems, used in a portable win32/linux app.

See quick tutorial here: http://www.labri.fr/perso/fleury/posts/programming/a-quick-gettext-tutorial.html

The main "problem" you can hit with gettext - is when you want to change language explicitly. It's important to call setlocale(LC_ALL, "") and have LANGUAGE environment variable set to desired language. Normally gettext returns translations depending on system's settings, so if you want to change language from within the app - just putenv() LANGUAGE var explicitly.

Exactly :) The most annoying part is you can't override the system settings (and tell gettext to use a desired language) and you are on the mercy of system settings.

And there is another problem, for some reason there is no putenv() function available "error: 'setenv' was not declared in this scope" (MinGW, Windows)... Which is quite weird... And, as I have heard, you can't make gettext work without setenv()...

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

2 minutes ago, Acharis said:

And there is another problem, for some reason there is no putenv() function available

There's _putenv() on windows :)

12 minutes ago, vstrakh said:

There's _putenv() on windows :)

Which is not available as well :) Same for _putenv_s() of course :)

There is SetEnvironmentVariable() but... it does not seem to have any effect.

It's as if everything related to setting system variables was not available or not working on my computer.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

This topic is closed to new replies.

Advertisement