Jump to content
  • Advertisement
Acharis

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

This topic is 375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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()

Edited by vstrakh

Share this post


Link to post
Share on other sites
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()...

Share this post


Link to post
Share on other sites
2 minutes ago, Acharis said:

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

There's _putenv() on windows :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!