mirror of
https://https.git.savannah.gnu.org/git/gettext.git
synced 2026-01-26 15:39:11 +00:00
* autogen.sh (GNULIB_MODULES_RUNTIME_FOR_SRC): Add c-ctype, c-strtold, fzprintf-posix, mbrtoc32, mbszero, quote, stdint-h, strtoimax, strtold, strtoumax, xstrtold. * gettext-runtime/src/printf-command.h: New file. * gettext-runtime/src/printf-command.c: New file. * gettext-runtime/src/printf_gettext.c: New file. * gettext-runtime/src/Makefile.am (bin_PROGRAMS): Add printf_gettext, printf_ngettext. (noinst_LIBRARIES, libgrtsrc_a_SOURCES): New variables. (printf_gettext_SOURCES, printf_gettext_CFLAGS, printf_gettext_LDFLAGS): New variables. (printf_ngettext_SOURCES, printf_ngettext_CFLAGS, printf_ngettext_LDFLAGS): New variables. (LDADD): Add libgrtsrc.a. * gettext-runtime/po/POTFILES.in: Add src/printf-command.c, src/printf_gettext.c, src/printf_ngettext.c. * gettext-runtime/man/printf_gettext.x: New file. * gettext-runtime/man/printf_ngettext.x: New file. * gettext-runtime/man/Makefile.am (man_aux): Add printf_gettext.x, printf_ngettext.x. (man_MAN1GEN): Add printf_gettext.1, printf_ngettext.1. (man_MAN1IN): Add printf_gettext.1.in, printf_ngettext.1.in. (man_HTML1GEN): Add printf_gettext.1.html, printf_ngettext.1.html. (man_HTML1IN): Add printf_gettext.1.html.in, printf_ngettext.1.html.in. (printf_gettext.1, rintf_ngettext.1, printf_gettext.1.in, printf_ngettext.1.in): Add dependencies. (printf_gettext.1.html, printf_ngettext.1.html, printf_gettext.1.html.in, printf_ngettext.1.html.in): Likewise. * gettext-runtime/Makefile.am (distdir1): Depend on man/printf_gettext.1 and man/printf_ngettext.1. (man/printf_gettext.1, man/printf_ngettext.1): Depend on gen-man1. (gen-man1): Make src/printf_gettext, src/printf_ngettext and printf_gettext.1, printf_ngettext.1. * gettext-runtime/doc/rt-printf_gettext.texi: New file. * gettext-runtime/doc/rt-printf_ngettext.texi: New file. * gettext-runtime/doc/Makefile.am (EXTRA_DIST): Add them. * gettext-tools/doc/lang-sh.texi (printf_gettext Invocation, printf_ngettext Invocation): New subsubsections. * gettext-tools/doc/gettext.texi (@direntry): Add printf_gettext, . * gettext-tools/doc/Makefile.am (gettext_TEXINFOS): Add rt-printf_gettext.texi, rt-printf_ngettext.texi. * gettext-runtime/NEWS: Mention the new programs. * NEWS: Likewise. * PACKAGING: Add the printf_gettext and printf_ngettext programs and their documentation.
150 lines
3.8 KiB
Plaintext
150 lines
3.8 KiB
Plaintext
@c This file is part of the GNU gettext manual.
|
|
@c Copyright (C) 2025 Free Software Foundation, Inc.
|
|
@c See the file gettext.texi for copying conditions.
|
|
|
|
@pindex printf_ngettext
|
|
@cindex @code{printf_ngettext} program, usage
|
|
@example
|
|
printf_ngettext [@var{option}] @var{format} @var{format-plural} @var{count} [@var{argument}]...
|
|
@end example
|
|
|
|
@cindex lookup format string translation with plural
|
|
@cindex formatted output in Shell
|
|
The @code{printf_ngettext} program produces formatted output,
|
|
applying the native language translation of
|
|
@var{format} and @var{format-plural}, depending on @var{count},
|
|
to the @var{argument}s.
|
|
|
|
@noindent @strong{Options and arguments}
|
|
|
|
@table @samp
|
|
@item -c @var{context}
|
|
@itemx --context=@var{context}
|
|
@opindex -c@r{, @code{printf_ngettext} option}
|
|
@opindex --context@r{, @code{printf_ngettext} option}
|
|
Specify the context for the format string to be translated.
|
|
See @ref{Contexts} for details.
|
|
|
|
@item @var{format}
|
|
English singular form of format string.
|
|
|
|
@item @var{format-plural}
|
|
English plural form of format string.
|
|
|
|
@item @var{count}
|
|
A cardinal number.
|
|
The singular/plural form is chosen based on this value.
|
|
|
|
@item @var{argument}
|
|
A string or numeric argument.
|
|
|
|
@end table
|
|
|
|
@noindent @strong{Informative output}
|
|
|
|
@table @samp
|
|
@item -h
|
|
@itemx --help
|
|
@opindex -h@r{, @code{printf_ngettext} option}
|
|
@opindex --help@r{, @code{printf_ngettext} option}
|
|
Display this help and exit.
|
|
|
|
@item -V
|
|
@itemx --version
|
|
@opindex -V@r{, @code{printf_ngettext} option}
|
|
@opindex --version@r{, @code{printf_ngettext} option}
|
|
Output version information and exit.
|
|
|
|
@end table
|
|
|
|
Each format string consists of
|
|
@itemize @bullet
|
|
@item
|
|
plain text,
|
|
@item
|
|
directives, that start with @samp{%},
|
|
@item
|
|
escape sequences, that start with a backslash.
|
|
@end itemize
|
|
|
|
A directive that consumes an argument
|
|
@itemize @bullet
|
|
@item
|
|
starts with @samp{%} or @samp{%@var{m}$} where @var{m} is a positive integer,
|
|
@item
|
|
is optionally followed by any of the characters
|
|
@samp{#}, @samp{0}, @samp{-}, @samp{ }, @samp{+},
|
|
each of which acts as a flag,
|
|
@item
|
|
is optionally followed by a width specification (a nonnegative integer),
|
|
@item
|
|
is optionally followed by @samp{.} and a precision specification
|
|
(an optional nonnegative integer),
|
|
@item
|
|
is finished by a specifier
|
|
@itemize @bullet
|
|
@item
|
|
@samp{c}, that prints a character,
|
|
@item
|
|
@samp{s}, that prints a string,
|
|
@item
|
|
@samp{i}, @samp{d}, that print an integer,
|
|
@item
|
|
@samp{u}, @samp{o}, @samp{x}, @samp{X},
|
|
that print an unsigned (nonnegative) integer,
|
|
@item
|
|
@samp{e}, @samp{E}, that print a floating-point number in scientific notation,
|
|
@item
|
|
@samp{f}, @samp{F}, that print a floating-point number without an exponent,
|
|
@item
|
|
@samp{g}, @samp{G}, that print a floating-point number in general notation,
|
|
@item
|
|
@samp{a}, @samp{A}, that print a floating-point number in hexadecimal notation.
|
|
@end itemize
|
|
@end itemize
|
|
|
|
Some flag+specifier combinations are invalid:
|
|
@itemize @bullet
|
|
@item
|
|
The @samp{#} flag with the specifiers
|
|
@samp{c}, @samp{s}, @samp{i}, @samp{d}, @samp{u}.
|
|
@item
|
|
The @samp{0} flag with the specifiers
|
|
@samp{c}, @samp{s}.
|
|
@end itemize
|
|
|
|
Additionally there is the directive @samp{%%}, that prints a single @code{%}.
|
|
|
|
If a directive specifies the argument by its number (@samp{%@var{m}$} notation),
|
|
all directives that consume an argument must do so.
|
|
|
|
The escape sequences are:
|
|
@table @code
|
|
@item \\
|
|
backslash
|
|
@item \a
|
|
alert (BEL)
|
|
@item \b
|
|
backspace (BS)
|
|
@item \f
|
|
form feed (FF)
|
|
@item \n
|
|
new line (LF)
|
|
@item \r
|
|
carriage return (CR)
|
|
@item \t
|
|
horizontal tab (HT)
|
|
@item \v
|
|
vertical tab (VT)
|
|
@item \@var{nnn}
|
|
octal number with 1 to 3 octal digits
|
|
@end table
|
|
|
|
@noindent @strong{Environment Variables}
|
|
|
|
The translation of the format string is looked up in the translation domain
|
|
given by the environment variable @code{TEXTDOMAIN}.
|
|
|
|
It is looked up in the catalogs directory given by the environment variable
|
|
@code{TEXTDOMAINDIR} or, if not present, in the default catalogs directory.
|