Start making use of BMessageFormat.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#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>
|
||||||
|
|
||||||
@@ -67,15 +68,12 @@ NotifyFilter::MailboxSynced(status_t status)
|
|||||||
system_beep("New E-mail");
|
system_beep("New E-mail");
|
||||||
|
|
||||||
if (fStrategy & alert) {
|
if (fStrategy & alert) {
|
||||||
BString text, numString;
|
BString text;
|
||||||
if (fNNewMessages != 1)
|
BMessageFormat().Format(text, B_TRANSLATE(
|
||||||
text << B_TRANSLATE("You have %num new messages for %name.");
|
"You have {0, plural, one{# new message} other{# new messages}} "
|
||||||
else
|
"for %account."), fNNewMessages);
|
||||||
text << B_TRANSLATE("You have %num new message for %name.");
|
|
||||||
|
|
||||||
numString << fNNewMessages;
|
text.ReplaceFirst("%account", fMailProtocol.AccountSettings().Name());
|
||||||
text.ReplaceFirst("%num", numString);
|
|
||||||
text.ReplaceFirst("%name", fMailProtocol.AccountSettings().Name());
|
|
||||||
|
|
||||||
BAlert *alert = new BAlert(B_TRANSLATE("New messages"), text.String(),
|
BAlert *alert = new BAlert(B_TRANSLATE("New messages"), text.String(),
|
||||||
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL);
|
B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL);
|
||||||
@@ -99,14 +97,10 @@ NotifyFilter::MailboxSynced(status_t status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fStrategy & log_window) {
|
if (fStrategy & log_window) {
|
||||||
BString message, numString;
|
BString message;
|
||||||
if (fNNewMessages != 1)
|
BMessageFormat().Format(message, B_TRANSLATE(
|
||||||
message << B_TRANSLATE("%num new messages");
|
"{0, plural, one{# new message} other{# new messages}}"),
|
||||||
else
|
fNNewMessages);
|
||||||
message << B_TRANSLATE("%num new message");
|
|
||||||
|
|
||||||
numString << fNNewMessages;
|
|
||||||
message.ReplaceFirst("%num", numString);
|
|
||||||
|
|
||||||
fMailProtocol.ShowMessage(message.String());
|
fMailProtocol.ShowMessage(message.String());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#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 <OS.h>
|
#include <OS.h>
|
||||||
@@ -442,13 +443,10 @@ AboutView::AboutView()
|
|||||||
B_ALIGN_VERTICAL_UNSET));
|
B_ALIGN_VERTICAL_UNSET));
|
||||||
|
|
||||||
// CPU count, type and clock speed
|
// CPU count, type and clock speed
|
||||||
char processorLabel[256];
|
BString processorLabel;
|
||||||
if (systemInfo.cpu_count > 1) {
|
BMessageFormat().Format(processorLabel, B_TRANSLATE_COMMENT(
|
||||||
snprintf(processorLabel, sizeof(processorLabel),
|
"{0, plural, one{Processors:} other{# Processors:}}",
|
||||||
B_TRANSLATE("%ld Processors:"), systemInfo.cpu_count);
|
"\"Processor:\" or \"2 Processors:\""), systemInfo.cpu_count);
|
||||||
} else
|
|
||||||
strlcpy(processorLabel, B_TRANSLATE("Processor:"),
|
|
||||||
sizeof(processorLabel));
|
|
||||||
|
|
||||||
uint32 topologyNodeCount = 0;
|
uint32 topologyNodeCount = 0;
|
||||||
cpu_topology_node_info* topology = NULL;
|
cpu_topology_node_info* topology = NULL;
|
||||||
@@ -550,7 +548,7 @@ AboutView::AboutView()
|
|||||||
.Add(versionView)
|
.Add(versionView)
|
||||||
.Add(abiView)
|
.Add(abiView)
|
||||||
.AddStrut(offset)
|
.AddStrut(offset)
|
||||||
.Add(_CreateLabel("cpulabel", processorLabel))
|
.Add(_CreateLabel("cpulabel", processorLabel.String()))
|
||||||
.Add(cpuView)
|
.Add(cpuView)
|
||||||
.Add(frequencyView)
|
.Add(frequencyView)
|
||||||
.AddStrut(offset)
|
.AddStrut(offset)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#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 <TextView.h>
|
#include <TextView.h>
|
||||||
@@ -294,17 +295,20 @@ PairsWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
// game end and results
|
// game end and results
|
||||||
if (fFinishPairs == pairsButtonList->CountItems() / 2) {
|
if (fFinishPairs == pairsButtonList->CountItems() / 2) {
|
||||||
BString score;
|
|
||||||
score << fButtonClicks;
|
|
||||||
BString strAbout = B_TRANSLATE("%app%\n"
|
BString strAbout = B_TRANSLATE("%app%\n"
|
||||||
"\twritten by Ralf Schülke\n"
|
"\twritten by Ralf Schülke\n"
|
||||||
"\tCopyright 2008-2010, Haiku Inc.\n"
|
"\tCopyright 2008-2010, Haiku Inc.\n"
|
||||||
"\n"
|
"\n");
|
||||||
"You completed the game in %num% clicks.\n");
|
|
||||||
|
|
||||||
strAbout.ReplaceFirst("%app%",
|
strAbout.ReplaceFirst("%app%",
|
||||||
B_TRANSLATE_SYSTEM_NAME("Pairs"));
|
B_TRANSLATE_SYSTEM_NAME("Pairs"));
|
||||||
strAbout.ReplaceFirst("%num%", score);
|
|
||||||
|
// Note: in english the singular form is never used, but other
|
||||||
|
// languages behave differently.
|
||||||
|
BMessageFormat().Format(strAbout, B_TRANSLATE(
|
||||||
|
"You completed the game in "
|
||||||
|
"{0, plural, one{# click} other{# clicks}}.\n"),
|
||||||
|
fButtonClicks);
|
||||||
|
|
||||||
BAlert* alert = new BAlert("about",
|
BAlert* alert = new BAlert("about",
|
||||||
strAbout.String(),
|
strAbout.String(),
|
||||||
|
|||||||
@@ -41,6 +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 "AutoLock.h"
|
#include "AutoLock.h"
|
||||||
#include "Bitmaps.h"
|
#include "Bitmaps.h"
|
||||||
@@ -230,13 +231,11 @@ BCountView::Draw(BRect updateRect)
|
|||||||
} else {
|
} else {
|
||||||
if (fLastCount == 0)
|
if (fLastCount == 0)
|
||||||
itemString << B_TRANSLATE("no items");
|
itemString << B_TRANSLATE("no items");
|
||||||
else if (fLastCount == 1)
|
|
||||||
itemString << B_TRANSLATE("1 item");
|
|
||||||
else {
|
else {
|
||||||
itemString.SetTo(B_TRANSLATE("%num items"));
|
BMessageFormat().Format(itemString, B_TRANSLATE_COMMENT(
|
||||||
char numString[256];
|
"{0, plural, one{# item} other{# items}}",
|
||||||
snprintf(numString, sizeof(numString), "%" B_PRId32, fLastCount);
|
"Number of selected items: \"1 item\" or \"2 items\""),
|
||||||
itemString.ReplaceFirst("%num", numString);
|
fLastCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ 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>
|
||||||
@@ -675,43 +676,22 @@ void
|
|||||||
BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
|
BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
|
||||||
{
|
{
|
||||||
char sizeBuffer[128];
|
char sizeBuffer[128];
|
||||||
|
BMessageFormat messageFormat;
|
||||||
|
|
||||||
result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer));
|
result << string_for_size((double)size, sizeBuffer, sizeof(sizeBuffer));
|
||||||
|
|
||||||
// when we show the byte size, format it with a thousands delimiter
|
|
||||||
// TODO: use BCountry::FormatNumber
|
|
||||||
if (size >= kKBSize) {
|
if (size >= kKBSize) {
|
||||||
char numStr[128];
|
result << " ";
|
||||||
snprintf(numStr, sizeof(numStr), "%" B_PRIdOFF, size);
|
messageFormat.Format(result, B_TRANSLATE(
|
||||||
BString bytes;
|
"{0, plural, one{(# byte)} other{(# bytes)}}"), size);
|
||||||
|
|
||||||
uint32 length = strlen(numStr);
|
|
||||||
if (length >= 4) {
|
|
||||||
uint32 charsTillComma = length % 3;
|
|
||||||
if (charsTillComma == 0)
|
|
||||||
charsTillComma = 3;
|
|
||||||
|
|
||||||
uint32 numberIndex = 0;
|
|
||||||
|
|
||||||
while (numStr[numberIndex]) {
|
|
||||||
bytes += numStr[numberIndex++];
|
|
||||||
if (--charsTillComma == 0 && numStr[numberIndex]) {
|
|
||||||
bytes += ',';
|
|
||||||
charsTillComma = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result << " " << B_TRANSLATE("(%bytes bytes)");
|
|
||||||
// "bytes" translation could come from string_for_size
|
// "bytes" translation could come from string_for_size
|
||||||
// which could be part of the localekit itself
|
// which could be part of the localekit itself
|
||||||
result.ReplaceFirst("%bytes", bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileCount != 0) {
|
if (fileCount != 0) {
|
||||||
result << " " << B_TRANSLATE("for %num files");
|
result << " ";
|
||||||
BString countString;
|
messageFormat.Format(result, B_TRANSLATE(
|
||||||
countString << fileCount;
|
"{0, plural, one{for # file} other{for # files}}"), fileCount);
|
||||||
result.ReplaceFirst("%num", countString);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#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>
|
||||||
@@ -525,7 +526,7 @@ DeskbarView::_BuildMenu()
|
|||||||
item = new BMenuItem(path.Leaf(), msg);
|
item = new BMenuItem(path.Leaf(), msg);
|
||||||
|
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
if(entry.InitCheck() != B_OK)
|
if (entry.InitCheck() != B_OK)
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
}
|
}
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
@@ -541,14 +542,10 @@ DeskbarView::_BuildMenu()
|
|||||||
// The New E-mail query
|
// The New E-mail query
|
||||||
|
|
||||||
if (fNewMessages > 0) {
|
if (fNewMessages > 0) {
|
||||||
BString string, numString;
|
BString string;
|
||||||
if (fNewMessages != 1)
|
BMessageFormat().Format(string, B_TRANSLATE(
|
||||||
string << B_TRANSLATE("%num new messages");
|
"{0, plural, one{# new message} other{# new messages}}"),
|
||||||
else
|
fNewMessages);
|
||||||
string << B_TRANSLATE("%num new message");
|
|
||||||
|
|
||||||
numString << fNewMessages;
|
|
||||||
string.ReplaceFirst("%num", numString);
|
|
||||||
|
|
||||||
_GetNewQueryRef(ref);
|
_GetNewQueryRef(ref);
|
||||||
|
|
||||||
@@ -559,8 +556,7 @@ DeskbarView::_BuildMenu()
|
|||||||
navMenu->SetNavDir(&ref);
|
navMenu->SetNavDir(&ref);
|
||||||
|
|
||||||
menu->AddItem(item);
|
menu->AddItem(item);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
menu->AddItem(item = new BMenuItem(B_TRANSLATE("No new messages"),
|
menu->AddItem(item = new BMenuItem(B_TRANSLATE("No new messages"),
|
||||||
NULL));
|
NULL));
|
||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#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>
|
||||||
@@ -175,17 +176,12 @@ MailDaemonApp::ReadyToRun()
|
|||||||
fQueries.AddItem(query);
|
fQueries.AddItem(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
BString string, numString;
|
BString string;
|
||||||
if (fNewMessages > 0) {
|
if (fNewMessages > 0) {
|
||||||
if (fNewMessages != 1)
|
BMessageFormat().Format(string, B_TRANSLATE(
|
||||||
string << B_TRANSLATE("%num new messages.");
|
"{0, plural, one{# new message} other{# new messages}}"),
|
||||||
else
|
fNewMessages);
|
||||||
string << B_TRANSLATE("%num new message.");
|
} else
|
||||||
|
|
||||||
numString << fNewMessages;
|
|
||||||
string.ReplaceFirst("%num", numString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
string = B_TRANSLATE("No new messages");
|
string = B_TRANSLATE("No new messages");
|
||||||
|
|
||||||
fCentralBeep = false;
|
fCentralBeep = false;
|
||||||
@@ -349,15 +345,10 @@ MailDaemonApp::MessageReceived(BMessage* msg)
|
|||||||
case 'numg':
|
case 'numg':
|
||||||
{
|
{
|
||||||
int32 numMessages = msg->FindInt32("num_messages");
|
int32 numMessages = msg->FindInt32("num_messages");
|
||||||
BString numString;
|
BMessageFormat().Format(fAlertString, B_TRANSLATE(
|
||||||
|
"{0, plural, one{# new message} other{# new messages}} "
|
||||||
|
"for %name\n"), numMessages);
|
||||||
|
|
||||||
if (numMessages > 1)
|
|
||||||
fAlertString << B_TRANSLATE("%num new messages for %name\n");
|
|
||||||
else
|
|
||||||
fAlertString << B_TRANSLATE("%num new message for %name\n");
|
|
||||||
|
|
||||||
numString << numMessages;
|
|
||||||
fAlertString.ReplaceFirst("%num", numString);
|
|
||||||
fAlertString.ReplaceFirst("%name", msg->FindString("name"));
|
fAlertString.ReplaceFirst("%name", msg->FindString("name"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -375,18 +366,13 @@ MailDaemonApp::MessageReceived(BMessage* msg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
BString string, numString;
|
BString string;
|
||||||
|
|
||||||
if (fNewMessages > 0) {
|
if (fNewMessages > 0) {
|
||||||
if (fNewMessages != 1)
|
BMessageFormat().Format(string, B_TRANSLATE(
|
||||||
string << B_TRANSLATE("%num new messages.");
|
"{0, plural, one{# new message.} other{# new messages.}}"),
|
||||||
else
|
fNewMessages);
|
||||||
string << B_TRANSLATE("%num new message.");
|
} else
|
||||||
|
|
||||||
numString << fNewMessages;
|
|
||||||
string.ReplaceFirst("%num", numString);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
string << B_TRANSLATE("No new messages.");
|
string << B_TRANSLATE("No new messages.");
|
||||||
|
|
||||||
fNotification->SetTitle(string.String());
|
fNotification->SetTitle(string.String());
|
||||||
|
|||||||
Reference in New Issue
Block a user