manpagez: man pages & more
info gettext
Home | html | info | man

File: gettext.info,  Node: c-format,  Next: objc-format,  Up: Translators for other Languages

16.3.1 C Format Strings
-----------------------

   C format strings are described in POSIX (IEEE P1003.1 2001), section
XSH 3 fprintf(),
.
See also the fprintf() manual page man fprintf.

   Although format strings with positions that reorder arguments, such
as

     "Only %2$d bytes free on '%1$s'."

which is semantically equivalent to

     "'%s' has only %d bytes free."

are a POSIX/XSI feature and not specified by ISO C 99, translators can
rely on this reordering ability: On the few platforms where ‘printf()’,
‘fprintf()’ etc.  don't support this feature natively, ‘libintl.a’ or
‘libintl.so’ provides replacement functions, and GNU ‘’
activates these replacement functions automatically.

   C format strings can contain placeholders that reference macros
defined in ISO C 99 ‘’.  For example, ‘’ references
the macro ‘PRId64’.  The value of such a macro is system-dependent, but
programmers and translators do not need to know this value.  ISO C 23
specifies system-independent format string elements, for example,
‘"%w64d"’ instead of ‘"%" PRId64’; however, as of 2024, these are not
implemented across systems and therefore cannot be used portably.

   As a special feature for Farsi (Persian) and maybe Arabic,
translators can insert an ‘I’ flag into numeric format directives.  For
example, the translation of ‘"%d"’ can be ‘"%Id"’.  The effect of this
flag, on systems with GNU ‘libc’, is that in the output, the ASCII
digits are replaced with the ‘outdigits’ defined in the ‘LC_CTYPE’
locale category.  On other systems, the ‘gettext’ function removes this
flag, so that it has no effect.

   Note that the programmer should _not_ put this flag into the
untranslated string.  (Putting the ‘I’ format directive flag into an
MSGID string would lead to undefined behaviour on platforms without
glibc when NLS is disabled.)

© manpagez.com 2000-2026
Individual documents may contain additional copyright information.