xgettext vs gettext

Kentor picture Kentor · Aug 30, 2009 · Viewed 8.3k times · Source

I have a few questions:

I know what gettext is. I've read a few posts where they mentioned xgettext and was curious as to what is the difference between the two.

How can I install xgettext on Windows?

And finally, does anybody have a tutorial on how to install the library php-gettext http://savannah.nongnu.org/projects/php-gettext/ (this one usually doesn't come with PHP) I've read about it in an article but I'm not sure how to get it working in Windows. The thing is, sometimes when you make changes, you need to restart Apache to see the new data with the gettext that comes with PHP (but with the library you don't need to restart it) so I wanted to use the library for development. Thanks!

Answer

CW Holeman II picture CW Holeman II · Jun 5, 2010

In regards to the question:

I know what gettext is. I've read a few posts where they mentioned xgettext and was curious as to what is the difference between the two.

In short, gettext() is a function and xgettext is a utility program for extracting messages from source code.

In long, SO answer to Complete C++ i18n gettext() “hello world” example shows as part of the C++ source code file hellogt.cxx:

gettext("hello, world!")

The gettext() function is passed a text string that is used as an index to the message to be used at run-time. It returns the specified message for the language which is specified either in the code or at the time the program is invoked.

Then it shows:

xgettext --package-name hellogt --package-version 1.2 --default-domain hellogt --output hellogt.pot hellogt.cxx

which is a utility program used at build time to examine the source code file hellogt.cxx for text strings passed to gettext(). These are extracted and used to create the Portable Object Template file hellogt.pot.

The .pot file template is used by translators in the process of delivering the binary translated message file hellogt.mo used at run-time by gettext().