From 7457ccb4b2f4786525d3b7bda42598487d57ab7d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 13 Aug 2018 20:49:00 -0400 Subject: [PATCH] BMessageFormat: Rename to BStringFormat. The ICU class is named MessageFormat, but on Haiku, it sounds too much like something related to BMessage (which it isn't in the slightest) and not part of the Locale system. It works almost entirely with BStrings, so naming it BStringFormat makes much more sense. OK'ed by PulkoMandy and Humdinger. --- .../{MessageFormat.h => StringFormat.h} | 14 ++++----- .../notifier/NotifierFilter.cpp | 6 ++-- src/add-ons/tracker/zipomatic/ZipOMatic.cpp | 4 +-- .../tracker/zipomatic/ZipOMaticWindow.cpp | 4 +-- src/apps/aboutsystem/AboutSystem.cpp | 4 +-- src/apps/diskusage/InfoWindow.cpp | 4 +-- src/apps/diskusage/StatusView.cpp | 4 +-- .../haikudepot/ui/PackageContentsView.cpp | 2 +- src/apps/haikudepot/ui/PackageListView.cpp | 4 +-- src/apps/magnify/Magnify.cpp | 4 +-- src/apps/mediaconverter/MediaConverterApp.cpp | 4 +-- src/apps/mediaconverter/MediaFileInfo.cpp | 8 ++--- src/apps/mediaplayer/InfoWin.cpp | 4 +-- src/apps/pairs/PairsWindow.cpp | 4 +-- src/apps/poorman/StatusSlider.cpp | 4 +-- src/apps/poorman/StatusSlider.h | 6 ++-- src/kits/locale/Jamfile | 2 +- .../{MessageFormat.cpp => StringFormat.cpp} | 14 ++++----- src/kits/shared/StringForSize.cpp | 4 +-- src/kits/tracker/CountView.cpp | 4 +-- src/kits/tracker/FSUtils.cpp | 4 +-- src/kits/tracker/InfoWindow.cpp | 6 ++-- src/kits/tracker/WidgetAttributeText.cpp | 4 +-- .../filetypes/ApplicationTypesWindow.cpp | 4 +-- src/servers/mail/DeskbarView.cpp | 4 +-- src/servers/mail/MailDaemonApplication.cpp | 6 ++-- src/tests/kits/locale/Jamfile | 2 +- src/tests/kits/locale/LocaleKitTestAddon.cpp | 4 +-- ...ageFormatTest.cpp => StringFormatTest.cpp} | 30 +++++++++---------- ...MessageFormatTest.h => StringFormatTest.h} | 10 +++---- 30 files changed, 89 insertions(+), 89 deletions(-) rename headers/os/locale/{MessageFormat.h => StringFormat.h} (71%) rename src/kits/locale/{MessageFormat.cpp => StringFormat.cpp} (80%) rename src/tests/kits/locale/{MessageFormatTest.cpp => StringFormatTest.cpp} (82%) rename src/tests/kits/locale/{MessageFormatTest.h => StringFormatTest.h} (59%) diff --git a/headers/os/locale/MessageFormat.h b/headers/os/locale/StringFormat.h similarity index 71% rename from headers/os/locale/MessageFormat.h rename to headers/os/locale/StringFormat.h index 38fb2054ad..0e5947a6a1 100644 --- a/headers/os/locale/MessageFormat.h +++ b/headers/os/locale/StringFormat.h @@ -6,8 +6,8 @@ * Adrien Destugues, pulkomandy@pulkomandy.tk * John Scipione, jscipione@gmail.com */ -#ifndef _B_MESSAGE_FORMAT_H_ -#define _B_MESSAGE_FORMAT_H_ +#ifndef _B_STRING_FORMAT_H_ +#define _B_STRING_FORMAT_H_ #include @@ -22,12 +22,12 @@ namespace U_ICU_NAMESPACE { } -class BMessageFormat: public BFormat { +class BStringFormat : public BFormat { public: - BMessageFormat(const BLanguage& language, + BStringFormat(const BLanguage& language, const BString pattern); - BMessageFormat(const BString pattern); - ~BMessageFormat(); + BStringFormat(const BString pattern); + ~BStringFormat(); status_t InitCheck(); @@ -41,4 +41,4 @@ private: }; -#endif // _B_MESSAGE_FORMAT_H_ +#endif // _B_STRING_FORMAT_H_ diff --git a/src/add-ons/mail_daemon/inbound_filters/notifier/NotifierFilter.cpp b/src/add-ons/mail_daemon/inbound_filters/notifier/NotifierFilter.cpp index a302aae038..5739738825 100644 --- a/src/add-ons/mail_daemon/inbound_filters/notifier/NotifierFilter.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/notifier/NotifierFilter.cpp @@ -15,9 +15,9 @@ #include #include #include -#include #include #include +#include #include @@ -77,7 +77,7 @@ NotifyFilter::MailboxSynchronized(status_t status) system_beep("New E-mail"); if ((fStrategy & NOTIFY_ALERT) != 0) { - BMessageFormat format(B_TRANSLATE( + BStringFormat format(B_TRANSLATE( "You have {0, plural, one{One new message} other{# new messages}} " "for %account.")); @@ -107,7 +107,7 @@ NotifyFilter::MailboxSynchronized(status_t status) } if ((fStrategy & NOTIFY_NOTIFICATION) != 0) { - BMessageFormat format(B_TRANSLATE("{0, plural, " + BStringFormat format(B_TRANSLATE("{0, plural, " "one{One new message} other{# new messages}}")); BString message; diff --git a/src/add-ons/tracker/zipomatic/ZipOMatic.cpp b/src/add-ons/tracker/zipomatic/ZipOMatic.cpp index 44ad6b50fa..6c4df7741d 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMatic.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMatic.cpp @@ -10,8 +10,8 @@ #include "ZipOMatic.h" #include -#include #include +#include #include #include "ZipOMaticMisc.h" @@ -154,7 +154,7 @@ ZipOMatic::QuitRequested(void) // The multi-zipper case differs from the single-zipper case // in that zippers are not paused while the BAlert is up. - static BMessageFormat format( + static BStringFormat format( B_TRANSLATE("You have {0, plural, one{# Zip-O-Matic} " "other{# Zip-O-Matics}} running.\n\n")); diff --git a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp index 76f2263f71..b7b5c34d83 100644 --- a/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp +++ b/src/add-ons/tracker/zipomatic/ZipOMaticWindow.cpp @@ -21,12 +21,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include "ZipOMatic.h" #include "ZipOMaticActivity.h" @@ -152,7 +152,7 @@ ZippoWindow::MessageReceived(BMessage* message) // being created (added to) or if we're updating an // already existing archive. - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{# file added.} other{# files added.}}")); BString output; format.Format(output, fFileCount); diff --git a/src/apps/aboutsystem/AboutSystem.cpp b/src/apps/aboutsystem/AboutSystem.cpp index d8820db8d6..72439db87a 100644 --- a/src/apps/aboutsystem/AboutSystem.cpp +++ b/src/apps/aboutsystem/AboutSystem.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -471,7 +471,7 @@ AboutView::AboutView() B_ALIGN_VERTICAL_UNSET)); // CPU count, type and clock speed - static BMessageFormat format(B_TRANSLATE_COMMENT( + static BStringFormat format(B_TRANSLATE_COMMENT( "{0, plural, one{Processor:} other{# Processors:}}", "\"Processor:\" or \"2 Processors:\"")); diff --git a/src/apps/diskusage/InfoWindow.cpp b/src/apps/diskusage/InfoWindow.cpp index ae43a4c972..f74e0a6597 100644 --- a/src/apps/diskusage/InfoWindow.cpp +++ b/src/apps/diskusage/InfoWindow.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent) BString name; if (f->count > 0) { // This is a directory, include file count information - static BMessageFormat format(B_TRANSLATE( + static BStringFormat format(B_TRANSLATE( "%size% in {0, plural, one{# file} other{# files}}")); format.Format(name, f->count); diff --git a/src/apps/diskusage/StatusView.cpp b/src/apps/diskusage/StatusView.cpp index e1aa911df6..0272d62641 100644 --- a/src/apps/diskusage/StatusView.cpp +++ b/src/apps/diskusage/StatusView.cpp @@ -17,9 +17,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -152,7 +152,7 @@ StatusView::ShowInfo(const FileInfo* info) fSizeView->SetText(label); if (info->count > 0) { - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{# file} other{# files}}")); BString label; format.Format(label, info->count); diff --git a/src/apps/haikudepot/ui/PackageContentsView.cpp b/src/apps/haikudepot/ui/PackageContentsView.cpp index 17f0384325..5d2e0c86af 100644 --- a/src/apps/haikudepot/ui/PackageContentsView.cpp +++ b/src/apps/haikudepot/ui/PackageContentsView.cpp @@ -11,13 +11,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include diff --git a/src/apps/haikudepot/ui/PackageListView.cpp b/src/apps/haikudepot/ui/PackageListView.cpp index e924639d1b..86f8979cb6 100644 --- a/src/apps/haikudepot/ui/PackageListView.cpp +++ b/src/apps/haikudepot/ui/PackageListView.cpp @@ -14,8 +14,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -716,7 +716,7 @@ public: private: BString _GetLabel() const { - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{# item} other{# items}}")); BString label; diff --git a/src/apps/magnify/Magnify.cpp b/src/apps/magnify/Magnify.cpp index c411a81b98..949f538d82 100644 --- a/src/apps/magnify/Magnify.cpp +++ b/src/apps/magnify/Magnify.cpp @@ -22,13 +22,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -1062,7 +1062,7 @@ TInfoView::Draw(BRect updateRect) MovePenTo(15 + fPopUp->Bounds().Width(), fFontHeight + 5); - static BMessageFormat format(B_TRANSLATE("%width x %height @ {0, plural, " + static BStringFormat format(B_TRANSLATE("%width x %height @ {0, plural, " "one{# pixel/pixel} other{# pixels/pixel}}")); BString dimensionsInfo; diff --git a/src/apps/mediaconverter/MediaConverterApp.cpp b/src/apps/mediaconverter/MediaConverterApp.cpp index 4f64f13526..b97817060d 100644 --- a/src/apps/mediaconverter/MediaConverterApp.cpp +++ b/src/apps/mediaconverter/MediaConverterApp.cpp @@ -15,10 +15,10 @@ #include #include #include -#include #include #include #include +#include #include #include "MediaConverterWindow.h" @@ -131,7 +131,7 @@ MediaConverterApp::RefsReceived(BMessage* msg) if (errors) { BString alertText; - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{The file was not recognized as a supported media file:} " "other{# files were not recognized as supported media files:}}")); format.Format(alertText, errors); diff --git a/src/apps/mediaconverter/MediaFileInfo.cpp b/src/apps/mediaconverter/MediaFileInfo.cpp index 127c96c928..dcf3975826 100644 --- a/src/apps/mediaconverter/MediaFileInfo.cpp +++ b/src/apps/mediaconverter/MediaFileInfo.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #undef B_TRANSLATION_CONTEXT @@ -53,7 +53,7 @@ MediaFileInfo::LoadInfo(BMediaFile* file) if (ret != B_OK) return ret; - static BMessageFormat frameFormat(B_TRANSLATE( + static BStringFormat frameFormat(B_TRANSLATE( "{0, plural, one{# frame} other{# frames}}")); if (format.IsVideo()) { @@ -97,12 +97,12 @@ MediaFileInfo::LoadInfo(BMediaFile* file) BString details; if (bytesPerSample == 1 || bytesPerSample == 2) { - static BMessageFormat bitFormat( + static BStringFormat bitFormat( B_TRANSLATE("{0, plural, one{# bit} other{# bits}}")); bitFormat.Format(details, bytesPerSample * 8); details.SetToFormat(B_TRANSLATE("%d bit "), bytesPerSample * 8); } else { - static BMessageFormat bitFormat( + static BStringFormat bitFormat( B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}")); bitFormat.Format(details, bytesPerSample); } diff --git a/src/apps/mediaplayer/InfoWin.cpp b/src/apps/mediaplayer/InfoWin.cpp index a14babdd66..ed58658de4 100644 --- a/src/apps/mediaplayer/InfoWin.cpp +++ b/src/apps/mediaplayer/InfoWin.cpp @@ -20,11 +20,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -486,7 +486,7 @@ InfoWin::_UpdateAudio() info << bitString << " "; } - static BMessageFormat channelFormat(B_TRANSLATE( + static BStringFormat channelFormat(B_TRANSLATE( "{0, plural, =1{Mono} =2{Stereo} other{# Channels}}")); channelFormat.Format(info, channelCount); diff --git a/src/apps/pairs/PairsWindow.cpp b/src/apps/pairs/PairsWindow.cpp index e0379e023f..34e4964238 100644 --- a/src/apps/pairs/PairsWindow.cpp +++ b/src/apps/pairs/PairsWindow.cpp @@ -22,9 +22,9 @@ #include #include #include -#include #include #include +#include #include #include "Pairs.h" @@ -305,7 +305,7 @@ PairsWindow::MessageReceived(BMessage* message) // Note: in english the singular form is never used, but other // languages behave differently. - static BMessageFormat format(B_TRANSLATE( + static BStringFormat format(B_TRANSLATE( "You completed the game in " "{0, plural, one{# click} other{# clicks}}.\n")); format.Format(strAbout, fButtonClicks); diff --git a/src/apps/poorman/StatusSlider.cpp b/src/apps/poorman/StatusSlider.cpp index d8129ea874..d1d87c6077 100644 --- a/src/apps/poorman/StatusSlider.cpp +++ b/src/apps/poorman/StatusSlider.cpp @@ -4,11 +4,11 @@ * Started: 5/14/2004 * Version: 0.1 */ - + #include "StatusSlider.h" -#include +#include StatusSlider::StatusSlider(const char* name, const char* label, diff --git a/src/apps/poorman/StatusSlider.h b/src/apps/poorman/StatusSlider.h index 69be9a074e..8d2d6e9964 100644 --- a/src/apps/poorman/StatusSlider.h +++ b/src/apps/poorman/StatusSlider.h @@ -4,15 +4,15 @@ * Started: 5/14/2004 * Version: 0.1 */ - + #ifndef STATUS_SLIDER #define STATUS_SLIDER //#define BEOS_R5_COMPATIBLE -#include #include #include +#include class StatusSlider: public BSlider { @@ -28,7 +28,7 @@ public: private: mutable char fPattern[256]; - BMessageFormat fFormat; + BStringFormat fFormat; mutable BString fStr; }; diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index 057687f556..d6fad85790 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -28,8 +28,8 @@ local sources = DateFormat.cpp DateTimeFormat.cpp DurationFormat.cpp - MessageFormat.cpp NumberFormat.cpp + StringFormat.cpp TimeFormat.cpp TimeUnitFormat.cpp Format.cpp # Used by some of the above. diff --git a/src/kits/locale/MessageFormat.cpp b/src/kits/locale/StringFormat.cpp similarity index 80% rename from src/kits/locale/MessageFormat.cpp rename to src/kits/locale/StringFormat.cpp index 274d4ac8a7..e71190aace 100644 --- a/src/kits/locale/MessageFormat.cpp +++ b/src/kits/locale/StringFormat.cpp @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include @@ -19,35 +19,35 @@ #include -BMessageFormat::BMessageFormat(const BLanguage& language, const BString pattern) +BStringFormat::BStringFormat(const BLanguage& language, const BString pattern) : BFormat(language, BFormattingConventions()) { _Initialize(UnicodeString::fromUTF8(pattern.String())); } -BMessageFormat::BMessageFormat(const BString pattern) +BStringFormat::BStringFormat(const BString pattern) : BFormat() { _Initialize(UnicodeString::fromUTF8(pattern.String())); } -BMessageFormat::~BMessageFormat() +BStringFormat::~BStringFormat() { delete fFormatter; } status_t -BMessageFormat::InitCheck() +BStringFormat::InitCheck() { return fInitStatus; } status_t -BMessageFormat::Format(BString& output, const int64 arg) const +BStringFormat::Format(BString& output, const int64 arg) const { if (fInitStatus != B_OK) return fInitStatus; @@ -72,7 +72,7 @@ BMessageFormat::Format(BString& output, const int64 arg) const status_t -BMessageFormat::_Initialize(const UnicodeString& pattern) +BStringFormat::_Initialize(const UnicodeString& pattern) { fInitStatus = B_OK; UErrorCode error = U_ZERO_ERROR; diff --git a/src/kits/shared/StringForSize.cpp b/src/kits/shared/StringForSize.cpp index 3a308ef239..9862ff8f29 100644 --- a/src/kits/shared/StringForSize.cpp +++ b/src/kits/shared/StringForSize.cpp @@ -7,7 +7,7 @@ #include -#include +#include #include using BPrivate::gSystemCatalog; @@ -29,7 +29,7 @@ string_for_size(double size, char* string, size_t stringSize) "{0, plural, one{# byte} other{# bytes}}"); BString tmp; - BMessageFormat format( + BStringFormat format( gSystemCatalog.GetString(trKey, B_TRANSLATION_CONTEXT)); format.Format(tmp, (int)size); diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index 5c5bfc14db..27620e4a3e 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -41,7 +41,7 @@ All rights reserved. #include #include #include -#include +#include #include "AutoLock.h" #include "Bitmaps.h" @@ -217,7 +217,7 @@ BCountView::Draw(BRect updateRect) if (fLastCount == 0) itemString << B_TRANSLATE("no items"); else { - static BMessageFormat format(B_TRANSLATE_COMMENT( + static BStringFormat format(B_TRANSLATE_COMMENT( "{0, plural, one{# item} other{# items}}", "Number of selected items: \"1 item\" or \"2 items\"")); format.Format(itemString, fLastCount); diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 5399efcd33..23467f16b8 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -58,12 +58,12 @@ respective holders. All rights reserved. #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -2092,7 +2092,7 @@ FileStatToString(StatStruct* stat, char* buffer, int32 length) localtime_r(&stat->st_mtime, &timeData); BString size; - static BMessageFormat format( + static BStringFormat format( B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}")); format.Format(size, stat->st_size); uint32 pos = snprintf(buffer, length, "\n\t(%s ", size.String()); diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index 6ade764aee..346d394b2c 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -47,7 +47,6 @@ All rights reserved. #include #include #include -#include #include #include #include @@ -57,6 +56,7 @@ All rights reserved. #include #include #include +#include #include #include #include @@ -674,9 +674,9 @@ BInfoWindow::MessageReceived(BMessage* message) void BInfoWindow::GetSizeString(BString& result, off_t size, int32 fileCount) { - static BMessageFormat sizeFormat(B_TRANSLATE( + static BStringFormat sizeFormat(B_TRANSLATE( "{0, plural, one{(# byte)} other{(# bytes)}}")); - static BMessageFormat countFormat(B_TRANSLATE( + static BStringFormat countFormat(B_TRANSLATE( "{0, plural, one{for # file} other{for # files}}")); char sizeBuffer[128]; diff --git a/src/kits/tracker/WidgetAttributeText.cpp b/src/kits/tracker/WidgetAttributeText.cpp index b5bf3896ae..d36d425bd8 100644 --- a/src/kits/tracker/WidgetAttributeText.cpp +++ b/src/kits/tracker/WidgetAttributeText.cpp @@ -49,9 +49,9 @@ All rights reserved. #include #include #include -#include #include #include +#include #include #include #include @@ -107,7 +107,7 @@ TruncFileSizeBase(BString* outString, int64 value, const View* view, *outString = "-"; return view->StringWidth("-"); } else if (value < kKBSize) { - static BMessageFormat format(B_TRANSLATE( + static BStringFormat format(B_TRANSLATE( "{0, plural, one{# byte} other{# bytes}}")); format.Format(buffer, value); if (view->StringWidth(buffer.String()) > width) diff --git a/src/preferences/filetypes/ApplicationTypesWindow.cpp b/src/preferences/filetypes/ApplicationTypesWindow.cpp index 0afb8632f1..4f69fa85bd 100644 --- a/src/preferences/filetypes/ApplicationTypesWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypesWindow.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -346,7 +346,7 @@ ApplicationTypesWindow::_RemoveUninstalled() progressWindow->PostMessage(B_QUIT_REQUESTED); - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{# Application type could be removed} " "other{# Application types could be removed}}")); BString message; diff --git a/src/servers/mail/DeskbarView.cpp b/src/servers/mail/DeskbarView.cpp index f5cbaea90e..36012a219a 100644 --- a/src/servers/mail/DeskbarView.cpp +++ b/src/servers/mail/DeskbarView.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -546,7 +546,7 @@ DeskbarView::_BuildMenu() // The New E-mail query if (fNewMessages > 0) { - static BMessageFormat format(B_TRANSLATE( + static BStringFormat format(B_TRANSLATE( "{0, plural, one{# new message} other{# new messages}}")); BString string; format.Format(string, fNewMessages); diff --git a/src/servers/mail/MailDaemonApplication.cpp b/src/servers/mail/MailDaemonApplication.cpp index 0a9c486e6c..5db9cf651c 100644 --- a/src/servers/mail/MailDaemonApplication.cpp +++ b/src/servers/mail/MailDaemonApplication.cpp @@ -20,12 +20,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include @@ -350,7 +350,7 @@ MailDaemonApplication::MessageReceived(BMessage* msg) case 'numg': { - static BMessageFormat format(B_TRANSLATE("{0, plural, " + static BStringFormat format(B_TRANSLATE("{0, plural, " "one{# new message} other{# new messages}} for %name\n")); int32 numMessages = msg->FindInt32("num_messages"); @@ -797,7 +797,7 @@ MailDaemonApplication::_UpdateNewMessagesNotification() { BString title; if (fNewMessages > 0) { - BMessageFormat format(B_TRANSLATE( + BStringFormat format(B_TRANSLATE( "{0, plural, one{One new message} other{# new messages}}")); format.Format(title, fNewMessages); diff --git a/src/tests/kits/locale/Jamfile b/src/tests/kits/locale/Jamfile index 20e1e4b682..5d29c72815 100644 --- a/src/tests/kits/locale/Jamfile +++ b/src/tests/kits/locale/Jamfile @@ -50,8 +50,8 @@ UnitTestLib localekittest.so : DateFormatTest.cpp DurationFormatTest.cpp LanguageTest.cpp - MessageFormatTest.cpp RelativeDateTimeFormatTest.cpp + StringFormatTest.cpp UnicodeCharTest.cpp : be [ TargetLibstdc++ ] diff --git a/src/tests/kits/locale/LocaleKitTestAddon.cpp b/src/tests/kits/locale/LocaleKitTestAddon.cpp index 01ea7d2144..f2649de282 100644 --- a/src/tests/kits/locale/LocaleKitTestAddon.cpp +++ b/src/tests/kits/locale/LocaleKitTestAddon.cpp @@ -11,8 +11,8 @@ #include "DateFormatTest.h" #include "DurationFormatTest.h" #include "LanguageTest.h" -#include "MessageFormatTest.h" #include "RelativeDateTimeFormatTest.h" +#include "StringFormatTest.h" #include "UnicodeCharTest.h" @@ -25,7 +25,7 @@ getTestSuite() DateFormatTest::AddTests(*suite); DurationFormatTest::AddTests(*suite); LanguageTest::AddTests(*suite); - MessageFormatTest::AddTests(*suite); + StringFormatTest::AddTests(*suite); RelativeDateTimeFormatTest::AddTests(*suite); UnicodeCharTest::AddTests(*suite); diff --git a/src/tests/kits/locale/MessageFormatTest.cpp b/src/tests/kits/locale/StringFormatTest.cpp similarity index 82% rename from src/tests/kits/locale/MessageFormatTest.cpp rename to src/tests/kits/locale/StringFormatTest.cpp index 7b70223218..862e649b24 100644 --- a/src/tests/kits/locale/MessageFormatTest.cpp +++ b/src/tests/kits/locale/StringFormatTest.cpp @@ -4,27 +4,27 @@ */ -#include "MessageFormatTest.h" +#include "StringFormatTest.h" #include -#include +#include #include #include -MessageFormatTest::MessageFormatTest() +StringFormatTest::StringFormatTest() { } -MessageFormatTest::~MessageFormatTest() +StringFormatTest::~StringFormatTest() { } void -MessageFormatTest::TestFormat() +StringFormatTest::TestFormat() { BString output; @@ -82,7 +82,7 @@ MessageFormatTest::TestFormat() NextSubTest(); output.Truncate(0); BLanguage language(tests[i].locale); - BMessageFormat formatter(language, tests[i].pattern); + BStringFormat formatter(language, tests[i].pattern); result = formatter.Format(output, tests[i].number); CPPUNIT_ASSERT_EQUAL(B_OK, result); @@ -92,7 +92,7 @@ MessageFormatTest::TestFormat() void -MessageFormatTest::TestBogus() +StringFormatTest::TestBogus() { struct Test { const char* pattern; @@ -113,7 +113,7 @@ MessageFormatTest::TestBogus() status_t result; BString output; - BMessageFormat formatter(tests[i].pattern); + BStringFormat formatter(tests[i].pattern); CPPUNIT_ASSERT(formatter.InitCheck() != B_OK); result = formatter.Format(output, 1); @@ -126,14 +126,14 @@ MessageFormatTest::TestBogus() /*static*/ void -MessageFormatTest::AddTests(BTestSuite& parent) +StringFormatTest::AddTests(BTestSuite& parent) { - CppUnit::TestSuite& suite = *new CppUnit::TestSuite("MessageFormatTest"); + CppUnit::TestSuite& suite = *new CppUnit::TestSuite("StringFormatTest"); - suite.addTest(new CppUnit::TestCaller( - "MessageFormatTest::TestFormat", &MessageFormatTest::TestFormat)); - suite.addTest(new CppUnit::TestCaller( - "MessageFormatTest::TestBogus", &MessageFormatTest::TestBogus)); + suite.addTest(new CppUnit::TestCaller( + "StringFormatTest::TestFormat", &StringFormatTest::TestFormat)); + suite.addTest(new CppUnit::TestCaller( + "StringFormatTest::TestBogus", &StringFormatTest::TestBogus)); - parent.addTest("MessageFormatTest", &suite); + parent.addTest("StringFormatTest", &suite); } diff --git a/src/tests/kits/locale/MessageFormatTest.h b/src/tests/kits/locale/StringFormatTest.h similarity index 59% rename from src/tests/kits/locale/MessageFormatTest.h rename to src/tests/kits/locale/StringFormatTest.h index 4e3c56d751..be3c1bba74 100644 --- a/src/tests/kits/locale/MessageFormatTest.h +++ b/src/tests/kits/locale/StringFormatTest.h @@ -2,18 +2,18 @@ * Copyright 2014 Haiku, Inc. * Distributed under the terms of the MIT License. */ -#ifndef MESSAGE_FORMAT_TEST_H -#define MESSAGE_FORMAT_TEST_H +#ifndef STRING_FORMAT_TEST +#define STRING_FORMAT_TEST #include #include -class MessageFormatTest: public BTestCase { +class StringFormatTest: public BTestCase { public: - MessageFormatTest(); - virtual ~MessageFormatTest(); + StringFormatTest(); + virtual ~StringFormatTest(); void TestFormat(); void TestBogus();