Printers preflet: Properly handle plurals for the pending jobs

Change-Id: Iac7cad00df0d52060fbc19fcc5551e21da66f152
Reviewed-on: https://review.haiku-os.org/713
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Niels Sascha Reedijk 2018-11-18 15:58:13 +01:00 committed by Adrien Destugues
parent 7d5acf5763
commit 39c461f50c

View File

@ -19,6 +19,7 @@
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Resources.h> #include <Resources.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include "pr_server.h" #include "pr_server.h"
#include "Messages.h" #include "Messages.h"
@ -509,18 +510,16 @@ PrinterItem::Node()
void void
PrinterItem::UpdatePendingJobs() PrinterItem::UpdatePendingJobs()
{ {
if (fFolder) { uint32 pendingJobs = 0;
uint32 pendingJobs = fFolder->CountJobs(); if (fFolder)
if (pendingJobs == 1) { pendingJobs = fFolder->CountJobs();
fPendingJobs = B_TRANSLATE("1 pending job");
return; static BStringFormat format(B_TRANSLATE("{0, plural,"
} else if (pendingJobs > 1) { "=0{No pending jobs}"
fPendingJobs = ""; "=1{1 pending job}"
fPendingJobs << pendingJobs << B_TRANSLATE(" pending jobs"); "other{# pending jobs}}"));
return;
} format.Format(fPendingJobs, pendingJobs);
}
fPendingJobs = B_TRANSLATE("No pending jobs");
} }