bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Translating format strings with multiple instances of things that could


From: James Youngman
Subject: Translating format strings with multiple instances of things that could be plural
Date: Fri, 6 Jul 2007 10:02:01 +0100

I have read about nettext in the gettext Info pages, and used it in a
couple of places.  But one code snippet (in findutils/locate/locate.c)
has me stumped.  It is this:-

 char hbuf1[LONGEST_HUMAN_READABLE + 1];
 char hbuf2[LONGEST_HUMAN_READABLE + 1];
 char hbuf3[LONGEST_HUMAN_READABLE + 1];
 char hbuf4[LONGEST_HUMAN_READABLE + 1];

 printf(ngettext("Locate database size: %s byte\n",
                  "Locate database size: %s bytes\n",
                  database_file_size),
         human_readable ((uintmax_t) database_file_size,
                         hbuf1, human_ceiling, 1, 1));

 printf( (results_were_filtered ?
           _("Matching Filenames: %s\n") :
           _("All Filenames: %s\n")),
          human_readable (statistics.total_filename_count,
                         hbuf1, human_ceiling, 1, 1));
 /* XXX: We would ideally use ngettext() here, but I don't know
  *      how to use it to handle more than one possibly-plural thing/
  */
 printf(_("File names have a cumulative length of %1$s bytes.\n"
           "Of those file names,\n"
           "\n\t%2$s contain whitespace, "
           "\n\t%3$s contain newline characters, "
           "\n\tand %4$s contain characters with the high bit set.\n"),
         human_readable (statistics.total_filename_length,  hbuf1,
human_ceiling, 1, 1),
         human_readable (statistics.whitespace_count,       hbuf2,
human_ceiling, 1, 1),
         human_readable (statistics.newline_count,          hbuf3,
human_ceiling, 1, 1),
         human_readable (statistics.highbit_filename_count, hbuf4,
human_ceiling, 1, 1));



My problem is the final printf() call here.  %1$s is certain to be
over 200, but the others could be anywhere between 0 and a very large
number.  How can I make this code translation-friendly?   On obvious
option is to break it up into multiple printf() calls, with one call
to ngettext() each.  But the resut of that is to construct an English
sentence out of multiple individually translated parts, which is very
unfriendly to the translators.  However, I also don't want to cater
for the 2^4 combinations of singular and plural in the English case
(and other languages will presumably be worse).

What should I do for the best translation result?

Thanks,
James.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]