Go to the first, previous, next, last section, table of contents.
@command{gawk}'s internationalization features were purposely chosen to have as little impact as possible on the portability of @command{awk} programs that use them to other versions of @command{awk}. Consider this program:
BEGIN {
TEXTDOMAIN = "guide"
if (Test_Guide) # set with -v
bindtextdomain("/test/guide/messages")
print _"don't panic!"
}
As written, it won't work on other versions of @command{awk}. However, it is actually almost portable, requiring very little change.
TEXTDOMAIN won't have any effect,
since TEXTDOMAIN is not special in other @command{awk} implementations.
_ with the string
following it.(45)" contest.} Typically, the variable _ has
the null string ("") as its value, leaving the original string constant as
the result.
dcgettext
and bindtextdomain, the @command{awk} program can be made to run, but
all the messages are output in the original language.
For example:
function bindtextdomain(dir, domain)
{
return dir
}
function dcgettext(string, domain, category)
{
return string
}
printf or
sprintf is not portable.
To support gettext at the C level, many systems' C versions of
sprintf do support positional specifiers. But it works only if
enough arguments are supplied in the function call. Many versions of
@command{awk} pass printf formats and arguments unchanged to the
underlying C library version of sprintf, but only one format and
argument at a time. What happens if a positional specification is
used is anybody's guess.
However, since the positional specifications are primarily for use in
translated format strings, and since non-GNU @command{awk}s never
retrieve the translated string, this should not be a problem in practice.
Go to the first, previous, next, last section, table of contents.