Re: _("string")



On Fri, Dec 06, 2002 at 04:32:06PM -0500, Tristan Van Berkom wrote:
Unicode macro.


No, has nothing to do with Unicode.

_("string")

in english should stay "string"
in french it's probably "chaine"

      -Tristan

Martin Bammer wrote:

Hi,

what means _("string") ?
What is the difference to "string" ?



The underscore is a shortcut to the gettext function. The gettext
function is part of the GNU gettext library. The gettext software which
includes the library and some development utility is one of the most
widely used tools for facilitating translation of program messages to
other languages, one aspect of program internationalization (i18n).

Basically, all the strings that you want to be able to translate you
actually turn into a function call, passing them to gettext. The gettext
function will return a translated string by doing a lookup in a message
database, based on the current localization settings.

The idea of using an underscore as a stand in for the gettext function 
is not that just that it reduces typing, but that it arguably lends 
itself to maintaining code readibility when the gettext system is being 
used. It is indeed sensible because it avoids littering the code with 
meaningless "gettext"s and as long as one knows that the gettext system 
is being used, the underscore becomes instantly recogzinable as the 
moniker for a translatable string.

The mechanism is relatively straightforward but there are too many
details to describe it here.
The GNU gettext manual does a decent job of explaining how the system
works, so I recommend you read through it. You can find a link to it at:
http://www.gnu.org/software/gettext/

        -jkl

Attachment: pgpHUlXQZ42Xw.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]