LML
LML

Reputation: 150

Query about an unfamiliar syntax of printf function

In the source code of Unix fdisk command, I came across following printf.

printf ("%s %s %10s %11s %11s %4s %7s ", _("Device"),
        _("Boot"), _("Start"), _("End"), _("Blocks"), _("Id"), _("System"));

Why are the strings being placed inside parentheses preceded by an underscore?

Upvotes: 3

Views: 98

Answers (1)

David Ranieri
David Ranieri

Reputation: 41017

Is a shorthand for gettext:

#define _(string) gettext (string)

1.1 The Purpose of GNU gettext

Usually, programs are written and documented in English, and use English at execution time to interact with users. This is true not only of GNU software, but also of a great deal of proprietary and free software. Using a common language is quite handy for communication between developers, maintainers and users from all countries. On the other hand, most people are less comfortable with English than with their own native language, and would prefer to use their mother tongue for day to day’s work, as far as possible. Many would simply love to see their computer screen showing a lot less of English, and far more of their own language.

However, to many people, this dream might appear so far fetched that they may believe it is not even worth spending time thinking about it. They have no confidence at all that the dream might ever become true. Yet some have not lost hope, and have organized themselves. The Translation Project is a formalization of this hope into a workable structure, which has a good chance to get all of us nearer the achievement of a truly multi-lingual set of programs.

GNU gettext is an important step for the Translation Project, as it is an asset on which we may build many other steps. This package offers to programmers, translators and even users, a well integrated set of tools and documentation. Specifically, the GNU gettext utilities are a set of tools that provides a framework within which other free packages may produce multi-lingual messages.

More info

Upvotes: 2

Related Questions