xgettext vs gettext
Asked Answered
E

4

12

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!

Emelyemelyne answered 30/8, 2009 at 3:21 Comment(1)
You might want to break out the second and third parts to their own questions.Witchcraft
W
16

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

Witchcraft answered 5/6, 2010 at 14:27 Comment(0)
U
4

Install Cygwin and select the gettext-devel package.
This will install the xgettext.exe

The Zend Framework has a gettext Zend_Translate adapter that doesn't require the php gettext extention.

Unrelenting answered 31/8, 2009 at 21:29 Comment(0)
D
0

xgettext is part of gettext, it's a program that extracts translatable strings from program sources. See gettext's manual.

I don't know about its availability on Windows, Google tells me there's a port.

Desultory answered 30/8, 2009 at 6:9 Comment(1)
could that help me with this -> #1351759 ?Emelyemelyne
A
-6

The online [function reference][1] reference tells me there is no xgettext.

Maybe they mean one of

ngettext dgettext dngettext dcgettext dcngettext

treating the 'x' like a wildcard [1]: https://www.php.net/manual-lookup.php?pattern=xgettext&lang=en

Aesthetically answered 30/8, 2009 at 3:28 Comment(1)
xgettext is a preprocessing function that is called to parse your source code files and extract all strings from the function gettext, ngettext, dgettext, and the others noted. So, xgettext is not a function, but a program that is called.Ritualist

© 2022 - 2024 — McMap. All rights reserved.