Author: stippi Date: 2010-05-05 10:00:57 +0200 (Wed, 05 May 2010) New Revision: 36618 Changeset: http://dev.haiku-os.org/changeset/36618/haiku Ticket: http://dev.haiku-os.org/ticket/5907 Modified: haiku/trunk/src/apps/packageinstaller/Jamfile haiku/trunk/src/apps/packageinstaller/PackageImageViewer.cpp haiku/trunk/src/apps/packageinstaller/PackageInfo.cpp haiku/trunk/src/apps/packageinstaller/PackageInstall.cpp haiku/trunk/src/apps/packageinstaller/PackageItem.cpp haiku/trunk/src/apps/packageinstaller/PackageItem.h haiku/trunk/src/apps/packageinstaller/PackageStatus.cpp haiku/trunk/src/apps/packageinstaller/PackageTextViewer.cpp haiku/trunk/src/apps/packageinstaller/PackageView.cpp haiku/trunk/src/apps/packageinstaller/PackageWindow.cpp haiku/trunk/src/apps/packageinstaller/main.cpp Log: Patch by Jorma Karvonen: Localization of the PackageInstaller. Thanks a lot! Contains small coding style corrections by myself. Closes ticket #5907. Modified: haiku/trunk/src/apps/packageinstaller/Jamfile =================================================================== --- haiku/trunk/src/apps/packageinstaller/Jamfile 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/Jamfile 2010-05-05 08:00:57 UTC (rev 36618) @@ -16,7 +16,7 @@ PackageTextViewer.cpp PackageImageViewer.cpp InstalledPackageInfo.cpp - : be tracker translation z $(TARGET_LIBSUPC++) + : be locale tracker translation z $(TARGET_LIBSUPC++) : PackageInstaller.rdef ; Modified: haiku/trunk/src/apps/packageinstaller/PackageImageViewer.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageImageViewer.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageImageViewer.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -10,23 +10,24 @@ #include "PackageImageViewer.h" #include <BitmapStream.h> +#include <Catalog.h> +#include <Locale.h> #include <Message.h> #include <Screen.h> #include <TranslatorRoster.h> -// Reserved -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageImageViewer" - enum { P_MSG_CLOSE = 'pmic' }; - ImageView::ImageView(BPositionIO *image) - : BView(BRect(0, 0, 1, 1), "image_view", B_FOLLOW_NONE, B_WILL_DRAW), + : + BView(BRect(0, 0, 1, 1), "image_view", B_FOLLOW_NONE, B_WILL_DRAW), fSuccess(true) { if (!image) { @@ -64,12 +65,10 @@ BRect frame = screen.Frame(); BRect image = fImage->Bounds(); - if (image.Width() > (frame.Width() - 100.0f)) { + if (image.Width() > (frame.Width() - 100.0f)) image.right = frame.Width() - 100.0f; - } - if (image.Height() > (frame.Height() - 100.0f)) { + if (image.Height() > (frame.Height() - 100.0f)) image.bottom = frame.Height() - 100.f; - } ResizeTo(image.Width(), image.Height()); } @@ -81,8 +80,8 @@ if (fSuccess) DrawBitmapAsync(fImage, Bounds()); else { - float length = StringWidth(T("Image not loaded correctly")); - DrawString(T("Image not loaded correctly"), + float length = StringWidth(TR("Image not loaded correctly")); + DrawString(TR("Image not loaded correctly"), BPoint((Bounds().Width() - length) / 2.0f, 30.0f)); } } @@ -101,8 +100,9 @@ PackageImageViewer::PackageImageViewer(BPositionIO *image) - : BWindow(BRect(100, 100, 100, 100), "", B_MODAL_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE) + : + BWindow(BRect(100, 100, 100, 100), "", B_MODAL_WINDOW, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE) { fBackground = new ImageView(image); AddChild(fBackground); @@ -168,8 +168,7 @@ delete_sem(fSemaphore); fSemaphore = -1; } - } - else + } else BWindow::MessageReceived(msg); } Modified: haiku/trunk/src/apps/packageinstaller/PackageInfo.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageInfo.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageInfo.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -1,23 +1,24 @@ /* - * Copyright (c) 2007-2009, Haiku, Inc. + * Copyright (c) 2007-2010, Haiku, Inc. * Distributed under the terms of the MIT license. * * Author: * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "PackageInfo.h" #include <Alert.h> #include <ByteOrder.h> +#include <Catalog.h> #include <FindDirectory.h> +#include <Locale.h> #include <Path.h> #include <kernel/OS.h> -// Macro reserved for later localization -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageInfo" #define RETURN_AND_SET_STATUS(err) fStatus = err; \ fprintf(stderr, "err at %s():%d: %x\n", __FUNCTION__, __LINE__, err); \ @@ -48,7 +49,7 @@ : fStatus(B_NO_INIT), fPackageFile(0), - fDescription(T("No package available.")), + fDescription(TR("No package available.")), fProfiles(2), fHasImage(false) { @@ -59,7 +60,7 @@ : fStatus(B_NO_INIT), fPackageFile(new BFile(ref, B_READ_ONLY)), - fDescription(T("No package selected.")), + fDescription(TR("No package selected.")), fProfiles(2), fHasImage(false) { @@ -1027,7 +1028,7 @@ parser_debug("PtcI\n"); break; } else { - fprintf(stderr, "Unknown file tag %s\n", buffer); + fprintf(stderr, TR("Unknown file tag %s\n"), buffer); RETURN_AND_SET_STATUS(B_ERROR); } } @@ -1035,11 +1036,11 @@ if (static_cast<uint64>(actualSize) != fileSize) { // Inform the user of a possible error int32 selection; - BAlert *warning = new BAlert(T("filesize_wrong"), - T("There seems to be a file size mismatch in the package file. " + BAlert *warning = new BAlert("filesize_wrong", + TR("There seems to be a file size mismatch in the package file. " "The package might be corrupted or have been modified after its " - "creation. Do you still wish to continue?"), T("Continue"), - T("Abort"), NULL, + "creation. Do you still wish to continue?"), TR("Continue"), + TR("Abort"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); selection = warning->Go(); Modified: haiku/trunk/src/apps/packageinstaller/PackageInstall.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageInstall.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageInstall.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -6,7 +6,6 @@ * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "PackageInstall.h" #include "InstalledPackageInfo.h" @@ -14,13 +13,17 @@ #include "PackageView.h" #include <Alert.h> +#include <Catalog.h> +#include <Locale.h> #include <stdio.h> -// Macro reserved for later localization -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageInstall" -static int32 install_function(void *data) + +static int32 +install_function(void *data) { // TODO: Inform if already one thread is running PackageInstall *install = static_cast<PackageInstall *>(data); @@ -100,13 +103,14 @@ PackageInstall::_Install() { PackageInfo *info = fParent->GetPackageInfo(); - pkg_profile *type = static_cast<pkg_profile *>(info->GetProfile(fParent->GetCurrentType())); + pkg_profile *type = static_cast<pkg_profile *>(info->GetProfile( + fParent->GetCurrentType())); uint32 n = type->items.CountItems(), m = info->GetScriptCount(); PackageStatus *progress = fParent->GetStatusWindow(); progress->Reset(n + m + 5); - progress->StageStep(1, T("Preparing package")); + progress->StageStep(1, TR("Preparing package")); InstalledPackageInfo packageInfo(info->GetName(), info->GetVersion()); @@ -114,21 +118,21 @@ if (err == B_OK) { // The package is already installed, inform the user BAlert *reinstall = new BAlert("reinstall", - T("The given package seems to be already installed on your system. " - "Would you like to uninstall the existing one and continue the " - "installation?"), T("Continue"), T("Abort")); + TR("The given package seems to be already installed on your " + "system. Would you like to uninstall the existing one and " + "continue the installation?"), TR("Continue"), TR("Abort")); if (reinstall->Go() == 0) { // Uninstall the package err = packageInfo.Uninstall(); if (err != B_OK) { - fprintf(stderr, "Error on uninstall\n"); + fprintf(stderr, TR("Error on uninstall\n")); return P_MSG_I_ERROR; } err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); if (err != B_OK) { - fprintf(stderr, "Error on SetTo\n"); + fprintf(stderr, TR("Error on SetTo\n")); return P_MSG_I_ERROR; } } else { @@ -138,17 +142,17 @@ } else if (err == B_ENTRY_NOT_FOUND) { err = packageInfo.SetTo(info->GetName(), info->GetVersion(), true); if (err != B_OK) { - fprintf(stderr, "Error on SetTo\n"); + fprintf(stderr, TR("Error on SetTo\n")); return P_MSG_I_ERROR; } } else if (progress->Stopped()) { return P_MSG_I_ABORT; } else { - fprintf(stderr, "returning on error\n"); + fprintf(stderr, TR("returning on error\n")); return P_MSG_I_ERROR; } - progress->StageStep(1, T("Installing files and folders")); + progress->StageStep(1, TR("Installing files and folders")); // Install files and directories PackageItem *iter; @@ -181,7 +185,8 @@ if (err == B_FILE_EXISTS) { // Writing to path failed because path already exists - ask the user // what to do and retry the writing process - choice = fParent->ItemExists(*iter, state.destination, fItemExistsPolicy); + choice = fParent->ItemExists(*iter, state.destination, + fItemExistsPolicy); if (choice != P_EXISTS_ABORT) { state.policy = choice; err = iter->DoInstall(installPath, &state); @@ -189,7 +194,7 @@ } if (err != B_OK) { - fprintf(stderr, "Error while writing path\n"); + fprintf(stderr, TR("Error while writing path\n")); return P_MSG_I_ERROR; } @@ -202,7 +207,7 @@ packageInfo.AddItem(state.destination.Path()); } - progress->StageStep(1, T("Running post-installation scripts"), ""); + progress->StageStep(1, TR("Running post-installation scripts"), ""); PackageScript *scr; status_t status; @@ -214,7 +219,7 @@ fCurrentScript = scr; if (scr->DoInstall() != B_OK) { - fprintf(stderr, "Error while running script\n"); + fprintf(stderr, TR("Error while running script\n")); return P_MSG_I_ERROR; } fCurrentScriptLocker.Unlock(); @@ -232,13 +237,13 @@ progress->StageStep(1, NULL, label.String()); } - progress->StageStep(1, T("Finishing installation"), ""); + progress->StageStep(1, TR("Finishing installation"), ""); err = packageInfo.Save(); if (err != B_OK) return P_MSG_I_ERROR; - progress->StageStep(1, T("Done")); + progress->StageStep(1, TR("Done")); // Inform our parent that we finished return P_MSG_I_FINISHED; Modified: haiku/trunk/src/apps/packageinstaller/PackageItem.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageItem.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageItem.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -6,15 +6,16 @@ * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "PackageItem.h" #include <string.h> #include <Alert.h> #include <ByteOrder.h> +#include <Catalog.h> #include <Directory.h> #include <fs_info.h> +#include <Locale.h> #include <NodeInfo.h> #include <OS.h> #include <SymLink.h> @@ -23,8 +24,8 @@ #include "zlib.h" -// Macro reserved for later localization -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageItem" enum { P_CHUNK_SIZE = 256 @@ -561,10 +562,10 @@ } -const char* +const uint32 PackageScript::ItemKind() { - return "script"; + return P_KIND_SCRIPT; } @@ -737,10 +738,10 @@ } -const char* +const uint32 PackageDirectory::ItemKind() { - return "directory"; + return P_KIND_DIRECTORY; } @@ -903,10 +904,10 @@ } -const char* +const uint32 PackageFile::ItemKind() { - return "file"; + return P_KIND_FILE; } @@ -1038,8 +1039,9 @@ } -const char* +const uint32 PackageLink::ItemKind() { - return "symbolic link"; + return P_KIND_SYM_LINK; } + Modified: haiku/trunk/src/apps/packageinstaller/PackageItem.h =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageItem.h 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageItem.h 2010-05-05 08:00:57 UTC (rev 36618) @@ -42,6 +42,12 @@ P_EXISTS_NONE }; +const uint32 P_NO_KIND = 0; +const uint32 P_KIND_SCRIPT = 1; +const uint32 P_KIND_FILE = 2; +const uint32 P_KIND_DIRECTORY = 3; +const uint32 P_KIND_SYM_LINK = 4; + extern status_t inflate_data(uint8* in, uint32 inSize, uint8* out, uint32 outSize); @@ -77,7 +83,7 @@ virtual void SetTo(BFile* parent, const BString& path, uint8 type, uint32 ctime, uint32 mtime, uint64 offset = 0, uint64 size = 0); - virtual const char* ItemKind() = 0; + virtual const uint32 ItemKind() {return P_NO_KIND;}; protected: status_t InitPath(const char* path, BPath* destination); @@ -115,7 +121,7 @@ virtual status_t DoInstall(const char* path = NULL, ItemState *state = NULL); - virtual const char* ItemKind(); + virtual const uint32 ItemKind(); }; @@ -126,7 +132,7 @@ virtual status_t DoInstall(const char* path = NULL, ItemState *state = NULL); - virtual const char* ItemKind(); + virtual const uint32 ItemKind(); thread_id GetThreadId() { return fThreadId; } void SetThreadId(thread_id id) { fThreadId = id; } @@ -151,7 +157,7 @@ virtual status_t DoInstall(const char* path = NULL, ItemState *state = NULL); - virtual const char* ItemKind(); + virtual const uint32 ItemKind(); private: uint64 fOriginalSize; @@ -172,7 +178,7 @@ virtual status_t DoInstall(const char* path = NULL, ItemState *state = NULL); - virtual const char* ItemKind(); + virtual const uint32 ItemKind(); private: uint32 fMode; Modified: haiku/trunk/src/apps/packageinstaller/PackageStatus.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageStatus.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageStatus.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -6,23 +6,23 @@ * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "PackageStatus.h" #include <Autolock.h> - +#include <Catalog.h> #include <GroupLayoutBuilder.h> #include <GroupLayout.h> +#include <Locale.h> #include <stdio.h> #include <string.h> -// Macro reserved for later localization -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageStatus" - StopButton::StopButton() - : BButton(BRect(0, 0, 22, 18), "stop", "", new BMessage(P_MSG_STOP)) + : + BButton(BRect(0, 0, 22, 18), "stop", TR("Stop"), new BMessage(P_MSG_STOP)) { } @@ -33,7 +33,8 @@ BButton::Draw(updateRect); updateRect = Bounds(); - updateRect.InsetBy((updateRect.Width() - 4) / 2, (updateRect.Height() - 4) / 2); + updateRect.InsetBy((updateRect.Width() - 4) / 2, + (updateRect.Height() - 4) / 2); //updateRect.InsetBy(9, 7); SetHighColor(0, 0, 0); FillRect(updateRect); @@ -93,14 +94,15 @@ PackageStatus::PackageStatus(const char *title, const char *label, const char *trailing, BHandler *parent) - : BWindow(BRect(200, 200, 550, 255), title, B_TITLED_WINDOW, - B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0), + : + BWindow(BRect(200, 200, 550, 255), title, B_TITLED_WINDOW, + B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0), fIsStopped(false), fParent(parent) { SetLayout(new BGroupLayout(B_VERTICAL)); - fStatus = new BStatusBar("status_bar", T("Installing package")); + fStatus = new BStatusBar("status_bar", TR("Installing package")); fStatus->SetBarHeight(12); fButton = new StopButton(); Modified: haiku/trunk/src/apps/packageinstaller/PackageTextViewer.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageTextViewer.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageTextViewer.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -1,15 +1,16 @@ /* - * Copyright (c) 2007, Haiku, Inc. + * Copyright (c) 2007-2010, Haiku, Inc. * Distributed under the terms of the MIT license. * * Author: * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "PackageTextViewer.h" #include <Button.h> +#include <Catalog.h> +#include <Locale.h> #include <ScrollView.h> #include <GroupLayout.h> @@ -21,14 +22,15 @@ P_MSG_DECLINE }; -// Reserved -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageTextViewer" PackageTextViewer::PackageTextViewer(const char *text, bool disclaimer) - : BWindow(BRect(125, 125, 675, 475), T("Disclaimer"), B_MODAL_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE), - fValue(0) + : + BWindow(BRect(125, 125, 675, 475), TR("Disclaimer"), B_MODAL_WINDOW, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE), + fValue(0) { _InitView(text, disclaimer); } @@ -90,15 +92,13 @@ delete_sem(fSemaphore); fSemaphore = -1; } - } - else if (msg->what == P_MSG_DECLINE) { + } else if (msg->what == P_MSG_DECLINE) { if (fSemaphore >= B_OK) { fValue = 0; delete_sem(fSemaphore); fSemaphore = -1; } - } - else + } else BWindow::MessageReceived(msg); } @@ -115,8 +115,8 @@ BRect bounds; BRect rect = Bounds(); if (disclaimer) { - BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", T("Accept"), - new BMessage(P_MSG_ACCEPT)); + BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", + TR("Accept"), new BMessage(P_MSG_ACCEPT)); button->ResizeToPreferred(); bounds = button->Bounds(); @@ -128,7 +128,7 @@ button->MakeDefault(true); fBackground->AddChild(button); - button = new BButton(BRect(0, 0, 1, 1), "decline", T("Decline"), + button = new BButton(BRect(0, 0, 1, 1), "decline", TR("Decline"), new BMessage(P_MSG_DECLINE)); button->ResizeToPreferred(); @@ -136,10 +136,9 @@ rect.left -= bounds.right + 7.0f; button->MoveTo(rect.LeftTop()); fBackground->AddChild(button); - } - else { - BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", T("Continue"), - new BMessage(P_MSG_ACCEPT)); + } else { + BButton *button = new BButton(BRect(0, 0, 1, 1), "accept", + TR("Continue"), new BMessage(P_MSG_ACCEPT)); button->ResizeToPreferred(); bounds = button->Bounds(); @@ -157,13 +156,13 @@ bounds.right -= B_V_SCROLL_BAR_WIDTH; fText = new BTextView(bounds, "text_view", BRect(0, 0, bounds.Width(), - bounds.Height()), B_FOLLOW_NONE, B_WILL_DRAW); + bounds.Height()), B_FOLLOW_NONE, B_WILL_DRAW); fText->MakeEditable(false); fText->MakeSelectable(true); fText->SetText(text); 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); @@ -184,10 +183,10 @@ B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); if (disclaimer) { - BButton *accept = new BButton("accept", T("Accept"), + BButton *accept = new BButton("accept", TR("Accept"), new BMessage(P_MSG_ACCEPT)); - BButton *decline = new BButton("decline", T("Decline"), + BButton *decline = new BButton("decline", TR("Decline"), new BMessage(P_MSG_DECLINE)); fBackground = BGroupLayoutBuilder(B_VERTICAL) @@ -199,7 +198,7 @@ .End(); } else { - BButton *button = new BButton("accept", T("Continue"), + BButton *button = new BButton("accept", TR("Continue"), new BMessage(P_MSG_ACCEPT)); fBackground = BGroupLayoutBuilder(B_VERTICAL) Modified: haiku/trunk/src/apps/packageinstaller/PackageView.cpp =================================================================== --- haiku/trunk/src/apps/packageinstaller/PackageView.cpp 2010-05-04 21:56:53 UTC (rev 36617) +++ haiku/trunk/src/apps/packageinstaller/PackageView.cpp 2010-05-05 08:00:57 UTC (rev 36618) @@ -1,12 +1,11 @@ /* - * Copyright 2007-2009, Haiku, Inc. + * Copyright 2007-2010, Haiku, Inc. * Distributed under the terms of the MIT license. * * Author: * Łukasz 'Sil2100' Zemczak <sil2100@xxxxxxxxxxxxx> */ - #include "InstalledPackageInfo.h" #include "PackageImageViewer.h" #include "PackageTextViewer.h" @@ -14,8 +13,10 @@ #include <Alert.h> #include <Button.h> +#include <Catalog.h> #include <Directory.h> #include <FindDirectory.h> +#include <Locale.h> #include <MenuItem.h> #include <Path.h> #include <PopUpMenu.h> @@ -32,25 +33,27 @@ #include <fs_info.h> #include <stdio.h> // For debugging -// Macro reserved for later localization -#define T(x) x +#undef TR_CONTEXT +#define TR_CONTEXT "PackageView" + const float kMaxDescHeight = 125.0f; const uint32 kSeparatorIndex = 3; - static void convert_size(uint64 size, char *buffer, uint32 n) { if (size < 1024) - snprintf(buffer, n, "%llu bytes", size); + snprintf(buffer, n, TR("%llu bytes"), size); else if (size < 1024 * 1024) - snprintf(buffer, n, "%.1f KiB", size / 1024.0f); + snprintf(buffer, n, TR("%.1f KiB"), size / 1024.0f); else if (size < 1024 * 1024 * 1024) - snprintf(buffer, n, "%.1f MiB", size / (1024.0f*1024.0f)); - else - snprintf(buffer, n, "%.1f GiB", size / (1024.0f*1024.0f*1024.0f)); + snprintf(buffer, n, TR("%.1f MiB"), size / (1024.0f * 1024.0f)); + else { + snprintf(buffer, n, TR("%.1f GiB"), size + / (1024.0f * 1024.0f * 1024.0f)); + } } @@ -59,10 +62,10 @@ PackageView::PackageView(BRect frame, const entry_ref *ref) - : BView(frame, "package_view", B_FOLLOW_NONE, 0), - //BView("package_view", B_WILL_DRAW, new BGroupLayout(B_HORIZONTAL)), - fOpenPanel(new BFilePanel(B_OPEN_PANEL, NULL, NULL, - B_DIRECTORY_NODE, false)), + : + BView(frame, "package_view", B_FOLLOW_NONE, 0), + fOpenPanel(new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_DIRECTORY_NODE, + false)), fInfo(ref), fInstallProcess(this) { @@ -88,11 +91,11 @@ { status_t ret = fInfo.InitCheck(); if (ret != B_OK && ret != B_NO_INIT) { - BAlert *warning = new BAlert(T("parsing_failed"), - T("The package file is not readable.\nOne of the possible " - "reasons for this might be that the requested file is not a valid " - "BeOS .pkg package."), T("OK"), NULL, NULL, B_WIDTH_AS_USUAL, - B_WARNING_ALERT); + BAlert *warning = new BAlert("parsing_failed", + TR("The package file is not readable.\nOne of the possible " + "reasons for this might be that the requested file is not a " + "valid BeOS .pkg package."), TR("OK"), NULL, NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT); warning->Go(); Window()->PostMessage(B_QUIT_REQUESTED); @@ -104,10 +107,10 @@ BString title; BString name = fInfo.GetName(); if (name.CountChars() == 0) { - title = T("Package installer"); + title = TR("Package installer"); } else { - title = T("Install "); + title = TR("Install "); title += name; } parent->SetTitle(title.String()); @@ -122,8 +125,8 @@ // attaching the view to the window _GroupChanged(0); - fStatusWindow = new PackageStatus(T("Installation progress"), NULL, NULL, - this); + fStatusWindow = new PackageStatus(TR("Installation progress"), NULL, + NULL, this); // Show the splash screen, if present BMallocIO *image = fInfo.GetSplashScreen(); @@ -135,9 +138,11 @@ // Show the disclaimer/info text popup, if present BString disclaimer = fInfo.GetDisclaimer(); if (disclaimer.Length() != 0) { - PackageTextViewer *text = new PackageTextViewer(disclaimer.String()); + PackageTextViewer *text = new PackageTextViewer( + disclaimer.String()); int32 selection = text->Go(); - // The user didn't accept our disclaimer, this means we cannot continue. + // The user didn't accept our disclaimer, this means we cannot + // continue. if (selection == 0) { BWindow *parent = Window(); if (parent && parent->Lock()) @@ -184,8 +189,8 @@ case P_MSG_I_FINISHED: { BAlert *notify = new BAlert("installation_success", - T("The package you requested has been successfully installed " - "on your system."), T("OK")); + TR("The package you requested has been successfully installed " + "on your system."), TR("OK")); notify->Go(); fStatusWindow->Hide(); @@ -202,7 +207,8 @@ case P_MSG_I_ABORT: { BAlert *notify = new BAlert("installation_aborted", - T("The installation of the package has been aborted."), T("OK")); + TR("The installation of the package has been aborted."), + TR("OK")); notify->Go(); fStatusWindow->Hide(); fInstall->SetEnabled(true); @@ -213,12 +219,13 @@ } case P_MSG_I_ERROR: { - BAlert *notify = new BAlert("installation_failed", // TODO: Review this - T("The requested package failed to install on your system. This " - "might be a problem with the target package file. Please consult " - "this issue with the package distributor."), T("OK"), NULL, - NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - fprintf(stderr, "Error while installing the package\n"); + // TODO: Review this + BAlert *notify = new BAlert("installation_failed", + TR("The requested package failed to install on your system. " + "This might be a problem with the target package file. Please " + "consult this issue with the package distributor."), + TR("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + fprintf(stderr, TR("Error while installing the package\n")); notify->Go(); fStatusWindow->Hide(); fInstall->SetEnabled(true); @@ -253,10 +260,12 @@ break; BString name = path.Path(); - char sizeString[32]; + char sizeString[48]; - convert_size(volume.FreeBytes(), sizeString, 32); - name << " (" << sizeString << " free)"; + convert_size(volume.FreeBytes(), sizeString, 48); + char buffer[512]; + snprintf(buffer, sizeof(buffer), "(%s free)", sizeString); + name << buffer; item->SetLabel(name.String()); fCurrentPath.SetTo(path.Path()); @@ -300,15 +309,42 @@ case P_EXISTS_ASK: case P_EXISTS_NONE: { - BString alertString = T("The "); + const char* formatString; + switch (item.ItemKind()){ + case P_KIND_SCRIPT: + formatString = TR("The script named \'%s\' already exits " + "in the given path.\nReplace the script with the one " + "from this package or skip it?"); + break; + case P_KIND_FILE: + formatString = TR("The file named \'%s\' already exits " + "in the given path.\nReplace the file with the one " + "from this package or skip it?"); + break; + case P_KIND_DIRECTORY: + formatString = TR("The directory named \'%s\' already " + "exits in the given path.\nReplace the directory with " + "one from this package or skip it?"); + break; + case P_KIND_SYM_LINK: + formatString = TR("The symbolic link named \'%s\' already " + "exists in the give path.\nReplace the link with the " + "one from this package or skip it?"); + break; + default: + formatString = TR("The item named \'%s\' already exits " + "in the given path.\nReplace the item with the one " + "from this package or skip it?"); + break; + } + char buffer[512]; + snprintf(buffer, sizeof(buffer), formatString, path.Leaf()); + + BString alertString = buffer; + + BAlert *alert = new BAlert("file_exists", alertString.String(), + TR("Replace"), TR("Skip"), TR("Abort")); - alertString << item.ItemKind() << T(" named \'") << path.Leaf() << "\' "; - alertString << T("already exists in the given path.\nReplace the file with " - "the one from this package or skip it?"); - - BAlert *alert = new BAlert(T("file_exists"), alertString.String(), - T("Replace"), T("Skip"), T("Abort")); - choice = alert->Go(); switch (choice) { case 0: @@ -323,13 +359,14 @@ if (policy == P_EXISTS_NONE) { // TODO: Maybe add 'No, but ask again' type of choice as well? - alertString = T("Do you want to remember this decision for the rest of " - "this installation?\nAll existing files will be "); + alertString = TR("Do you want to remember this decision for " + "the rest of this installation?\n"); alertString << ((choice == P_EXISTS_OVERWRITE) - ? T("replaced?") : T("skipped?")); + ? TR("All existing files will be replaced?") + : TR("All existing files will be skipped?")); - alert = new BAlert(T("policy_decision"), alertString.String(), - T("Yes"), T("No")); + alert = new BAlert("policy_decision", alertString.String(), + TR("Replace all"), TR("Ask again")); int32 decision = alert->Go(); if (decision == 0) @@ -361,7 +398,7 @@ fInstallTypes = new BPopUpMenu("none"); BMenuField *installType = new BMenuField("install_type", - T("Installation type:"), fInstallTypes, 0); + TR("Installation type:"), fInstallTypes, 0); installType->SetAlignment(B_ALIGN_RIGHT); installType->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_MIDDLE)); @@ -370,10 +407,10 @@ fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fInstallDesc->MakeEditable(false); fInstallDesc->MakeSelectable(false); - fInstallDesc->SetText(T("No installation type selected")); + fInstallDesc->SetText(TR("No installation type selected")); fInstallDesc->TextHeight(0, fInstallDesc->TextLength()); - fInstall = new BButton("install_button", T("Install"), + fInstall = new BButton("install_button", TR("Install"), new BMessage(P_MSG_INSTALL)); BView *installField = BGroupLayoutBuilder(B_VERTICAL, 5.0f) @@ -416,9 +453,11 @@ float length = description->TextHeight(0, description->TextLength()) + 5; if (length > kMaxDescHeight) { // Set a scroller for the description. - description->ResizeTo(rect.Width() - B_V_SCROLL_BAR_WIDTH, kMaxDescHeight); + description->ResizeTo(rect.Width() - B_V_SCROLL_BAR_WIDTH, + kMaxDescHeight); BScrollView *scroller = new BScrollView("desciption_view", description, - B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_NO_BORDER); + B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, false, true, + B_NO_BORDER); AddChild(scroller); rect = scroller->Frame(); @@ -435,8 +474,8 @@ fInstallTypes = new BPopUpMenu("none"); - BMenuField *installType = new BMenuField(BRect(2, 2, 100, 50), "install_type", - T("Installation type:"), fInstallTypes, false); + BMenuField *installType = new BMenuField(BRect(2, 2, 100, 50), + "install_type", TR("Installation type:"), fInstallTypes, false); installType->SetDivider(installType->StringWidth(installType->Label()) + 8); installType->SetAlignment(B_ALIGN_RIGHT); installType->ResizeToPreferred(); @@ -450,12 +489,12 @@ B_WILL_DRAW); fInstallDesc->MakeEditable(false); fInstallDesc->MakeSelectable(false); - fInstallDesc->SetText(T("No installation type selected")); + fInstallDesc->SetText(TR("No installation type selected")); fInstallDesc->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fInstallDesc->ResizeTo(rect.Width() - B_V_SCROLL_BAR_WIDTH, 60); BScrollView *scroller = new BScrollView("desciption_view", fInstallDesc, - B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_NO_BORDER); + B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_NO_BORDER); installBox->ResizeTo(installBox->Bounds().Width(), scroller->Frame().bottom + 10); @@ -469,7 +508,7 @@ rect = installBox->Frame(); [... truncated: 256 lines follow ...]