More uses of BMessageFormat
ZipOMatic, DiskUsage, MediaConverter, MediaPlayer, ShowImage, WebPositive, Screen preferences, Tracker, string_for_size. Thanks to KapiX for reporting those!
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "ZipOMatic.h"
|
#include "ZipOMatic.h"
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <MessageFormat.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <TrackerAddOnAppLaunch.h>
|
#include <TrackerAddOnAppLaunch.h>
|
||||||
|
|
||||||
@@ -153,13 +154,15 @@ 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.
|
||||||
|
|
||||||
BString question;
|
static BMessageFormat format(
|
||||||
question << B_TRANSLATE("You have %ld Zip-O-Matic running.\n\n");
|
B_TRANSLATE("You have {0, plural, one{# Zip-O-Matic} "
|
||||||
question << B_TRANSLATE("Do you want to stop them?");
|
"other{# Zip-O-Matics}} running.\n\n"));
|
||||||
|
|
||||||
BString temp;
|
BString question;
|
||||||
temp << zippoCount;
|
|
||||||
question.ReplaceFirst("%ld", temp.String());
|
format.Format(question, zippoCount);
|
||||||
|
|
||||||
|
question << B_TRANSLATE("Do you want to stop them?");
|
||||||
|
|
||||||
BAlert* alert = new BAlert(NULL, question.String(),
|
BAlert* alert = new BAlert(NULL, question.String(),
|
||||||
B_TRANSLATE("Stop them"), B_TRANSLATE("Let them continue"), NULL,
|
B_TRANSLATE("Stop them"), B_TRANSLATE("Let them continue"), NULL,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
|
#include <MessageFormat.h>
|
||||||
#include <StringForSize.h>
|
#include <StringForSize.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
@@ -77,31 +78,36 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
Item item;
|
Item item;
|
||||||
|
|
||||||
// Size
|
// Size
|
||||||
char name[B_PATH_NAME_LENGTH] = { 0 };
|
BString name;
|
||||||
string_for_size(f->size, name, sizeof(name));
|
|
||||||
if (f->count > 0) {
|
if (f->count > 0) {
|
||||||
// This is a directory.
|
// This is a directory, include file count information
|
||||||
char str[64];
|
static BMessageFormat format(B_TRANSLATE(
|
||||||
snprintf(str, sizeof(str), B_TRANSLATE(" in %d files"),
|
"%size% in {0, plural, one{# file} other{# files}"));
|
||||||
f->count);
|
|
||||||
strlcat(name, str, sizeof(name));
|
format.Format(name, f->count);
|
||||||
}
|
} else
|
||||||
info.push_back(Item(B_TRANSLATE_MARK("Size"), name));
|
name = "%size%";
|
||||||
|
|
||||||
|
char tmp[B_PATH_NAME_LENGTH] = { 0 };
|
||||||
|
string_for_size(f->size, tmp, sizeof(tmp));
|
||||||
|
name.ReplaceFirst("%size%", tmp);
|
||||||
|
|
||||||
|
info.push_back(Item(B_TRANSLATE_MARK("Size"), name.String()));
|
||||||
|
|
||||||
// Created & modified dates
|
// Created & modified dates
|
||||||
BEntry entry(&f->ref);
|
BEntry entry(&f->ref);
|
||||||
time_t t;
|
time_t t;
|
||||||
entry.GetCreationTime(&t);
|
entry.GetCreationTime(&t);
|
||||||
strftime(name, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
||||||
info.push_back(Item(B_TRANSLATE("Created"), name));
|
info.push_back(Item(B_TRANSLATE("Created"), tmp));
|
||||||
entry.GetModificationTime(&t);
|
entry.GetModificationTime(&t);
|
||||||
strftime(name, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
|
||||||
info.push_back(Item(B_TRANSLATE("Modified"), name));
|
info.push_back(Item(B_TRANSLATE("Modified"), tmp));
|
||||||
|
|
||||||
// Kind
|
// Kind
|
||||||
BMimeType* type = f->Type();
|
BMimeType* type = f->Type();
|
||||||
type->GetShortDescription(name);
|
type->GetShortDescription(tmp);
|
||||||
info.push_back(Item(B_TRANSLATE("Kind"), name));
|
info.push_back(Item(B_TRANSLATE("Kind"), tmp));
|
||||||
delete type;
|
delete type;
|
||||||
|
|
||||||
// Path
|
// Path
|
||||||
@@ -127,15 +133,15 @@ InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
|
|||||||
float rightWidth = 0.0;
|
float rightWidth = 0.0;
|
||||||
InfoList::iterator i = info.begin();
|
InfoList::iterator i = info.begin();
|
||||||
while (i != info.end()) {
|
while (i != info.end()) {
|
||||||
float w = smallFont.StringWidth((*i).first.c_str()) +
|
float w = smallFont.StringWidth((*i).first.c_str())
|
||||||
2.0 * kSmallHMargin;
|
+ 2.0 * kSmallHMargin;
|
||||||
leftWidth = max_c(leftWidth, w);
|
leftWidth = max_c(leftWidth, w);
|
||||||
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
|
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
|
||||||
rightWidth = max_c(rightWidth, w);
|
rightWidth = max_c(rightWidth, w);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
|
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
|
||||||
+ kSmallVMargin);
|
+ kSmallVMargin);
|
||||||
float winWidth = leftWidth + rightWidth;
|
float winWidth = leftWidth + rightWidth;
|
||||||
ResizeTo(winWidth, winHeight);
|
ResizeTo(winWidth, winHeight);
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ StatusView::StatusView()
|
|||||||
B_SIZE_UNSET));
|
B_SIZE_UNSET));
|
||||||
|
|
||||||
char testLabel[256];
|
char testLabel[256];
|
||||||
snprintf(testLabel, sizeof(testLabel), B_TRANSLATE("%d files"),
|
snprintf(testLabel, sizeof(testLabel), B_TRANSLATE_COMMENT("%d files",
|
||||||
|
"For UI layouting only, use the longest plural form for your language"),
|
||||||
999999);
|
999999);
|
||||||
|
|
||||||
fCountView = new BStringView(NULL, kEmptyStr);
|
fCountView = new BStringView(NULL, kEmptyStr);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#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>
|
||||||
@@ -130,17 +131,10 @@ MediaConverterApp::RefsReceived(BMessage* msg)
|
|||||||
|
|
||||||
if (errors) {
|
if (errors) {
|
||||||
BString alertText;
|
BString alertText;
|
||||||
if (errors > 1) {
|
static BMessageFormat format(B_TRANSLATE("{0, plural, "
|
||||||
alertText = B_TRANSLATE(
|
"one{The file was not recognized as a supported media file:} "
|
||||||
"%amountOfFiles files were not recognized"
|
"other{# files were not recognized as supported media files:}}"));
|
||||||
" as supported media files:");
|
format.Format(alertText, errors);
|
||||||
BString amount;
|
|
||||||
amount << errors;
|
|
||||||
alertText.ReplaceAll("%amountOfFiles", amount);
|
|
||||||
} else {
|
|
||||||
alertText = B_TRANSLATE(
|
|
||||||
"The file was not recognized as a supported media file:");
|
|
||||||
}
|
|
||||||
|
|
||||||
alertText << "\n" << errorFiles;
|
alertText << "\n" << errorFiles;
|
||||||
BAlert* alert = new BAlert((errors > 1) ?
|
BAlert* alert = new BAlert((errors > 1) ?
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <MediaTrack.h>
|
#include <MediaTrack.h>
|
||||||
|
#include <MessageFormat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#undef B_TRANSLATION_CONTEXT
|
#undef B_TRANSLATION_CONTEXT
|
||||||
@@ -26,7 +27,7 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
_Reset();
|
_Reset();
|
||||||
if (!file)
|
if (!file)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
BMediaTrack* track;
|
BMediaTrack* track;
|
||||||
media_format format;
|
media_format format;
|
||||||
memset(&format, 0, sizeof(format));
|
memset(&format, 0, sizeof(format));
|
||||||
@@ -52,6 +53,9 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
if (ret != B_OK)
|
if (ret != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
static BMessageFormat frameFormat(B_TRANSLATE(
|
||||||
|
"{0, plural, one{# frame} other{# frames}}"));
|
||||||
|
|
||||||
if (format.IsVideo()) {
|
if (format.IsVideo()) {
|
||||||
memset(&format, 0, sizeof(format));
|
memset(&format, 0, sizeof(format));
|
||||||
format.type = B_MEDIA_RAW_VIDEO;
|
format.type = B_MEDIA_RAW_VIDEO;
|
||||||
@@ -71,12 +75,14 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
videoFrames = track->CountFrames();
|
videoFrames = track->CountFrames();
|
||||||
|
|
||||||
BString details;
|
BString details;
|
||||||
snprintf(details.LockBuffer(256), 256,
|
details.SetToFormat(
|
||||||
B_TRANSLATE_COMMENT("%u x %u, %.2ffps / %Ld frames",
|
B_TRANSLATE_COMMENT("%u x %u, %.2ffps", "Width x Height, fps"),
|
||||||
"Width x Height, fps / frames"),
|
format.Width(), format.Height(),
|
||||||
format.Width(), format.Height(),
|
rvf->field_rate / rvf->interlace);
|
||||||
rvf->field_rate / rvf->interlace, videoFrames);
|
|
||||||
details.UnlockBuffer();
|
details << " / ";
|
||||||
|
frameFormat.Format(details, videoFrames);
|
||||||
|
|
||||||
video.details << details;
|
video.details << details;
|
||||||
videoDone = true;
|
videoDone = true;
|
||||||
|
|
||||||
@@ -91,14 +97,17 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
|
|
||||||
BString details;
|
BString details;
|
||||||
if (bytesPerSample == 1 || bytesPerSample == 2) {
|
if (bytesPerSample == 1 || bytesPerSample == 2) {
|
||||||
snprintf(details.LockBuffer(16), 16,
|
static BMessageFormat bitFormat(
|
||||||
B_TRANSLATE("%d bit "), bytesPerSample * 8);
|
B_TRANSLATE("{0, plural, one{# bit} other{# bits}}"));
|
||||||
|
bitFormat.Format(details, bytesPerSample * 8);
|
||||||
|
details.SetToFormat(B_TRANSLATE("%d bit "), bytesPerSample * 8);
|
||||||
} else {
|
} else {
|
||||||
snprintf(details.LockBuffer(16), 16,
|
static BMessageFormat bitFormat(
|
||||||
B_TRANSLATE("%d byte "), bytesPerSample);
|
B_TRANSLATE("{0, plural, one{# byte} other{# bytes}}"));
|
||||||
|
bitFormat.Format(details, bytesPerSample);
|
||||||
}
|
}
|
||||||
details.UnlockBuffer();
|
|
||||||
audio.details << details;
|
audio.details << details;
|
||||||
|
audio.details << " ";
|
||||||
|
|
||||||
ret = track->GetCodecInfo(&codecInfo);
|
ret = track->GetCodecInfo(&codecInfo);
|
||||||
if (ret != B_OK)
|
if (ret != B_OK)
|
||||||
@@ -109,19 +118,19 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
audioFrames = track->CountFrames();
|
audioFrames = track->CountFrames();
|
||||||
BString channels;
|
BString channels;
|
||||||
if (raf->channel_count == 1) {
|
if (raf->channel_count == 1) {
|
||||||
snprintf(channels.LockBuffer(64), 64,
|
channels.SetToFormat(B_TRANSLATE("%.1f kHz mono"),
|
||||||
B_TRANSLATE("%.1f kHz mono / %lld frames"),
|
raf->frame_rate / 1000.f);
|
||||||
raf->frame_rate / 1000.f, audioFrames);
|
|
||||||
} else if (raf->channel_count == 2) {
|
} else if (raf->channel_count == 2) {
|
||||||
snprintf(channels.LockBuffer(64), 64,
|
channels.SetToFormat(B_TRANSLATE("%.1f kHz stereo"),
|
||||||
B_TRANSLATE("%.1f kHz stereo / %lld frames"),
|
raf->frame_rate / 1000.f);
|
||||||
raf->frame_rate / 1000.f, audioFrames);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(channels.LockBuffer(64), 64,
|
channels.SetToFormat(B_TRANSLATE("%.1f kHz %ld channel"),
|
||||||
B_TRANSLATE("%.1f kHz %ld channel / %lld frames"),
|
raf->frame_rate / 1000.f, raf->channel_count);
|
||||||
raf->frame_rate / 1000.f, raf->channel_count, audioFrames);
|
|
||||||
}
|
}
|
||||||
channels.UnlockBuffer();
|
|
||||||
|
channels << " / ";
|
||||||
|
frameFormat.Format(channels, audioFrames);
|
||||||
|
|
||||||
audio.details << channels;
|
audio.details << channels;
|
||||||
|
|
||||||
audioDone = true;
|
audioDone = true;
|
||||||
@@ -133,7 +142,7 @@ MediaFileInfo::LoadInfo(BMediaFile* file)
|
|||||||
|
|
||||||
useconds = MAX(audioDuration, videoDuration);
|
useconds = MAX(audioDuration, videoDuration);
|
||||||
duration << (int32)(useconds / 1000000)
|
duration << (int32)(useconds / 1000000)
|
||||||
<< B_TRANSLATE(" seconds");
|
<< B_TRANSLATE(" seconds");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
|
#include <MessageFormat.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
@@ -385,16 +386,11 @@ printf("InfoWin::Update(0x%08" B_PRIx32 ")\n", which);
|
|||||||
bitsPerSample);
|
bitsPerSample);
|
||||||
s << bitString << " ";
|
s << bitString << " ";
|
||||||
}
|
}
|
||||||
if (channelCount == 1)
|
|
||||||
s << B_TRANSLATE("Mono");
|
static BMessageFormat channelFormat(B_TRANSLATE(
|
||||||
else if (channelCount == 2)
|
"{0, plural, =1{Mono} =2{Stereo} other{# Channels}}"));
|
||||||
s << B_TRANSLATE("Stereo");
|
channelFormat.Format(s, channelCount);
|
||||||
else {
|
|
||||||
char channelString[20];
|
|
||||||
snprintf(channelString, sizeof(channelString),
|
|
||||||
B_TRANSLATE("%d Channels"), channelCount);
|
|
||||||
s << channelString;
|
|
||||||
}
|
|
||||||
s << ", ";
|
s << ", ";
|
||||||
if (sr > 0.0) {
|
if (sr > 0.0) {
|
||||||
char rateString[20];
|
char rateString[20];
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
|
#include <DurationFormat.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
@@ -317,11 +318,10 @@ ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
|
|||||||
|
|
||||||
int32 kDelays[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20};
|
int32 kDelays[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20};
|
||||||
for (uint32 i = 0; i < sizeof(kDelays) / sizeof(kDelays[0]); i++) {
|
for (uint32 i = 0; i < sizeof(kDelays) / sizeof(kDelays[0]); i++) {
|
||||||
BString text(B_TRANSLATE_COMMENT("%SECONDS seconds",
|
BString text;
|
||||||
"Don't translate %SECONDS"));
|
BDurationFormat format;
|
||||||
char seconds[32];
|
text.Truncate(0);
|
||||||
snprintf(seconds, sizeof(seconds), "%" B_PRIi32, kDelays[i]);
|
format.Format(text, 0, kDelays[i] * 1000000LL);
|
||||||
text.ReplaceFirst("%SECONDS", seconds);
|
|
||||||
|
|
||||||
_AddDelayItem(delayMenu, text.String(), kDelays[i] * 1000000LL);
|
_AddDelayItem(delayMenu, text.String(), kDelays[i] * 1000000LL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <SpaceLayoutItem.h>
|
#include <SpaceLayoutItem.h>
|
||||||
#include <StatusBar.h>
|
#include <StatusBar.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
|
#include <TimeUnitFormat.h>
|
||||||
|
|
||||||
#include "BrowserWindow.h"
|
#include "BrowserWindow.h"
|
||||||
#include "WebDownload.h"
|
#include "WebDownload.h"
|
||||||
@@ -796,38 +797,36 @@ DownloadProgressView::_UpdateStatusText()
|
|||||||
finishTime -= now;
|
finishTime -= now;
|
||||||
time = gmtime(&finishTime);
|
time = gmtime(&finishTime);
|
||||||
|
|
||||||
|
BTimeUnitFormat timeFormat;
|
||||||
|
|
||||||
BString buffer2;
|
BString buffer2;
|
||||||
if (finishTime > secondsPerDay) {
|
if (finishTime > secondsPerDay) {
|
||||||
int64 days = finishTime / secondsPerDay;
|
int64 days = finishTime / secondsPerDay;
|
||||||
if (days == 1)
|
|
||||||
buffer2 << B_TRANSLATE("Over 1 day left");
|
BString time;
|
||||||
else {
|
timeFormat.Format(time, days, B_TIME_UNIT_DAY);
|
||||||
buffer2 << B_TRANSLATE("Over %days days left");
|
|
||||||
buffer2.ReplaceFirst("%days", BString() << days);
|
buffer2 << B_TRANSLATE("Over %days left");
|
||||||
}
|
buffer2.ReplaceFirst("%days", time);
|
||||||
} else if (finishTime > 60 * 60) {
|
} else if (finishTime > 60 * 60) {
|
||||||
int64 hours = finishTime / (60 * 60);
|
int64 hours = finishTime / (60 * 60);
|
||||||
if (hours == 1)
|
BString time;
|
||||||
buffer2 << B_TRANSLATE("Over 1 hour left");
|
timeFormat.Format(time, hours, B_TIME_UNIT_HOUR);
|
||||||
else {
|
|
||||||
buffer2 << B_TRANSLATE("Over %hours hours left");
|
buffer2 << B_TRANSLATE("Over %hours left");
|
||||||
buffer2.ReplaceFirst("%hours", BString() << hours);
|
buffer2.ReplaceFirst("%hours", time);
|
||||||
}
|
|
||||||
} else if (finishTime > 60) {
|
} else if (finishTime > 60) {
|
||||||
int64 minutes = finishTime / 60;
|
int64 minutes = finishTime / 60;
|
||||||
if (minutes == 1)
|
if (minutes == 1)
|
||||||
buffer2 << B_TRANSLATE("Over 1 minute left");
|
buffer2 << B_TRANSLATE("Over 1 minute left");
|
||||||
else {
|
else
|
||||||
buffer2 << B_TRANSLATE("%minutes minutes");
|
timeFormat.Format(buffer2, minutes, B_TIME_UNIT_MINUTE);
|
||||||
buffer2.ReplaceFirst("%minutes", BString() << minutes);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (finishTime == 1)
|
BString time;
|
||||||
buffer2 << B_TRANSLATE("1 second left");
|
timeFormat.Format(time, finishTime, B_TIME_UNIT_SECOND);
|
||||||
else {
|
|
||||||
buffer2 << B_TRANSLATE("%seconds seconds left");
|
buffer2 << B_TRANSLATE("%seconds left");
|
||||||
buffer2.ReplaceFirst("%seconds", BString() << finishTime);
|
buffer2.ReplaceFirst("%seconds", time);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = "(";
|
buffer = "(";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <MessageFormat.h>
|
||||||
#include <SystemCatalog.h>
|
#include <SystemCatalog.h>
|
||||||
|
|
||||||
using BPrivate::gSystemCatalog;
|
using BPrivate::gSystemCatalog;
|
||||||
@@ -24,9 +25,15 @@ string_for_size(double size, char* string, size_t stringSize)
|
|||||||
{
|
{
|
||||||
double kib = size / 1024.0;
|
double kib = size / 1024.0;
|
||||||
if (kib < 1.0) {
|
if (kib < 1.0) {
|
||||||
const char* trKey = B_TRANSLATE_MARK("%d bytes");
|
const char* trKey = B_TRANSLATE_MARK(
|
||||||
snprintf(string, stringSize, gSystemCatalog.GetString(trKey,
|
"{0, plural, one{# byte} other{# bytes}");
|
||||||
B_TRANSLATION_CONTEXT), (int)size);
|
|
||||||
|
BString tmp;
|
||||||
|
BMessageFormat format(
|
||||||
|
gSystemCatalog.GetString(trKey, B_TRANSLATION_CONTEXT));
|
||||||
|
format.Format(tmp, (int)size);
|
||||||
|
|
||||||
|
strlcpy(string, tmp.String(), stringSize);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double mib = kib / 1024.0;
|
double mib = kib / 1024.0;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ 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>
|
||||||
@@ -2051,10 +2052,13 @@ FileStatToString(StatStruct* stat, char* buffer, int32 length)
|
|||||||
tm timeData;
|
tm timeData;
|
||||||
localtime_r(&stat->st_mtime, &timeData);
|
localtime_r(&stat->st_mtime, &timeData);
|
||||||
|
|
||||||
|
BString size;
|
||||||
|
static BMessageFormat 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());
|
||||||
|
|
||||||
uint32 pos = sprintf(buffer,
|
strftime(buffer + pos, length - pos, "%b %d %Y, %I:%M:%S %p)", &timeData);
|
||||||
B_TRANSLATE("\n\t(%Ld bytes, "), stat->st_size);
|
|
||||||
strftime(buffer + pos, length - pos,"%b %d %Y, %I:%M:%S %p)", &timeData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ 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 <TextView.h>
|
#include <TextView.h>
|
||||||
@@ -105,7 +106,9 @@ TruncFileSizeBase(BString* outString, int64 value, const View* view,
|
|||||||
*outString = "-";
|
*outString = "-";
|
||||||
return view->StringWidth("-");
|
return view->StringWidth("-");
|
||||||
} else if (value < kKBSize) {
|
} else if (value < kKBSize) {
|
||||||
buffer.SetToFormat(B_TRANSLATE("%Ld bytes"), value);
|
static BMessageFormat format(B_TRANSLATE(
|
||||||
|
"{0, plural, one{# byte} other{# bytes}}"));
|
||||||
|
format.Format(buffer, value);
|
||||||
if (view->StringWidth(buffer.String()) > width)
|
if (view->StringWidth(buffer.String()) > width)
|
||||||
buffer.SetToFormat(B_TRANSLATE("%Ld B"), value);
|
buffer.SetToFormat(B_TRANSLATE("%Ld B"), value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
#include <TimeUnitFormat.h>
|
||||||
|
|
||||||
#include <IconUtils.h>
|
#include <IconUtils.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
@@ -134,8 +135,13 @@ void
|
|||||||
AlertView::UpdateCountdownView()
|
AlertView::UpdateCountdownView()
|
||||||
{
|
{
|
||||||
BString string;
|
BString string;
|
||||||
string = B_TRANSLATE("Settings will revert in %seconds seconds.");
|
string = B_TRANSLATE("Settings will revert in %seconds.");
|
||||||
string.ReplaceFirst("%seconds", BString() << fSeconds);
|
|
||||||
|
BTimeUnitFormat format;
|
||||||
|
BString tmp;
|
||||||
|
format.Format(tmp, fSeconds, B_TIME_UNIT_SECOND);
|
||||||
|
|
||||||
|
string.ReplaceFirst("%seconds", tmp);
|
||||||
fCountdownView->SetText(string.String());
|
fCountdownView->SetText(string.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user