4

When using printf-like format strings in a translated text msgfmt --check checks that the translation still contains the placeholders. For example, running xgettext on the following code

printf( gettext( "string: %s, int: %d" ), str, i )

produces a .po file with a msgid flagged as c-format and whose value is "string: %s, int: %d". If the translator forgets either %s or %d in the translation then msgfmt complains:

number of format specifications in 'msgid' and 'msgstr' does not match

Unfortunately this check does not apply to format strings using positional notation, like

boost::format( gettext( "string: %1%, int %2%" ) ) % str % i

How can I validate the presence of the positional notation placeholders in my translations?

Julien
  • 2,139
  • 1
  • 19
  • 32

1 Answers1

0

Not direct answer, but maybe following solution could solve your problem:

boost::format( gettext( "string: %1$s, int %2$d" ) ) % str % i;

trigras
  • 515
  • 6
  • 18