Updated to use B_TRANSLATE* macros. relates to #5408.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36676 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matt Madia
2010-05-06 22:32:37 +00:00
parent 6c514d3e3b
commit eef956245e
8 changed files with 135 additions and 117 deletions
@@ -37,7 +37,7 @@ ImageView::ImageView(BPositionIO *image)
// Initialize and translate the image // Initialize and translate the image
BTranslatorRoster *roster = BTranslatorRoster::Default(); BTranslatorRoster *roster = BTranslatorRoster::Default();
BBitmapStream stream; BBitmapStream stream;
if (roster->Translate(image, NULL, NULL, &stream, B_TRANSLATOR_BITMAP) if (roster->Translate(image, NULL, NULL, &stream, B_TRANSLATOR_BITMAP)
< B_OK) { < B_OK) {
fSuccess = false; fSuccess = false;
return; return;
@@ -80,8 +80,8 @@ ImageView::Draw(BRect updateRect)
if (fSuccess) if (fSuccess)
DrawBitmapAsync(fImage, Bounds()); DrawBitmapAsync(fImage, Bounds());
else { else {
float length = StringWidth(TR("Image not loaded correctly")); float length = StringWidth(B_TRANSLATE("Image not loaded correctly"));
DrawString(TR("Image not loaded correctly"), DrawString(B_TRANSLATE("Image not loaded correctly"),
BPoint((Bounds().Width() - length) / 2.0f, 30.0f)); BPoint((Bounds().Width() - length) / 2.0f, 30.0f));
} }
} }
@@ -111,7 +111,7 @@ PackageImageViewer::PackageImageViewer(BPositionIO *image)
BScreen screen(this); BScreen screen(this);
BRect frame = screen.Frame(); BRect frame = screen.Frame();
MoveTo((frame.Width() - Bounds().Width()) / 2.0f, MoveTo((frame.Width() - Bounds().Width()) / 2.0f,
(frame.Height() - Bounds().Height()) / 2.0f); (frame.Height() - Bounds().Height()) / 2.0f);
} }
@@ -148,7 +148,7 @@ PackageImageViewer::Go()
break; break;
parent->UpdateIfNeeded(); parent->UpdateIfNeeded();
} }
} }
else { else {
// Since there are no spinlocks, wait until the semaphore is free // Since there are no spinlocks, wait until the semaphore is free
while (acquire_sem(fSemaphore) == B_INTERRUPTED) { while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
+9 -8
View File
@@ -50,7 +50,7 @@ PackageInfo::PackageInfo()
: :
fStatus(B_NO_INIT), fStatus(B_NO_INIT),
fPackageFile(0), fPackageFile(0),
fDescription(TR("No package available.")), fDescription(B_TRANSLATE("No package available.")),
fProfiles(2), fProfiles(2),
fHasImage(false) fHasImage(false)
{ {
@@ -61,7 +61,7 @@ PackageInfo::PackageInfo(const entry_ref *ref)
: :
fStatus(B_NO_INIT), fStatus(B_NO_INIT),
fPackageFile(new BFile(ref, B_READ_ONLY)), fPackageFile(new BFile(ref, B_READ_ONLY)),
fDescription(TR("No package selected.")), fDescription(B_TRANSLATE("No package selected.")),
fProfiles(2), fProfiles(2),
fHasImage(false) fHasImage(false)
{ {
@@ -999,7 +999,7 @@ PackageInfo::Parse()
localType, ctime, mtime, mode, offset, size); localType, ctime, mtime, mode, offset, size);
} }
} else if (element == P_SCRIPT) { } else if (element == P_SCRIPT) {
fScripts.AddItem(new PackageScript(fPackageFile, offset, size, fScripts.AddItem(new PackageScript(fPackageFile, offset, size,
originalSize)); originalSize));
} else { } else {
// If the directory tree count is equal to zero, this means all // If the directory tree count is equal to zero, this means all
@@ -1029,7 +1029,7 @@ PackageInfo::Parse()
parser_debug("PtcI\n"); parser_debug("PtcI\n");
break; break;
} else { } else {
fprintf(stderr, TR("Unknown file tag %s\n"), buffer); fprintf(stderr, B_TRANSLATE("Unknown file tag %s\n"), buffer);
RETURN_AND_SET_STATUS(B_ERROR); RETURN_AND_SET_STATUS(B_ERROR);
} }
} }
@@ -1038,10 +1038,11 @@ PackageInfo::Parse()
// Inform the user of a possible error // Inform the user of a possible error
int32 selection; int32 selection;
BAlert *warning = new BAlert("filesize_wrong", BAlert *warning = new BAlert("filesize_wrong",
TR("There seems to be a file size mismatch in the package file. " B_TRANSLATE("There seems to be a file size mismatch in the "
"The package might be corrupted or have been modified after its " "package file. The package might be corrupted or have been "
"creation. Do you still wish to continue?"), TR("Continue"), "modified after its creation. Do you still wish to continue?"),
TR("Abort"), NULL, B_TRANSLATE("Continue"),
B_TRANSLATE("Abort"), NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_WIDTH_AS_USUAL, B_WARNING_ALERT);
selection = warning->Go(); selection = warning->Go();
+18 -15
View File
@@ -57,7 +57,7 @@ PackageInstall::Start()
if (fThreadId > -1) { if (fThreadId > -1) {
ret = B_BUSY; ret = B_BUSY;
} else { } else {
fThreadId = spawn_thread(install_function, "install_package", B_NORMAL_PRIORITY, fThreadId = spawn_thread(install_function, "install_package", B_NORMAL_PRIORITY,
static_cast<void *>(this)); static_cast<void *>(this));
resume_thread(fThreadId); resume_thread(fThreadId);
} }
@@ -111,7 +111,7 @@ PackageInstall::_Install()
PackageStatus *progress = fParent->GetStatusWindow(); PackageStatus *progress = fParent->GetStatusWindow();
progress->Reset(n + m + 5); progress->Reset(n + m + 5);
progress->StageStep(1, TR("Preparing package")); progress->StageStep(1, B_TRANSLATE("Preparing package"));
InstalledPackageInfo packageInfo(info->GetName(), info->GetVersion()); InstalledPackageInfo packageInfo(info->GetName(), info->GetVersion());
@@ -119,21 +119,23 @@ PackageInstall::_Install()
if (err == B_OK) { if (err == B_OK) {
// The package is already installed, inform the user // The package is already installed, inform the user
BAlert *reinstall = new BAlert("reinstall", BAlert *reinstall = new BAlert("reinstall",
TR("The given package seems to be already installed on your " B_TRANSLATE("The given package seems to be already installed on "
"system. Would you like to uninstall the existing one and " "your system. Would you like to uninstall the existing one "
"continue the installation?"), TR("Continue"), TR("Abort")); "and continue the installation?"),
B_TRANSLATE("Continue"),
B_TRANSLATE("Abort"));
if (reinstall->Go() == 0) { if (reinstall->Go() == 0) {
// Uninstall the package // Uninstall the package
err = packageInfo.Uninstall(); err = packageInfo.Uninstall();
if (err != B_OK) { if (err != B_OK) {
fprintf(stderr, TR("Error on uninstall\n")); fprintf(stderr, B_TRANSLATE("Error on uninstall\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true);
if (err != B_OK) { if (err != B_OK) {
fprintf(stderr, TR("Error on SetTo\n")); fprintf(stderr, B_TRANSLATE("Error on SetTo\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
} else { } else {
@@ -143,17 +145,17 @@ PackageInstall::_Install()
} else if (err == B_ENTRY_NOT_FOUND) { } else if (err == B_ENTRY_NOT_FOUND) {
err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true);
if (err != B_OK) { if (err != B_OK) {
fprintf(stderr, TR("Error on SetTo\n")); fprintf(stderr, B_TRANSLATE("Error on SetTo\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
} else if (progress->Stopped()) { } else if (progress->Stopped()) {
return P_MSG_I_ABORT; return P_MSG_I_ABORT;
} else { } else {
fprintf(stderr, TR("returning on error\n")); fprintf(stderr, B_TRANSLATE("returning on error\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
progress->StageStep(1, TR("Installing files and folders")); progress->StageStep(1, B_TRANSLATE("Installing files and folders"));
// Install files and directories // Install files and directories
PackageItem *iter; PackageItem *iter;
@@ -195,7 +197,7 @@ PackageInstall::_Install()
} }
if (err != B_OK) { if (err != B_OK) {
fprintf(stderr, TR("Error while writing path\n")); fprintf(stderr, B_TRANSLATE("Error while writing path\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
@@ -208,7 +210,8 @@ PackageInstall::_Install()
packageInfo.AddItem(state.destination.Path()); packageInfo.AddItem(state.destination.Path());
} }
progress->StageStep(1, TR("Running post-installation scripts"), ""); progress->StageStep(1, B_TRANSLATE("Running post-installation scripts"),
"");
PackageScript *scr; PackageScript *scr;
status_t status; status_t status;
@@ -220,7 +223,7 @@ PackageInstall::_Install()
fCurrentScript = scr; fCurrentScript = scr;
if (scr->DoInstall() != B_OK) { if (scr->DoInstall() != B_OK) {
fprintf(stderr, TR("Error while running script\n")); fprintf(stderr, B_TRANSLATE("Error while running script\n"));
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
} }
fCurrentScriptLocker.Unlock(); fCurrentScriptLocker.Unlock();
@@ -238,13 +241,13 @@ PackageInstall::_Install()
progress->StageStep(1, NULL, label.String()); progress->StageStep(1, NULL, label.String());
} }
progress->StageStep(1, TR("Finishing installation"), ""); progress->StageStep(1, B_TRANSLATE("Finishing installation"), "");
err = packageInfo.Save(); err = packageInfo.Save();
if (err != B_OK) if (err != B_OK)
return P_MSG_I_ERROR; return P_MSG_I_ERROR;
progress->StageStep(1, TR("Done")); progress->StageStep(1, B_TRANSLATE("Done"));
// Inform our parent that we finished // Inform our parent that we finished
return P_MSG_I_FINISHED; return P_MSG_I_FINISHED;
+8 -7
View File
@@ -23,7 +23,8 @@
StopButton::StopButton() StopButton::StopButton()
: :
BButton(BRect(0, 0, 22, 18), "stop", TR("Stop"), new BMessage(P_MSG_STOP)) BButton(BRect(0, 0, 22, 18), "stop", B_TRANSLATE("Stop"),
new BMessage(P_MSG_STOP))
{ {
} }
@@ -48,7 +49,7 @@ StopButton::Draw(BRect updateRect)
// #pragma mark - // #pragma mark -
/*PackageStatus::PackageStatus(BHandler *parent, const char *title, /*PackageStatus::PackageStatus(BHandler *parent, const char *title,
const char *label, const char *trailing) const char *label, const char *trailing)
: BWindow(BRect(200, 200, 550, 275), title, B_TITLED_WINDOW, : BWindow(BRect(200, 200, 550, 275), title, B_TITLED_WINDOW,
B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0) B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0)
@@ -72,7 +73,7 @@ StopButton::Draw(BRect updateRect)
font_height fontHeight; font_height fontHeight;
fBackground->GetFontHeight(&fontHeight); fBackground->GetFontHeight(&fontHeight);
BRect frame = fStatus->Frame(); BRect frame = fStatus->Frame();
fBackground->ResizeTo(Bounds().Width(), (2 * frame.top) + frame.Height() + fBackground->ResizeTo(Bounds().Width(), (2 * frame.top) + frame.Height() +
fontHeight.leading + fontHeight.ascent + fontHeight.descent); fontHeight.leading + fontHeight.ascent + fontHeight.descent);
rect = Bounds(); rect = Bounds();
@@ -93,7 +94,7 @@ StopButton::Draw(BRect updateRect)
}*/ }*/
PackageStatus::PackageStatus(const char *title, const char *label, PackageStatus::PackageStatus(const char *title, const char *label,
const char *trailing, BHandler *parent) const char *trailing, BHandler *parent)
: :
BWindow(BRect(200, 200, 550, 255), title, B_TITLED_WINDOW, BWindow(BRect(200, 200, 550, 255), title, B_TITLED_WINDOW,
@@ -103,7 +104,7 @@ PackageStatus::PackageStatus(const char *title, const char *label,
{ {
SetLayout(new BGroupLayout(B_VERTICAL)); SetLayout(new BGroupLayout(B_VERTICAL));
fStatus = new BStatusBar("status_bar", TR("Installing package")); fStatus = new BStatusBar("status_bar", B_TRANSLATE("Installing package"));
fStatus->SetBarHeight(12); fStatus->SetBarHeight(12);
fButton = new StopButton(); fButton = new StopButton();
@@ -114,9 +115,9 @@ PackageStatus::PackageStatus(const char *title, const char *label,
.Add(fStatus) .Add(fStatus)
.Add(fButton); .Add(fButton);
fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(fBackground); AddChild(fBackground);
fButton->SetTarget(this); fButton->SetTarget(this);
Run(); Run();
} }
+14 -14
View File
@@ -29,8 +29,8 @@ enum {
PackageTextViewer::PackageTextViewer(const char *text, bool disclaimer) PackageTextViewer::PackageTextViewer(const char *text, bool disclaimer)
: :
BWindow(BRect(125, 125, 675, 475), TR("Disclaimer"), B_MODAL_WINDOW, BWindow(BRect(125, 125, 675, 475), B_TRANSLATE("Disclaimer"),
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE), B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE),
fValue(0) fValue(0)
{ {
_InitView(text, disclaimer); _InitView(text, disclaimer);
@@ -69,7 +69,7 @@ PackageTextViewer::Go()
break; break;
parent->UpdateIfNeeded(); parent->UpdateIfNeeded();
} }
} }
else { else {
// Since there are no spinlocks, wait until the semaphore is free // Since there are no spinlocks, wait until the semaphore is free
while (acquire_sem(fSemaphore) == B_INTERRUPTED) { while (acquire_sem(fSemaphore) == B_INTERRUPTED) {
@@ -117,7 +117,7 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
BRect rect = Bounds(); BRect rect = Bounds();
if (disclaimer) { if (disclaimer) {
BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", BButton *button = new BButton(BRect(0, 0, 1, 1), "accept",
TR("Accept"), new BMessage(P_MSG_ACCEPT)); B_TRANSLATE("Accept"), new BMessage(P_MSG_ACCEPT));
button->ResizeToPreferred(); button->ResizeToPreferred();
bounds = button->Bounds(); bounds = button->Bounds();
@@ -129,8 +129,8 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
button->MakeDefault(true); button->MakeDefault(true);
fBackground->AddChild(button); fBackground->AddChild(button);
button = new BButton(BRect(0, 0, 1, 1), "decline", TR("Decline"), button = new BButton(BRect(0, 0, 1, 1), "decline",
new BMessage(P_MSG_DECLINE)); B_TRANSLATE("Decline"), new BMessage(P_MSG_DECLINE));
button->ResizeToPreferred(); button->ResizeToPreferred();
bounds = button->Bounds(); bounds = button->Bounds();
@@ -139,7 +139,7 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
fBackground->AddChild(button); fBackground->AddChild(button);
} else { } else {
BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", BButton *button = new BButton(BRect(0, 0, 1, 1), "accept",
TR("Continue"), new BMessage(P_MSG_ACCEPT)); B_TRANSLATE("Continue"), new BMessage(P_MSG_ACCEPT));
button->ResizeToPreferred(); button->ResizeToPreferred();
bounds = button->Bounds(); bounds = button->Bounds();
@@ -164,7 +164,7 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
BScrollView *scroll = new BScrollView("scroll_view", fText, BScrollView *scroll = new BScrollView("scroll_view", fText,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
fBackground->AddChild(scroll); fBackground->AddChild(scroll);
AddChild(fBackground); AddChild(fBackground);
@@ -175,8 +175,8 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
PackageTextViewer::_InitView(const char *text, bool disclaimer) PackageTextViewer::_InitView(const char *text, bool disclaimer)
{ {
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
fText = new BTextView(BRect(0, 0, 1, 1), "text_view", BRect(0, 0, 1, 1), fText = new BTextView(BRect(0, 0, 1, 1), "text_view", BRect(0, 0, 1, 1),
B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT); B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
fText->MakeEditable(false); fText->MakeEditable(false);
fText->MakeSelectable(true); fText->MakeSelectable(true);
@@ -184,10 +184,10 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true);
if (disclaimer) { if (disclaimer) {
BButton *accept = new BButton("accept", TR("Accept"), BButton *accept = new BButton("accept", B_TRANSLATE("Accept"),
new BMessage(P_MSG_ACCEPT)); new BMessage(P_MSG_ACCEPT));
BButton *decline = new BButton("decline", TR("Decline"), BButton *decline = new BButton("decline", B_TRANSLATE("Decline"),
new BMessage(P_MSG_DECLINE)); new BMessage(P_MSG_DECLINE));
fBackground = BGroupLayoutBuilder(B_VERTICAL) fBackground = BGroupLayoutBuilder(B_VERTICAL)
@@ -199,7 +199,7 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
.End(); .End();
} }
else { else {
BButton *button = new BButton("accept", TR("Continue"), BButton *button = new BButton("accept", B_TRANSLATE("Continue"),
new BMessage(P_MSG_ACCEPT)); new BMessage(P_MSG_ACCEPT));
fBackground = BGroupLayoutBuilder(B_VERTICAL) fBackground = BGroupLayoutBuilder(B_VERTICAL)
@@ -211,7 +211,7 @@ PackageTextViewer::_InitView(const char *text, bool disclaimer)
} }
AddChild(fBackground); AddChild(fBackground);
fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fBackground->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fText->SetText(text); fText->SetText(text);
}*/ }*/
+64 -54
View File
@@ -46,14 +46,15 @@ static void
convert_size(uint64 size, char *buffer, uint32 n) convert_size(uint64 size, char *buffer, uint32 n)
{ {
if (size < 1024) if (size < 1024)
snprintf(buffer, n, TR("%llu bytes"), size); snprintf(buffer, n, B_TRANSLATE("%llu bytes"), size);
else if (size < 1024 * 1024) else if (size < 1024 * 1024)
snprintf(buffer, n, TR("%.1f KiB"), size / 1024.0f); snprintf(buffer, n, B_TRANSLATE("%.1f KiB"), size / 1024.0f);
else if (size < 1024 * 1024 * 1024) else if (size < 1024 * 1024 * 1024)
snprintf(buffer, n, TR("%.1f MiB"), size / (1024.0f * 1024.0f)); snprintf(buffer, n, B_TRANSLATE("%.1f MiB"),
size / (1024.0f * 1024.0f));
else { else {
snprintf(buffer, n, TR("%.1f GiB"), size snprintf(buffer, n, B_TRANSLATE("%.1f GiB"),
/ (1024.0f * 1024.0f * 1024.0f)); size / (1024.0f * 1024.0f * 1024.0f));
} }
} }
@@ -93,10 +94,10 @@ PackageView::AttachedToWindow()
status_t ret = fInfo.InitCheck(); status_t ret = fInfo.InitCheck();
if (ret != B_OK && ret != B_NO_INIT) { if (ret != B_OK && ret != B_NO_INIT) {
BAlert *warning = new BAlert("parsing_failed", BAlert *warning = new BAlert("parsing_failed",
TR("The package file is not readable.\nOne of the possible " B_TRANSLATE("The package file is not readable.\nOne of the "
"reasons for this might be that the requested file is not a " "possible reasons for this might be that the requested file "
"valid BeOS .pkg package."), TR("OK"), NULL, NULL, "is not a valid BeOS .pkg package."), B_TRANSLATE("OK"),
B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
warning->Go(); warning->Go();
Window()->PostMessage(B_QUIT_REQUESTED); Window()->PostMessage(B_QUIT_REQUESTED);
@@ -108,10 +109,10 @@ PackageView::AttachedToWindow()
BString title; BString title;
BString name = fInfo.GetName(); BString name = fInfo.GetName();
if (name.CountChars() == 0) { if (name.CountChars() == 0) {
title = TR("Package installer"); title = B_TRANSLATE("Package installer");
} }
else { else {
title = TR("Install "); title = B_TRANSLATE("Install ");
title += name; title += name;
} }
parent->SetTitle(title.String()); parent->SetTitle(title.String());
@@ -126,8 +127,9 @@ PackageView::AttachedToWindow()
// attaching the view to the window // attaching the view to the window
_GroupChanged(0); _GroupChanged(0);
fStatusWindow = new PackageStatus(TR("Installation progress"), NULL, fStatusWindow = new PackageStatus
NULL, this); (B_TRANSLATE("Installation progress"),
NULL, NULL, this);
// Show the splash screen, if present // Show the splash screen, if present
BMallocIO *image = fInfo.GetSplashScreen(); BMallocIO *image = fInfo.GetSplashScreen();
@@ -190,8 +192,9 @@ PackageView::MessageReceived(BMessage *msg)
case P_MSG_I_FINISHED: case P_MSG_I_FINISHED:
{ {
BAlert *notify = new BAlert("installation_success", BAlert *notify = new BAlert("installation_success",
TR("The package you requested has been successfully installed " B_TRANSLATE("The package you requested has been successfully "
"on your system."), TR("OK")); "installed on your system."),
B_TRANSLATE("OK"));
notify->Go(); notify->Go();
fStatusWindow->Hide(); fStatusWindow->Hide();
@@ -208,8 +211,9 @@ PackageView::MessageReceived(BMessage *msg)
case P_MSG_I_ABORT: case P_MSG_I_ABORT:
{ {
BAlert *notify = new BAlert("installation_aborted", BAlert *notify = new BAlert("installation_aborted",
TR("The installation of the package has been aborted."), B_TRANSLATE(
TR("OK")); "The installation of the package has been aborted."),
B_TRANSLATE("OK"));
notify->Go(); notify->Go();
fStatusWindow->Hide(); fStatusWindow->Hide();
fInstall->SetEnabled(true); fInstall->SetEnabled(true);
@@ -222,11 +226,14 @@ PackageView::MessageReceived(BMessage *msg)
{ {
// TODO: Review this // TODO: Review this
BAlert *notify = new BAlert("installation_failed", BAlert *notify = new BAlert("installation_failed",
TR("The requested package failed to install on your system. " B_TRANSLATE("The requested package failed to install on your "
"This might be a problem with the target package file. Please " "system. This might be a problem with the target package "
"consult this issue with the package distributor."), "file. Please consult this issue with the package "
TR("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); "distributor."),
fprintf(stderr, TR("Error while installing the package\n")); B_TRANSLATE("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
fprintf(stderr,
B_TRANSLATE("Error while installing the package\n"));
notify->Go(); notify->Go();
fStatusWindow->Hide(); fStatusWindow->Hide();
fInstall->SetEnabled(true); fInstall->SetEnabled(true);
@@ -313,38 +320,40 @@ PackageView::ItemExists(PackageItem &item, BPath &path, int32 &policy)
const char* formatString; const char* formatString;
switch (item.ItemKind()){ switch (item.ItemKind()){
case P_KIND_SCRIPT: case P_KIND_SCRIPT:
formatString = TR("The script named \'%s\' already exits " formatString = B_TRANSLATE("The script named \'%s\' "
"in the given path.\nReplace the script with the one " "already exits in the given path.\nReplace the script "
"from this package or skip it?"); "with the one from this package or skip it?");
break; break;
case P_KIND_FILE: case P_KIND_FILE:
formatString = TR("The file named \'%s\' already exits " formatString = B_TRANSLATE("The file named \'%s\' already "
"in the given path.\nReplace the file with the one " "exits in the given path.\nReplace the file with the "
"from this package or skip it?"); "one from this package or skip it?");
break; break;
case P_KIND_DIRECTORY: case P_KIND_DIRECTORY:
formatString = TR("The directory named \'%s\' already " formatString = B_TRANSLATE("The directory named \'%s\' "
"exits in the given path.\nReplace the directory with " "already exits in the given path.\nReplace the "
"one from this package or skip it?"); "directory with one from this package or skip it?");
break; break;
case P_KIND_SYM_LINK: case P_KIND_SYM_LINK:
formatString = TR("The symbolic link named \'%s\' already " formatString = B_TRANSLATE("The symbolic link named \'%s\' "
"exists in the give path.\nReplace the link with the " "already exists in the give path.\nReplace the link "
"one from this package or skip it?"); "with the one from this package or skip it?");
break; break;
default: default:
formatString = TR("The item named \'%s\' already exits " formatString = B_TRANSLATE("The item named \'%s\' already "
"in the given path.\nReplace the item with the one " "exits in the given path.\nReplace the item with the "
"from this package or skip it?"); "one from this package or skip it?");
break; break;
} }
char buffer[512]; char buffer[512];
snprintf(buffer, sizeof(buffer), formatString, path.Leaf()); snprintf(buffer, sizeof(buffer), formatString, path.Leaf());
BString alertString = buffer; BString alertString = buffer;
BAlert *alert = new BAlert("file_exists", alertString.String(), BAlert *alert = new BAlert("file_exists", alertString.String(),
TR("Replace"), TR("Skip"), TR("Abort")); B_TRANSLATE("Replace"),
B_TRANSLATE("Skip"),
B_TRANSLATE("Abort"));
choice = alert->Go(); choice = alert->Go();
switch (choice) { switch (choice) {
@@ -360,14 +369,14 @@ PackageView::ItemExists(PackageItem &item, BPath &path, int32 &policy)
if (policy == P_EXISTS_NONE) { if (policy == P_EXISTS_NONE) {
// TODO: Maybe add 'No, but ask again' type of choice as well? // TODO: Maybe add 'No, but ask again' type of choice as well?
alertString = TR("Do you want to remember this decision for " alertString = B_TRANSLATE("Do you want to remember this "
"the rest of this installation?\n"); "decision for the rest of this installation?\n");
alertString << ((choice == P_EXISTS_OVERWRITE) alertString << ((choice == P_EXISTS_OVERWRITE)
? TR("All existing files will be replaced?") ? B_TRANSLATE("All existing files will be replaced?")
: TR("All existing files will be skipped?")); : B_TRANSLATE("All existing files will be skipped?"));
alert = new BAlert("policy_decision", alertString.String(), alert = new BAlert("policy_decision", alertString.String(),
TR("Replace all"), TR("Ask again")); B_TRANSLATE("Replace all"), B_TRANSLATE("Ask again"));
int32 decision = alert->Go(); int32 decision = alert->Go();
if (decision == 0) if (decision == 0)
@@ -399,7 +408,7 @@ PackageView::_InitView()
fInstallTypes = new BPopUpMenu("none"); fInstallTypes = new BPopUpMenu("none");
BMenuField *installType = new BMenuField("install_type", BMenuField *installType = new BMenuField("install_type",
TR("Installation type:"), fInstallTypes, 0); B_TRANSLATE("Installation type:"), fInstallTypes, 0);
installType->SetAlignment(B_ALIGN_RIGHT); installType->SetAlignment(B_ALIGN_RIGHT);
installType->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); installType->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE));
@@ -408,10 +417,10 @@ PackageView::_InitView()
fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fInstallDesc->MakeEditable(false); fInstallDesc->MakeEditable(false);
fInstallDesc->MakeSelectable(false); fInstallDesc->MakeSelectable(false);
fInstallDesc->SetText(TR("No installation type selected")); fInstallDesc->SetText(B_TRANSLATE("No installation type selected"));
fInstallDesc->TextHeight(0, fInstallDesc->TextLength()); fInstallDesc->TextHeight(0, fInstallDesc->TextLength());
fInstall = new BButton("install_button", TR("Install"), fInstall = new BButton("install_button", B_TRANSLATE("Install"),
new BMessage(P_MSG_INSTALL)); new BMessage(P_MSG_INSTALL));
BView *installField = BGroupLayoutBuilder(B_VERTICAL, 5.0f) BView *installField = BGroupLayoutBuilder(B_VERTICAL, 5.0f)
@@ -476,7 +485,8 @@ PackageView::_InitView()
fInstallTypes = new BPopUpMenu("none"); fInstallTypes = new BPopUpMenu("none");
BMenuField *installType = new BMenuField(BRect(2, 2, 100, 50), BMenuField *installType = new BMenuField(BRect(2, 2, 100, 50),
"install_type", TR("Installation type:"), fInstallTypes, false); "install_type", B_TRANSLATE("Installation type:"),
fInstallTypes, false);
installType->SetDivider(installType->StringWidth(installType->Label()) + 8); installType->SetDivider(installType->StringWidth(installType->Label()) + 8);
installType->SetAlignment(B_ALIGN_RIGHT); installType->SetAlignment(B_ALIGN_RIGHT);
installType->ResizeToPreferred(); installType->ResizeToPreferred();
@@ -490,7 +500,7 @@ PackageView::_InitView()
B_WILL_DRAW); B_WILL_DRAW);
fInstallDesc->MakeEditable(false); fInstallDesc->MakeEditable(false);
fInstallDesc->MakeSelectable(false); fInstallDesc->MakeSelectable(false);
fInstallDesc->SetText(TR("No installation type selected")); fInstallDesc->SetText(B_TRANSLATE("No installation type selected"));
fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fInstallDesc->ResizeTo(rect.Width() - B_V_SCROLL_BAR_WIDTH, 60); fInstallDesc->ResizeTo(rect.Width() - B_V_SCROLL_BAR_WIDTH, 60);
@@ -509,7 +519,7 @@ PackageView::_InitView()
rect = installBox->Frame(); rect = installBox->Frame();
rect.top = rect.bottom + 5; rect.top = rect.bottom + 5;
rect.bottom += 35; rect.bottom += 35;
fDestField = new BMenuField(rect, "install_to", TR("Install to:"), fDestField = new BMenuField(rect, "install_to", B_TRANSLATE("Install to:"),
fDestination, false); fDestination, false);
fDestField->SetDivider(fDestField->StringWidth(fDestField->Label()) + 8); fDestField->SetDivider(fDestField->StringWidth(fDestField->Label()) + 8);
fDestField->SetAlignment(B_ALIGN_RIGHT); fDestField->SetAlignment(B_ALIGN_RIGHT);
@@ -517,7 +527,7 @@ PackageView::_InitView()
AddChild(fDestField); AddChild(fDestField);
fInstall = new BButton(rect, "install_button", TR("Install"), fInstall = new BButton(rect, "install_button", B_TRANSLATE("Install"),
new BMessage(P_MSG_INSTALL)); new BMessage(P_MSG_INSTALL));
fInstall->ResizeToPreferred(); fInstall->ResizeToPreferred();
AddChild(fInstall); AddChild(fInstall);
@@ -600,7 +610,7 @@ PackageView::_GroupChanged(int32 index)
BMessage *temp; BMessage *temp;
BVolume volume; BVolume volume;
char buffer[512]; char buffer[512];
const char *tmp = TR("(%s free)"); const char *tmp = B_TRANSLATE("(%s free)");
if (prof->path_type == P_INSTALL_PATH) { if (prof->path_type == P_INSTALL_PATH) {
dev_t device; dev_t device;
@@ -645,7 +655,7 @@ PackageView::_GroupChanged(int32 index)
} }
fDestination->AddSeparatorItem(); fDestination->AddSeparatorItem();
item = new BMenuItem(TR("Other" B_UTF8_ELLIPSIS), item = new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
new BMessage(P_MSG_OPEN_PANEL)); new BMessage(P_MSG_OPEN_PANEL));
item->SetTarget(this); item->SetTarget(this);
fDestination->AddItem(item); fDestination->AddItem(item);
+2 -2
View File
@@ -21,7 +21,7 @@
PackageWindow::PackageWindow(const entry_ref *ref) PackageWindow::PackageWindow(const entry_ref *ref)
: :
BWindow(BRect(100, 100, 600, 300), TR("PackageInstaller"), BWindow(BRect(100, 100, 600, 300), B_TRANSLATE("PackageInstaller"),
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE) B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{ {
//SetLayout(new BGroupLayout(B_HORIZONTAL)); //SetLayout(new BGroupLayout(B_HORIZONTAL));
@@ -36,7 +36,7 @@ PackageWindow::PackageWindow(const entry_ref *ref)
PackageWindow::~PackageWindow() PackageWindow::~PackageWindow()
{ {
RemoveChild(fBackground); RemoveChild(fBackground);
delete fBackground; delete fBackground;
} }
+15 -12
View File
@@ -28,13 +28,13 @@ class PackageInstaller : public BApplication {
public: public:
PackageInstaller(); PackageInstaller();
~PackageInstaller(); ~PackageInstaller();
void RefsReceived(BMessage *msg); void RefsReceived(BMessage *msg);
void ArgvReceived(int32 argc, char **argv); void ArgvReceived(int32 argc, char **argv);
void ReadyToRun(); void ReadyToRun();
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
void AboutRequested(); void AboutRequested();
private: private:
@@ -92,7 +92,7 @@ PackageInstaller::RefsReceived(BMessage *msg)
} }
void void
PackageInstaller::ArgvReceived(int32 argc, char **argv) PackageInstaller::ArgvReceived(int32 argc, char **argv)
{ {
int i; int i;
@@ -100,17 +100,20 @@ PackageInstaller::ArgvReceived(int32 argc, char **argv)
entry_ref ref; entry_ref ref;
status_t ret = B_OK; status_t ret = B_OK;
PackageWindow *iter = 0; PackageWindow *iter = 0;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
if (path.SetTo(argv[i]) != B_OK) { if (path.SetTo(argv[i]) != B_OK) {
fprintf(stderr, TR("Error! \"%s\" is not a valid path.\n"), argv[i]); fprintf(stderr,
B_TRANSLATE("Error! \"%s\" is not a valid path.\n"),
argv[i]);
continue; continue;
} }
ret = get_ref_for_path(path.Path(), &ref); ret = get_ref_for_path(path.Path(), &ref);
if (ret != B_OK) { if (ret != B_OK) {
fprintf(stderr, TR("Error (%s)! Could not open \"%s\".\n"), strerror(ret), fprintf(stderr,
argv[i]); B_TRANSLATE("Error (%s)! Could not open \"%s\".\n"),
strerror(ret), argv[i]);
continue; continue;
} }
@@ -144,11 +147,11 @@ void
PackageInstaller::AboutRequested() PackageInstaller::AboutRequested()
{ {
BAlert *about = new BAlert("about", BAlert *about = new BAlert("about",
TR("PackageInstaller\n" B_TRANSLATE("PackageInstaller\n"
"BeOS legacy .pkg file installer for Haiku.\n\n" "BeOS legacy .pkg file installer for Haiku.\n\n"
"Copyright 2007,\nŁukasz 'Sil2100' Zemczak\n\n" "Copyright 2007,\nŁukasz 'Sil2100' Zemczak\n\n"
"Copyright (c) 2007 Haiku, Inc. \n"), "Copyright (c) 2007 Haiku, Inc. \n"),
TR("OK")); B_TRANSLATE("OK"));
BTextView *view = about->TextView(); BTextView *view = about->TextView();
BFont font; BFont font;
@@ -167,7 +170,7 @@ main(void)
{ {
PackageInstaller app; PackageInstaller app;
app.Run(); app.Run();
return 0; return 0;
} }