From be93029899fb6fc32eabbaa0647f4716d03737f0 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 8 Oct 2014 12:04:06 +0200 Subject: [PATCH] More uses of BMessageFormat. --- src/apps/diskusage/StatusView.cpp | 9 +++++---- src/apps/magnify/Magnify.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/apps/diskusage/StatusView.cpp b/src/apps/diskusage/StatusView.cpp index 1c0c159a38..734d8b3de2 100644 --- a/src/apps/diskusage/StatusView.cpp +++ b/src/apps/diskusage/StatusView.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -83,7 +84,7 @@ StatusView::StatusView() .Add(fCountView) .Add(divider2) .Add(fSizeView) - .End() + .End() .End() .AddStrut(kSmallHMargin) .Add(fRefreshBtn) @@ -150,9 +151,9 @@ StatusView::ShowInfo(const FileInfo* info) fSizeView->SetText(label); if (info->count > 0) { - char label[256]; - snprintf(label, sizeof(label), (info->count == 1) ? - B_TRANSLATE("%d file") : B_TRANSLATE("%d files"), info->count); + BString label; + BMessageFormat().Format(label, B_TRANSLATE("{0, plural, one{# file}, " + "other{# files}}"), info->count); fCountView->SetText(label); } else { fCountView->SetText(kEmptyStr); diff --git a/src/apps/magnify/Magnify.cpp b/src/apps/magnify/Magnify.cpp index 85184c99bd..9e9599de31 100644 --- a/src/apps/magnify/Magnify.cpp +++ b/src/apps/magnify/Magnify.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -828,17 +829,16 @@ TInfoView::Draw(BRect updateRect) MovePenTo(10, fFontHeight + 5); - BString dimensionsInfo( - B_TRANSLATE("%width x %height @ %pixelSize pixels/pixel")); + BString dimensionsInfo; + BMessageFormat().Format(dimensionsInfo, + B_TRANSLATE("%width x %height @ {0, plural, one{# pixel/pixel} " + "other{# pixels/pixel}}"), pixelSize); BString rep; rep << hPixelCount; dimensionsInfo.ReplaceAll("%width", rep); rep = ""; rep << vPixelCount; dimensionsInfo.ReplaceAll("%height", rep); - rep = ""; - rep << pixelSize; - dimensionsInfo.ReplaceAll("%pixelSize", rep); invalRect.Set(10, 5, 10 + StringWidth(fInfoStr), fFontHeight+7); SetHighColor(ViewColor()); FillRect(invalRect);