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.
This commit is contained in:
Augustin Cavalier
2018-08-13 20:49:00 -04:00
parent 8906767241
commit 7457ccb4b2
30 changed files with 89 additions and 89 deletions
@@ -6,8 +6,8 @@
* Adrien Destugues, pulkomandy@pulkomandy.tk * Adrien Destugues, pulkomandy@pulkomandy.tk
* John Scipione, jscipione@gmail.com * John Scipione, jscipione@gmail.com
*/ */
#ifndef _B_MESSAGE_FORMAT_H_ #ifndef _B_STRING_FORMAT_H_
#define _B_MESSAGE_FORMAT_H_ #define _B_STRING_FORMAT_H_
#include <Format.h> #include <Format.h>
@@ -22,12 +22,12 @@ namespace U_ICU_NAMESPACE {
} }
class BMessageFormat: public BFormat { class BStringFormat : public BFormat {
public: public:
BMessageFormat(const BLanguage& language, BStringFormat(const BLanguage& language,
const BString pattern); const BString pattern);
BMessageFormat(const BString pattern); BStringFormat(const BString pattern);
~BMessageFormat(); ~BStringFormat();
status_t InitCheck(); status_t InitCheck();
@@ -41,4 +41,4 @@ private:
}; };
#endif // _B_MESSAGE_FORMAT_H_ #endif // _B_STRING_FORMAT_H_
@@ -15,9 +15,9 @@
#include <Beep.h> #include <Beep.h>
#include <Catalog.h> #include <Catalog.h>
#include <Message.h> #include <Message.h>
#include <MessageFormat.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <MailFilter.h> #include <MailFilter.h>
@@ -77,7 +77,7 @@ NotifyFilter::MailboxSynchronized(status_t status)
system_beep("New E-mail"); system_beep("New E-mail");
if ((fStrategy & NOTIFY_ALERT) != 0) { if ((fStrategy & NOTIFY_ALERT) != 0) {
BMessageFormat format(B_TRANSLATE( BStringFormat format(B_TRANSLATE(
"You have {0, plural, one{One new message} other{# new messages}} " "You have {0, plural, one{One new message} other{# new messages}} "
"for %account.")); "for %account."));
@@ -107,7 +107,7 @@ NotifyFilter::MailboxSynchronized(status_t status)
} }
if ((fStrategy & NOTIFY_NOTIFICATION) != 0) { if ((fStrategy & NOTIFY_NOTIFICATION) != 0) {
BMessageFormat format(B_TRANSLATE("{0, plural, " BStringFormat format(B_TRANSLATE("{0, plural, "
"one{One new message} other{# new messages}}")); "one{One new message} other{# new messages}}"));
BString message; BString message;
+2 -2
View File
@@ -10,8 +10,8 @@
#include "ZipOMatic.h" #include "ZipOMatic.h"
#include <Alert.h> #include <Alert.h>
#include <MessageFormat.h>
#include <Roster.h> #include <Roster.h>
#include <StringFormat.h>
#include <TrackerAddOnAppLaunch.h> #include <TrackerAddOnAppLaunch.h>
#include "ZipOMaticMisc.h" #include "ZipOMaticMisc.h"
@@ -154,7 +154,7 @@ ZipOMatic::QuitRequested(void)
// The multi-zipper case differs from the single-zipper case // The multi-zipper case differs from the single-zipper case
// in that zippers are not paused while the BAlert is up. // 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} " B_TRANSLATE("You have {0, plural, one{# Zip-O-Matic} "
"other{# Zip-O-Matics}} running.\n\n")); "other{# Zip-O-Matics}} running.\n\n"));
@@ -21,12 +21,12 @@
#include <GroupLayout.h> #include <GroupLayout.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <Locale.h> #include <Locale.h>
#include <MessageFormat.h>
#include <Path.h> #include <Path.h>
#include <Roster.h> #include <Roster.h>
#include <Screen.h> #include <Screen.h>
#include <SeparatorView.h> #include <SeparatorView.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include "ZipOMatic.h" #include "ZipOMatic.h"
#include "ZipOMaticActivity.h" #include "ZipOMaticActivity.h"
@@ -152,7 +152,7 @@ ZippoWindow::MessageReceived(BMessage* message)
// being created (added to) or if we're updating an // being created (added to) or if we're updating an
// already existing archive. // already existing archive.
static BMessageFormat format(B_TRANSLATE("{0, plural, " static BStringFormat format(B_TRANSLATE("{0, plural, "
"one{# file added.} other{# files added.}}")); "one{# file added.} other{# files added.}}"));
BString output; BString output;
format.Format(output, fFileCount); format.Format(output, fFileCount);
+2 -2
View File
@@ -29,7 +29,6 @@
#include <Font.h> #include <Font.h>
#include <fs_attr.h> #include <fs_attr.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <MessageFormat.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <Messenger.h> #include <Messenger.h>
#include <ObjectList.h> #include <ObjectList.h>
@@ -40,6 +39,7 @@
#include <Screen.h> #include <Screen.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <StringList.h> #include <StringList.h>
#include <StringView.h> #include <StringView.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
@@ -471,7 +471,7 @@ AboutView::AboutView()
B_ALIGN_VERTICAL_UNSET)); B_ALIGN_VERTICAL_UNSET));
// CPU count, type and clock speed // CPU count, type and clock speed
static BMessageFormat format(B_TRANSLATE_COMMENT( static BStringFormat format(B_TRANSLATE_COMMENT(
"{0, plural, one{Processor:} other{# Processors:}}", "{0, plural, one{Processor:} other{# Processors:}}",
"\"Processor:\" or \"2 Processors:\"")); "\"Processor:\" or \"2 Processors:\""));
+2 -2
View File
@@ -17,7 +17,7 @@
#include <vector> #include <vector>
#include <Catalog.h> #include <Catalog.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include <StringForSize.h> #include <StringForSize.h>
#include <StringView.h> #include <StringView.h>
#include <Bitmap.h> #include <Bitmap.h>
@@ -81,7 +81,7 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
BString name; BString name;
if (f->count > 0) { if (f->count > 0) {
// This is a directory, include file count information // 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}}")); "%size% in {0, plural, one{# file} other{# files}}"));
format.Format(name, f->count); format.Format(name, f->count);
+2 -2
View File
@@ -17,9 +17,9 @@
#include <Catalog.h> #include <Catalog.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <MessageFormat.h>
#include <Node.h> #include <Node.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <StringForSize.h> #include <StringForSize.h>
#include <StringView.h> #include <StringView.h>
@@ -152,7 +152,7 @@ StatusView::ShowInfo(const FileInfo* info)
fSizeView->SetText(label); fSizeView->SetText(label);
if (info->count > 0) { if (info->count > 0) {
static BMessageFormat format(B_TRANSLATE("{0, plural, " static BStringFormat format(B_TRANSLATE("{0, plural, "
"one{# file} other{# files}}")); "one{# file} other{# files}}"));
BString label; BString label;
format.Format(label, info->count); format.Format(label, info->count);
@@ -11,13 +11,13 @@
#include <Autolock.h> #include <Autolock.h>
#include <Catalog.h> #include <Catalog.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <MessageFormat.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <LayoutUtils.h> #include <LayoutUtils.h>
#include <OutlineListView.h> #include <OutlineListView.h>
#include <Path.h> #include <Path.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringFormat.h>
#include <StringItem.h> #include <StringItem.h>
#include <package/PackageDefs.h> #include <package/PackageDefs.h>
+2 -2
View File
@@ -14,8 +14,8 @@
#include <Autolock.h> #include <Autolock.h>
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <MessageFormat.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <StringFormat.h>
#include <StringForSize.h> #include <StringForSize.h>
#include <package/hpkg/Strings.h> #include <package/hpkg/Strings.h>
#include <Window.h> #include <Window.h>
@@ -716,7 +716,7 @@ public:
private: private:
BString _GetLabel() const BString _GetLabel() const
{ {
static BMessageFormat format(B_TRANSLATE("{0, plural, " static BStringFormat format(B_TRANSLATE("{0, plural, "
"one{# item} other{# items}}")); "one{# item} other{# items}}"));
BString label; BString label;
+2 -2
View File
@@ -22,13 +22,13 @@
#include <Locale.h> #include <Locale.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MenuField.h> #include <MenuField.h>
#include <MessageFormat.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <PropertyInfo.h> #include <PropertyInfo.h>
#include <Screen.h> #include <Screen.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringFormat.h>
#include <TextView.h> #include <TextView.h>
#include <TranslationUtils.h> #include <TranslationUtils.h>
#include <TranslatorRoster.h> #include <TranslatorRoster.h>
@@ -1062,7 +1062,7 @@ TInfoView::Draw(BRect updateRect)
MovePenTo(15 + fPopUp->Bounds().Width(), fFontHeight + 5); 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}}")); "one{# pixel/pixel} other{# pixels/pixel}}"));
BString dimensionsInfo; BString dimensionsInfo;
@@ -15,10 +15,10 @@
#include <Locale.h> #include <Locale.h>
#include <MediaFile.h> #include <MediaFile.h>
#include <MediaTrack.h> #include <MediaTrack.h>
#include <MessageFormat.h>
#include <Mime.h> #include <Mime.h>
#include <Path.h> #include <Path.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <View.h> #include <View.h>
#include "MediaConverterWindow.h" #include "MediaConverterWindow.h"
@@ -131,7 +131,7 @@ MediaConverterApp::RefsReceived(BMessage* msg)
if (errors) { if (errors) {
BString alertText; 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:} " "one{The file was not recognized as a supported media file:} "
"other{# files were not recognized as supported media files:}}")); "other{# files were not recognized as supported media files:}}"));
format.Format(alertText, errors); format.Format(alertText, errors);
+4 -4
View File
@@ -9,7 +9,7 @@
#include <Catalog.h> #include <Catalog.h>
#include <MediaTrack.h> #include <MediaTrack.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include <stdio.h> #include <stdio.h>
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@@ -53,7 +53,7 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
if (ret != B_OK) if (ret != B_OK)
return ret; return ret;
static BMessageFormat frameFormat(B_TRANSLATE( static BStringFormat frameFormat(B_TRANSLATE(
"{0, plural, one{# frame} other{# frames}}")); "{0, plural, one{# frame} other{# frames}}"));
if (format.IsVideo()) { if (format.IsVideo()) {
@@ -97,12 +97,12 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
BString details; BString details;
if (bytesPerSample == 1 || bytesPerSample == 2) { if (bytesPerSample == 1 || bytesPerSample == 2) {
static BMessageFormat bitFormat( static BStringFormat bitFormat(
B_TRANSLATE("{0, plural, one{# bit} other{# bits}}")); B_TRANSLATE("{0, plural, one{# bit} other{# bits}}"));
bitFormat.Format(details, bytesPerSample * 8); bitFormat.Format(details, bytesPerSample * 8);
details.SetToFormat(B_TRANSLATE("%d bit "), bytesPerSample * 8); details.SetToFormat(B_TRANSLATE("%d bit "), bytesPerSample * 8);
} else { } else {
static BMessageFormat bitFormat( static BStringFormat bitFormat(
B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}")); B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}"));
bitFormat.Format(details, bytesPerSample); bitFormat.Format(details, bytesPerSample);
} }
+2 -2
View File
@@ -20,11 +20,11 @@
#include <Debug.h> #include <Debug.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <MediaDefs.h> #include <MediaDefs.h>
#include <MessageFormat.h>
#include <Mime.h> #include <Mime.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Screen.h> #include <Screen.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <StringForRate.h> #include <StringForRate.h>
#include <StringView.h> #include <StringView.h>
#include <TextView.h> #include <TextView.h>
@@ -486,7 +486,7 @@ InfoWin::_UpdateAudio()
info << bitString << " "; info << bitString << " ";
} }
static BMessageFormat channelFormat(B_TRANSLATE( static BStringFormat channelFormat(B_TRANSLATE(
"{0, plural, =1{Mono} =2{Stereo} other{# Channels}}")); "{0, plural, =1{Mono} =2{Stereo} other{# Channels}}"));
channelFormat.Format(info, channelCount); channelFormat.Format(info, channelCount);
+2 -2
View File
@@ -22,9 +22,9 @@
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MessageFormat.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <TextView.h> #include <TextView.h>
#include "Pairs.h" #include "Pairs.h"
@@ -305,7 +305,7 @@ PairsWindow::MessageReceived(BMessage* message)
// Note: in english the singular form is never used, but other // Note: in english the singular form is never used, but other
// languages behave differently. // languages behave differently.
static BMessageFormat format(B_TRANSLATE( static BStringFormat format(B_TRANSLATE(
"You completed the game in " "You completed the game in "
"{0, plural, one{# click} other{# clicks}}.\n")); "{0, plural, one{# click} other{# clicks}}.\n"));
format.Format(strAbout, fButtonClicks); format.Format(strAbout, fButtonClicks);
+2 -2
View File
@@ -4,11 +4,11 @@
* Started: 5/14/2004 * Started: 5/14/2004
* Version: 0.1 * Version: 0.1
*/ */
#include "StatusSlider.h" #include "StatusSlider.h"
#include <MessageFormat.h> #include <StringFormat.h>
StatusSlider::StatusSlider(const char* name, const char* label, StatusSlider::StatusSlider(const char* name, const char* label,
+3 -3
View File
@@ -4,15 +4,15 @@
* Started: 5/14/2004 * Started: 5/14/2004
* Version: 0.1 * Version: 0.1
*/ */
#ifndef STATUS_SLIDER #ifndef STATUS_SLIDER
#define STATUS_SLIDER #define STATUS_SLIDER
//#define BEOS_R5_COMPATIBLE //#define BEOS_R5_COMPATIBLE
#include <MessageFormat.h>
#include <Slider.h> #include <Slider.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
class StatusSlider: public BSlider { class StatusSlider: public BSlider {
@@ -28,7 +28,7 @@ public:
private: private:
mutable char fPattern[256]; mutable char fPattern[256];
BMessageFormat fFormat; BStringFormat fFormat;
mutable BString fStr; mutable BString fStr;
}; };
+1 -1
View File
@@ -28,8 +28,8 @@ local sources =
DateFormat.cpp DateFormat.cpp
DateTimeFormat.cpp DateTimeFormat.cpp
DurationFormat.cpp DurationFormat.cpp
MessageFormat.cpp
NumberFormat.cpp NumberFormat.cpp
StringFormat.cpp
TimeFormat.cpp TimeFormat.cpp
TimeUnitFormat.cpp TimeUnitFormat.cpp
Format.cpp # Used by some of the above. Format.cpp # Used by some of the above.
@@ -8,7 +8,7 @@
*/ */
#include <unicode/uversion.h> #include <unicode/uversion.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include <Autolock.h> #include <Autolock.h>
#include <FormattingConventionsPrivate.h> #include <FormattingConventionsPrivate.h>
@@ -19,35 +19,35 @@
#include <unicode/msgfmt.h> #include <unicode/msgfmt.h>
BMessageFormat::BMessageFormat(const BLanguage& language, const BString pattern) BStringFormat::BStringFormat(const BLanguage& language, const BString pattern)
: BFormat(language, BFormattingConventions()) : BFormat(language, BFormattingConventions())
{ {
_Initialize(UnicodeString::fromUTF8(pattern.String())); _Initialize(UnicodeString::fromUTF8(pattern.String()));
} }
BMessageFormat::BMessageFormat(const BString pattern) BStringFormat::BStringFormat(const BString pattern)
: BFormat() : BFormat()
{ {
_Initialize(UnicodeString::fromUTF8(pattern.String())); _Initialize(UnicodeString::fromUTF8(pattern.String()));
} }
BMessageFormat::~BMessageFormat() BStringFormat::~BStringFormat()
{ {
delete fFormatter; delete fFormatter;
} }
status_t status_t
BMessageFormat::InitCheck() BStringFormat::InitCheck()
{ {
return fInitStatus; return fInitStatus;
} }
status_t status_t
BMessageFormat::Format(BString& output, const int64 arg) const BStringFormat::Format(BString& output, const int64 arg) const
{ {
if (fInitStatus != B_OK) if (fInitStatus != B_OK)
return fInitStatus; return fInitStatus;
@@ -72,7 +72,7 @@ BMessageFormat::Format(BString& output, const int64 arg) const
status_t status_t
BMessageFormat::_Initialize(const UnicodeString& pattern) BStringFormat::_Initialize(const UnicodeString& pattern)
{ {
fInitStatus = B_OK; fInitStatus = B_OK;
UErrorCode error = U_ZERO_ERROR; UErrorCode error = U_ZERO_ERROR;
+2 -2
View File
@@ -7,7 +7,7 @@
#include <stdio.h> #include <stdio.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include <SystemCatalog.h> #include <SystemCatalog.h>
using BPrivate::gSystemCatalog; using BPrivate::gSystemCatalog;
@@ -29,7 +29,7 @@ string_for_size(double size, char* string, size_t stringSize)
"{0, plural, one{# byte} other{# bytes}}"); "{0, plural, one{# byte} other{# bytes}}");
BString tmp; BString tmp;
BMessageFormat format( BStringFormat format(
gSystemCatalog.GetString(trKey, B_TRANSLATION_CONTEXT)); gSystemCatalog.GetString(trKey, B_TRANSLATION_CONTEXT));
format.Format(tmp, (int)size); format.Format(tmp, (int)size);
+2 -2
View File
@@ -41,7 +41,7 @@ All rights reserved.
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Locale.h> #include <Locale.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include "AutoLock.h" #include "AutoLock.h"
#include "Bitmaps.h" #include "Bitmaps.h"
@@ -217,7 +217,7 @@ BCountView::Draw(BRect updateRect)
if (fLastCount == 0) if (fLastCount == 0)
itemString << B_TRANSLATE("no items"); itemString << B_TRANSLATE("no items");
else { else {
static BMessageFormat format(B_TRANSLATE_COMMENT( static BStringFormat format(B_TRANSLATE_COMMENT(
"{0, plural, one{# item} other{# items}}", "{0, plural, one{# item} other{# items}}",
"Number of selected items: \"1 item\" or \"2 items\"")); "Number of selected items: \"1 item\" or \"2 items\""));
format.Format(itemString, fLastCount); format.Format(itemString, fLastCount);
+2 -2
View File
@@ -58,12 +58,12 @@ respective holders. All rights reserved.
#include <Entry.h> #include <Entry.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Locale.h> #include <Locale.h>
#include <MessageFormat.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
#include <Roster.h> #include <Roster.h>
#include <Screen.h> #include <Screen.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <SymLink.h> #include <SymLink.h>
#include <Volume.h> #include <Volume.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
@@ -2092,7 +2092,7 @@ FileStatToString(StatStruct* stat, char* buffer, int32 length)
localtime_r(&stat->st_mtime, &timeData); localtime_r(&stat->st_mtime, &timeData);
BString size; BString size;
static BMessageFormat format( static BStringFormat format(
B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}")); B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}"));
format.Format(size, stat->st_size); format.Format(size, stat->st_size);
uint32 pos = snprintf(buffer, length, "\n\t(%s ", size.String()); uint32 pos = snprintf(buffer, length, "\n\t(%s ", size.String());
+3 -3
View File
@@ -47,7 +47,6 @@ All rights reserved.
#include <Font.h> #include <Font.h>
#include <Locale.h> #include <Locale.h>
#include <MenuField.h> #include <MenuField.h>
#include <MessageFormat.h>
#include <Mime.h> #include <Mime.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <NodeMonitor.h> #include <NodeMonitor.h>
@@ -57,6 +56,7 @@ All rights reserved.
#include <Roster.h> #include <Roster.h>
#include <Screen.h> #include <Screen.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StringFormat.h>
#include <SymLink.h> #include <SymLink.h>
#include <TextView.h> #include <TextView.h>
#include <Volume.h> #include <Volume.h>
@@ -674,9 +674,9 @@ BInfoWindow::MessageReceived(BMessage* message)
void void
BInfoWindow::GetSizeString(BString& result, off_t size, int32 fileCount) 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)}}")); "{0, plural, one{(# byte)} other{(# bytes)}}"));
static BMessageFormat countFormat(B_TRANSLATE( static BStringFormat countFormat(B_TRANSLATE(
"{0, plural, one{for # file} other{for # files}}")); "{0, plural, one{for # file} other{for # files}}"));
char sizeBuffer[128]; char sizeBuffer[128];
+2 -2
View File
@@ -49,9 +49,9 @@ All rights reserved.
#include <DateTimeFormat.h> #include <DateTimeFormat.h>
#include <Debug.h> #include <Debug.h>
#include <Locale.h> #include <Locale.h>
#include <MessageFormat.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
#include <StringFormat.h>
#include <SupportDefs.h> #include <SupportDefs.h>
#include <TextView.h> #include <TextView.h>
#include <Volume.h> #include <Volume.h>
@@ -107,7 +107,7 @@ TruncFileSizeBase(BString* outString, int64 value, const View* view,
*outString = "-"; *outString = "-";
return view->StringWidth("-"); return view->StringWidth("-");
} else if (value < kKBSize) { } else if (value < kKBSize) {
static BMessageFormat format(B_TRANSLATE( static BStringFormat format(B_TRANSLATE(
"{0, plural, one{# byte} other{# bytes}}")); "{0, plural, one{# byte} other{# bytes}}"));
format.Format(buffer, value); format.Format(buffer, value);
if (view->StringWidth(buffer.String()) > width) if (view->StringWidth(buffer.String()) > width)
@@ -21,7 +21,6 @@
#include <Locale.h> #include <Locale.h>
#include <MenuField.h> #include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MessageFormat.h>
#include <Mime.h> #include <Mime.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
@@ -31,6 +30,7 @@
#include <Screen.h> #include <Screen.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <StatusBar.h> #include <StatusBar.h>
#include <StringFormat.h>
#include <StringView.h> #include <StringView.h>
#include <TextView.h> #include <TextView.h>
#include <Volume.h> #include <Volume.h>
@@ -346,7 +346,7 @@ ApplicationTypesWindow::_RemoveUninstalled()
progressWindow->PostMessage(B_QUIT_REQUESTED); 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} " "one{# Application type could be removed} "
"other{# Application types could be removed}}")); "other{# Application types could be removed}}"));
BString message; BString message;
+2 -2
View File
@@ -24,7 +24,6 @@
#include <kernel/fs_info.h> #include <kernel/fs_info.h>
#include <kernel/fs_index.h> #include <kernel/fs_index.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MessageFormat.h>
#include <Messenger.h> #include <Messenger.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <NodeMonitor.h> #include <NodeMonitor.h>
@@ -36,6 +35,7 @@
#include <Resources.h> #include <Resources.h>
#include <Roster.h> #include <Roster.h>
#include <String.h> #include <String.h>
#include <StringFormat.h>
#include <SymLink.h> #include <SymLink.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
#include <Window.h> #include <Window.h>
@@ -546,7 +546,7 @@ DeskbarView::_BuildMenu()
// The New E-mail query // The New E-mail query
if (fNewMessages > 0) { if (fNewMessages > 0) {
static BMessageFormat format(B_TRANSLATE( static BStringFormat format(B_TRANSLATE(
"{0, plural, one{# new message} other{# new messages}}")); "{0, plural, one{# new message} other{# new messages}}"));
BString string; BString string;
format.Format(string, fNewMessages); format.Format(string, fNewMessages);
+3 -3
View File
@@ -20,12 +20,12 @@
#include <FindDirectory.h> #include <FindDirectory.h>
#include <fs_index.h> #include <fs_index.h>
#include <IconUtils.h> #include <IconUtils.h>
#include <MessageFormat.h>
#include <NodeMonitor.h> #include <NodeMonitor.h>
#include <Notification.h> #include <Notification.h>
#include <Path.h> #include <Path.h>
#include <Roster.h> #include <Roster.h>
#include <StringList.h> #include <StringList.h>
#include <StringFormat.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
#include <E-mail.h> #include <E-mail.h>
@@ -350,7 +350,7 @@ MailDaemonApplication::MessageReceived(BMessage* msg)
case 'numg': 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")); "one{# new message} other{# new messages}} for %name\n"));
int32 numMessages = msg->FindInt32("num_messages"); int32 numMessages = msg->FindInt32("num_messages");
@@ -797,7 +797,7 @@ MailDaemonApplication::_UpdateNewMessagesNotification()
{ {
BString title; BString title;
if (fNewMessages > 0) { if (fNewMessages > 0) {
BMessageFormat format(B_TRANSLATE( BStringFormat format(B_TRANSLATE(
"{0, plural, one{One new message} other{# new messages}}")); "{0, plural, one{One new message} other{# new messages}}"));
format.Format(title, fNewMessages); format.Format(title, fNewMessages);
+1 -1
View File
@@ -50,8 +50,8 @@ UnitTestLib localekittest.so :
DateFormatTest.cpp DateFormatTest.cpp
DurationFormatTest.cpp DurationFormatTest.cpp
LanguageTest.cpp LanguageTest.cpp
MessageFormatTest.cpp
RelativeDateTimeFormatTest.cpp RelativeDateTimeFormatTest.cpp
StringFormatTest.cpp
UnicodeCharTest.cpp UnicodeCharTest.cpp
: be [ TargetLibstdc++ ] : be [ TargetLibstdc++ ]
+2 -2
View File
@@ -11,8 +11,8 @@
#include "DateFormatTest.h" #include "DateFormatTest.h"
#include "DurationFormatTest.h" #include "DurationFormatTest.h"
#include "LanguageTest.h" #include "LanguageTest.h"
#include "MessageFormatTest.h"
#include "RelativeDateTimeFormatTest.h" #include "RelativeDateTimeFormatTest.h"
#include "StringFormatTest.h"
#include "UnicodeCharTest.h" #include "UnicodeCharTest.h"
@@ -25,7 +25,7 @@ getTestSuite()
DateFormatTest::AddTests(*suite); DateFormatTest::AddTests(*suite);
DurationFormatTest::AddTests(*suite); DurationFormatTest::AddTests(*suite);
LanguageTest::AddTests(*suite); LanguageTest::AddTests(*suite);
MessageFormatTest::AddTests(*suite); StringFormatTest::AddTests(*suite);
RelativeDateTimeFormatTest::AddTests(*suite); RelativeDateTimeFormatTest::AddTests(*suite);
UnicodeCharTest::AddTests(*suite); UnicodeCharTest::AddTests(*suite);
@@ -4,27 +4,27 @@
*/ */
#include "MessageFormatTest.h" #include "StringFormatTest.h"
#include <Locale.h> #include <Locale.h>
#include <MessageFormat.h> #include <StringFormat.h>
#include <cppunit/TestCaller.h> #include <cppunit/TestCaller.h>
#include <cppunit/TestSuite.h> #include <cppunit/TestSuite.h>
MessageFormatTest::MessageFormatTest() StringFormatTest::StringFormatTest()
{ {
} }
MessageFormatTest::~MessageFormatTest() StringFormatTest::~StringFormatTest()
{ {
} }
void void
MessageFormatTest::TestFormat() StringFormatTest::TestFormat()
{ {
BString output; BString output;
@@ -82,7 +82,7 @@ MessageFormatTest::TestFormat()
NextSubTest(); NextSubTest();
output.Truncate(0); output.Truncate(0);
BLanguage language(tests[i].locale); BLanguage language(tests[i].locale);
BMessageFormat formatter(language, tests[i].pattern); BStringFormat formatter(language, tests[i].pattern);
result = formatter.Format(output, tests[i].number); result = formatter.Format(output, tests[i].number);
CPPUNIT_ASSERT_EQUAL(B_OK, result); CPPUNIT_ASSERT_EQUAL(B_OK, result);
@@ -92,7 +92,7 @@ MessageFormatTest::TestFormat()
void void
MessageFormatTest::TestBogus() StringFormatTest::TestBogus()
{ {
struct Test { struct Test {
const char* pattern; const char* pattern;
@@ -113,7 +113,7 @@ MessageFormatTest::TestBogus()
status_t result; status_t result;
BString output; BString output;
BMessageFormat formatter(tests[i].pattern); BStringFormat formatter(tests[i].pattern);
CPPUNIT_ASSERT(formatter.InitCheck() != B_OK); CPPUNIT_ASSERT(formatter.InitCheck() != B_OK);
result = formatter.Format(output, 1); result = formatter.Format(output, 1);
@@ -126,14 +126,14 @@ MessageFormatTest::TestBogus()
/*static*/ void /*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>( suite.addTest(new CppUnit::TestCaller<StringFormatTest>(
"MessageFormatTest::TestFormat", &MessageFormatTest::TestFormat)); "StringFormatTest::TestFormat", &StringFormatTest::TestFormat));
suite.addTest(new CppUnit::TestCaller<MessageFormatTest>( suite.addTest(new CppUnit::TestCaller<StringFormatTest>(
"MessageFormatTest::TestBogus", &MessageFormatTest::TestBogus)); "StringFormatTest::TestBogus", &StringFormatTest::TestBogus));
parent.addTest("MessageFormatTest", &suite); parent.addTest("StringFormatTest", &suite);
} }
@@ -2,18 +2,18 @@
* Copyright 2014 Haiku, Inc. * Copyright 2014 Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef MESSAGE_FORMAT_TEST_H #ifndef STRING_FORMAT_TEST
#define MESSAGE_FORMAT_TEST_H #define STRING_FORMAT_TEST
#include <TestCase.h> #include <TestCase.h>
#include <TestSuite.h> #include <TestSuite.h>
class MessageFormatTest: public BTestCase { class StringFormatTest: public BTestCase {
public: public:
MessageFormatTest(); StringFormatTest();
virtual ~MessageFormatTest(); virtual ~StringFormatTest();
void TestFormat(); void TestFormat();
void TestBogus(); void TestBogus();