[cups.bugs] [LOW] STR #3822: lpq output not aligned when translated

Christian Boltz cups-bugs at cboltz.de
Wed Mar 30 15:33:00 PDT 2011


DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Closed w/o Resolution]

I finally had a look at the code (lpq.c). It's been a while since I read C
code the last time, so forgive me if I misunderstood something ;-)

If I get it right, show_jobs() prints the header line (which is one big
string) if jobcount == 0 (aka "header not yet printed") and longstatus
(-l) mode is not used.

#ifdef __osf__
    _cupsLangPuts(stdout,                                                 
                                                                           
     
                  _("Rank   Owner      Pri  Job        Files              
        Total Size"));
(similar for #else)

Then it prints the various fields:
#ifdef __osf__
        _cupsLangPrintf(stdout,
                    _("%-6s %-10.10s %-4d %-10d %-27.27s %.0f bytes"),
            rankstr, jobuser, jobpriority, jobid, jobname, 
            1024.0 * jobsize);
(again similar for #else)

The format string indeed comes from the translation file, so yes, you are
right. However I just checked all translations and the only thing that was
changes in this string was the word "bytes" - making only this word
translateable would therefore be enough (or teach the translators the
printf syntax ;-)

I still propose to auto-detect the length of the headers and change the
column width accordingly. The needed changes are IMHO:
- split the header to multiple texts ("Rank", "Owner", "Pri" etc.)
- detect the length of each one, with a minimum length given, and add 2 
  for some spaces).
  Pseudocode:
      $rank_len = max( (strlen(_("Rank")), 6) + 2;
      $owner_len = max( (strlen(_("Owner")), 6) + 2;
  (6 is the current field width - for "File(s)" it's about 30)
- change the printf string used for _cupsLangPrintf according to 
  $xxxx_len. Pseudocode again (shortened at "[...]"):
      $jobs_prinf = "%-" . $rank_len . "s %-" . $owner_len . ".10s [...]
                    %.0f ";
        _cupsLangPrintf(stdout,
                    $jobs_printf . _("bytes"),
            rankstr, jobuser, jobpriority, jobid, jobname, 
            1024.0 * jobsize);
- use the same $jobs_printf string to format the header output

I'm aware that what I propose means bigger changes than "just" changing
the printf string in a translation file. OTOH, it will fix this issue for
all languages at once.

Link: http://www.cups.org/str.php?L3822
Version: 1.4.6
Fix Version: None





More information about the cups-devel mailing list