From 4b947a07d31f8823c24d5c40a3e023c5ccefae33 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 8 Oct 2014 17:08:41 +0200 Subject: [PATCH] More BMessageFormat rework. I'm stopping this now, I heard we want to leave those as GCI tasks. --- src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp | 14 +++++--------- .../filetypes/ApplicationTypesWindow.cpp | 12 +++++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp index 197550e018..76f2263f71 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -151,17 +152,12 @@ ZippoWindow::MessageReceived(BMessage* message) // being created (added to) or if we're updating an // already existing archive. + static BMessageFormat format(B_TRANSLATE("{0, plural, " + "one{# file added.} other{# files added.}}")); BString output; - fFileCount++; - BString count; - count << fFileCount; + format.Format(output, fFileCount); - if (fFileCount == 1) { - output << B_TRANSLATE("1 file added."); - } else { - output << B_TRANSLATE("%ld files added."); - output.ReplaceFirst("%ld", count.String()); - } + fFileCount++; fZipOutputView->SetText(output.String()); } else { diff --git a/src/preferences/filetypes/ApplicationTypesWindow.cpp b/src/preferences/filetypes/ApplicationTypesWindow.cpp index cc56ab5b73..936dd90663 100644 --- a/src/preferences/filetypes/ApplicationTypesWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypesWindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -353,11 +354,12 @@ ApplicationTypesWindow::_RemoveUninstalled() progressWindow->PostMessage(B_QUIT_REQUESTED); - char message[512]; - // TODO: Use ICU to properly format this. - snprintf(message, sizeof(message), - B_TRANSLATE("%ld Application type%s could be removed."), - removed, removed == 1 ? "" : "s"); + static BMessageFormat format(B_TRANSLATE("{0, plural, " + "one{# Application type could be removed} " + "other{# Application types could be removed}}")); + BString message; + format.Format(message, removed); + error_alert(message, B_OK, B_INFO_ALERT); }