Author: stippi Date: 2010-01-21 21:02:57 +0100 (Thu, 21 Jan 2010) New Revision: 35229 Changeset: http://dev.haiku-os.org/changeset/35229/haiku Modified: haiku/trunk/src/apps/drivesetup/CreateParamsPanel.cpp haiku/trunk/src/apps/drivesetup/DiskView.cpp haiku/trunk/src/apps/drivesetup/DriveSetup.cpp haiku/trunk/src/apps/drivesetup/DriveSetup.h haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp haiku/trunk/src/apps/drivesetup/Jamfile haiku/trunk/src/apps/drivesetup/MainWindow.cpp haiku/trunk/src/apps/drivesetup/PartitionList.cpp haiku/trunk/src/apps/drivesetup/Support.cpp haiku/trunk/src/apps/drivesetup/Support.h Log: Localized DriveSetup. Modified: haiku/trunk/src/apps/drivesetup/CreateParamsPanel.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/CreateParamsPanel.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/CreateParamsPanel.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -12,6 +12,7 @@ #include "Support.h" #include <Button.h> +#include <Catalog.h> #include <ControlLook.h> #include <DiskDeviceTypes.h> #include <GridLayoutBuilder.h> @@ -27,6 +28,9 @@ #include <String.h> +#define TR_CONTEXT "CreateParamsPanel" + + class CreateParamsPanel::EscapeFilter : public BMessageFilter { public: EscapeFilter(CreateParamsPanel* target) @@ -216,11 +220,11 @@ off_t size) { // Setup the controls - fSizeSlider = new SizeSlider("Slider", "Partition size", NULL, offset, + fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); - fNameTextControl = new BTextControl("Name Control", "Partition name:", + fNameTextControl = new BTextControl("Name Control", TR("Partition name:"), "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); @@ -229,7 +233,8 @@ int32 cookie = 0; BString supportedType; - while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { + while (parent->GetNextSupportedChildType(&cookie, &supportedType) + == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); @@ -239,7 +244,8 @@ item->SetMarked(true); } - fTypeMenuField = new BMenuField("Partition type:", fTypePopUpMenu, NULL); + fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu, + NULL); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); @@ -261,10 +267,10 @@ if (fEditor) AddChild(fEditor->View()); - BButton* okButton = new BButton("Create", new BMessage(MSG_OK)); + BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK)); AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() - .Add(new BButton("Cancel", new BMessage(MSG_CANCEL))) + .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) ); SetDefaultButton(okButton); Modified: haiku/trunk/src/apps/drivesetup/DiskView.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DiskView.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/DiskView.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -1,35 +1,40 @@ /* - * Copyright 2007-2009 Haiku Inc. All rights reserved. - * Distributed under the terms of the MIT license. - * - * Authors: - * Stephan Aßmus <superstippi@xxxxxx> + * Copyright 2007-2010 Stephan Aßmus <superstippi@xxxxxx>. + * All rights reserved. Distributed under the terms of the MIT license. */ #include "DiskView.h" -#include "MainWindow.h" +#include <stdio.h> + #include <DiskDeviceVisitor.h> +#include <Catalog.h> #include <GroupLayout.h> #include <HashMap.h> #include <LayoutItem.h> #include <PartitioningInfo.h> #include <String.h> +#include "MainWindow.h" + + +#define TR_CONTEXT "DiskView" + using BPrivate::HashMap; using BPrivate::HashKey32; - static const pattern kStripes = { { 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 } }; static const float kLayoutInset = 6; + class PartitionView : public BView { public: PartitionView(const char* name, float weight, off_t offset, int32 level, partition_id id) - : BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE), + : + BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE), fID(id), fWeight(weight), fOffset(offset), @@ -195,7 +200,7 @@ virtual bool Visit(BDiskDevice* device) { - PartitionView* view = new PartitionView("Device", 1.0, + PartitionView* view = new PartitionView(TR("Device"), 1.0, device->Offset(), 0, device->ID()); fViewMap.Put(device->ID(), view); fView->GetLayout()->AddView(view); @@ -220,8 +225,11 @@ if (name.Length() == 0) { if (partition->CountChildren() > 0) name << partition->Type(); - else - name << "Partition " << partition->ID(); + else { + char buffer[64]; + snprintf(buffer, 64, TR("Partition %ld"), partition->ID()); + name << buffer; + } } partition_id id = partition->ID(); PartitionView* view = new PartitionView(name.String(), scale, offset, @@ -279,7 +287,7 @@ double scale = (double)size / parentSize; partition_id id = fSpaceIDMap.SpaceIDFor(partition->ID(), offset); - PartitionView* view = new PartitionView("<empty>", scale, + PartitionView* view = new PartitionView(TR("<empty>"), scale, offset, parentView->Level() + 1, id); fViewMap.Put(id, view); @@ -320,7 +328,8 @@ DiskView::DiskView(const BRect& frame, uint32 resizeMode, SpaceIDMap& spaceIDMap) - : Inherited(frame, "diskview", resizeMode, + : + Inherited(frame, "diskview", resizeMode, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE), fDiskCount(0), fDisk(NULL), @@ -390,9 +399,9 @@ const char* helpfulMessage; if (fDiskCount == 0) - helpfulMessage = "No disk devices have been recognized."; + helpfulMessage = TR("No disk devices have been recognized."); else - helpfulMessage = "Select a partition from the list below."; + helpfulMessage = TR("Select a partition from the list below."); float width = StringWidth(helpfulMessage); font_height fh; Modified: haiku/trunk/src/apps/drivesetup/DriveSetup.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/DriveSetup.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/DriveSetup.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -16,6 +16,7 @@ #include <File.h> #include <FindDirectory.h> +#include <Locale.h> #include <Path.h> @@ -35,6 +36,8 @@ void DriveSetup::ReadyToRun() { + be_locale->GetAppCatalog(&fCatalog); + fWindow = new MainWindow(BRect(50, 50, 600, 450)); if (_RestoreSettings() != B_OK) fWindow->ApplyDefaultSettings(); Modified: haiku/trunk/src/apps/drivesetup/DriveSetup.h =================================================================== --- haiku/trunk/src/apps/drivesetup/DriveSetup.h 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/DriveSetup.h 2010-01-21 20:02:57 UTC (rev 35229) @@ -7,6 +7,7 @@ #include <Application.h> +#include <Catalog.h> #include <Message.h> @@ -31,6 +32,7 @@ MainWindow* fWindow; BMessage fSettings; + BCatalog fCatalog; }; Modified: haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/InitParamsPanel.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -13,6 +13,7 @@ #include <stdio.h> #include <Button.h> +#include <Catalog.h> #include <ControlLook.h> #include <GroupLayout.h> #include <GroupLayoutBuilder.h> @@ -21,10 +22,14 @@ #include <String.h> +#define TR_CONTEXT "InitParamsPanel" + + class InitParamsPanel::EscapeFilter : public BMessageFilter { public: EscapeFilter(InitParamsPanel* target) - : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), + : + BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE), fPanel(target) { } @@ -70,8 +75,9 @@ InitParamsPanel::InitParamsPanel(BWindow* window, const BString& diskSystem, - BPartition* partition) - : BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK, + BPartition* partition) + : + BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS), fEscapeFilter(new EscapeFilter(this)), @@ -81,7 +87,7 @@ { AddCommonFilter(fEscapeFilter); - BButton* okButton = new BButton("Initialize", new BMessage(MSG_OK)); + BButton* okButton = new BButton(TR("Initialize"), new BMessage(MSG_OK)); partition->GetInitializationParameterEditor(diskSystem.String(), &fEditor); @@ -92,7 +98,7 @@ .Add(fEditor->View()) .AddGroup(B_HORIZONTAL, spacing) .AddGlue() - .Add(new BButton("Cancel", new BMessage(MSG_CANCEL))) + .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) .End() .SetInsets(spacing, spacing, spacing, spacing) Modified: haiku/trunk/src/apps/drivesetup/Jamfile =================================================================== --- haiku/trunk/src/apps/drivesetup/Jamfile 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/Jamfile 2010-01-21 20:02:57 UTC (rev 35229) @@ -13,6 +13,20 @@ PartitionList.cpp Support.cpp - : be libcolumnlistview.a libshared.a $(TARGET_LIBSUPC++) + : be liblocale.so libcolumnlistview.a libshared.a $(TARGET_LIBSUPC++) : DriveSetup.rdef ; + +DoCatalogs DriveSetup : + x-vnd.Haiku-DriveSetup + : + CreateParamsPanel.cpp + DiskView.cpp + InitParamsPanel.cpp + MainWindow.cpp + PartitionList.cpp + Support.cpp + : en.catalog + : de.catkeys +; + Modified: haiku/trunk/src/apps/drivesetup/MainWindow.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/MainWindow.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 Haiku Inc. All rights reserved. + * Copyright 2002-2010 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: @@ -10,18 +10,13 @@ */ #include "MainWindow.h" -#include "DiskView.h" -#include "InitParamsPanel.h" -#include "CreateParamsPanel.h" -#include "PartitionList.h" -#include "Support.h" -#include "tracker_private.h" #include <stdio.h> #include <string.h> #include <Alert.h> #include <Application.h> +#include <Catalog.h> #include <ColumnListView.h> #include <ColumnTypes.h> #include <Debug.h> @@ -40,6 +35,17 @@ #include <Volume.h> #include <VolumeRoster.h> +#include "CreateParamsPanel.h" +#include "DiskView.h" +#include "InitParamsPanel.h" +#include "PartitionList.h" +#include "Support.h" +#include "tracker_private.h" + + +#define TR_CONTEXT "MainWindow" + + class ListPopulatorVisitor : public BDiskDeviceVisitor { public: ListPopulatorVisitor(PartitionListView* list, int32& diskCount, @@ -161,24 +167,24 @@ BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu"); // create all the menu items - fFormatMI = new BMenuItem("Format (not implemented)", + fFormatMI = new BMenuItem(TR("Format (not implemented)"), new BMessage(MSG_FORMAT)); - fEjectMI = new BMenuItem("Eject", new BMessage(MSG_EJECT), 'E'); - fSurfaceTestMI = new BMenuItem("Surface test (not implemented)", + fEjectMI = new BMenuItem(TR("Eject"), new BMessage(MSG_EJECT), 'E'); + fSurfaceTestMI = new BMenuItem(TR("Surface test (not implemented)"), new BMessage(MSG_SURFACE_TEST)); - fRescanMI = new BMenuItem("Rescan", new BMessage(MSG_RESCAN)); + fRescanMI = new BMenuItem(TR("Rescan"), new BMessage(MSG_RESCAN)); - fCreateMI = new BMenuItem("Create" B_UTF8_ELLIPSIS, + fCreateMI = new BMenuItem(TR("Create" B_UTF8_ELLIPSIS), new BMessage(MSG_CREATE), 'C'); - fDeleteMI = new BMenuItem("Delete", new BMessage(MSG_DELETE), 'D'); + fDeleteMI = new BMenuItem(TR("Delete"), new BMessage(MSG_DELETE), 'D'); - fMountMI = new BMenuItem("Mount", new BMessage(MSG_MOUNT), 'M'); - fUnmountMI = new BMenuItem("Unmount", new BMessage(MSG_UNMOUNT), 'U'); - fMountAllMI = new BMenuItem("Mount all", + fMountMI = new BMenuItem(TR("Mount"), new BMessage(MSG_MOUNT), 'M'); + fUnmountMI = new BMenuItem(TR("Unmount"), new BMessage(MSG_UNMOUNT), 'U'); + fMountAllMI = new BMenuItem(TR("Mount all"), new BMessage(MSG_MOUNT_ALL), 'M', B_SHIFT_KEY); // Disk menu - fDiskMenu = new BMenu("Disk"); + fDiskMenu = new BMenu(TR("Disk")); fDiskMenu->AddItem(fFormatMI); fDiskMenu->AddItem(fEjectMI); fDiskMenu->AddItem(fSurfaceTestMI); @@ -189,10 +195,10 @@ menuBar->AddItem(fDiskMenu); // Parition menu - fPartitionMenu = new BMenu("Partition"); + fPartitionMenu = new BMenu(TR("Partition")); fPartitionMenu->AddItem(fCreateMI); - fInitMenu = new BMenu("Initialize"); + fInitMenu = new BMenu(TR("Initialize")); fPartitionMenu->AddItem(fInitMenu); fPartitionMenu->AddItem(fDeleteMI); @@ -468,8 +474,8 @@ MainWindow::_SetToDiskAndPartition(partition_id disk, partition_id partition, partition_id parent) { -printf("MainWindow::_SetToDiskAndPartition(disk: %ld, partition: %ld, " - "parent: %ld)\n", disk, partition, parent); +//printf("MainWindow::_SetToDiskAndPartition(disk: %ld, partition: %ld, " +// "parent: %ld)\n", disk, partition, parent); BDiskDevice* oldDisk = NULL; if (!fCurrentDisk || fCurrentDisk->ID() != disk) { @@ -611,18 +617,20 @@ if (partition && _message.FindFirst("%s") >= 0) { BString name; name << "\"" << partition->ContentName() << "\""; - sprintf(message, _message.String(), name.String()); + snprintf(message, sizeof(message), _message.String(), name.String()); } else { _message.ReplaceAll("%s", ""); - sprintf(message, _message.String()); + snprintf(message, sizeof(message), _message.String()); } if (error < B_OK) { BString helper = message; - sprintf(message, "%s\n\nError: %s", helper.String(), strerror(error)); + const char* errorString = TR_CMT("Error: ", "in any error alert"); + snprintf(message, sizeof(message), "%s\n\n%s%s", helper.String(), + errorString, strerror(error)); } - BAlert* alert = new BAlert("error", message, "OK", NULL, NULL, + BAlert* alert = new BAlert("error", message, TR("OK"), NULL, NULL, B_WIDTH_FROM_WIDEST, error < B_OK ? B_STOP_ALERT : B_INFO_ALERT); alert->Go(NULL); } @@ -635,28 +643,29 @@ MainWindow::_Mount(BDiskDevice* disk, partition_id selectedPartition) { if (!disk || selectedPartition < 0) { - _DisplayPartitionError("You need to select a partition " - "entry from the list."); + _DisplayPartitionError(TR("You need to select a partition " + "entry from the list.")); return; } BPartition* partition = disk->FindDescendant(selectedPartition); if (!partition) { - _DisplayPartitionError("Unable to find the selected partition by ID."); + _DisplayPartitionError(TR("Unable to find the selected partition " + "by ID.")); return; } if (!partition->IsMounted()) { status_t ret = partition->Mount(); if (ret < B_OK) { - _DisplayPartitionError("Could not mount partition %s.", + _DisplayPartitionError(TR("Could not mount partition %s."), partition, ret); } else { // successful mount, adapt to the changes _ScanDrives(); } } else { - _DisplayPartitionError("The partition %s is already mounted.", + _DisplayPartitionError(TR("The partition %s is already mounted."), partition); } } @@ -666,14 +675,15 @@ MainWindow::_Unmount(BDiskDevice* disk, partition_id selectedPartition) { if (!disk || selectedPartition < 0) { - _DisplayPartitionError("You need to select a partition " - "entry from the list."); + _DisplayPartitionError(TR("You need to select a partition " + "entry from the list.")); return; } BPartition* partition = disk->FindDescendant(selectedPartition); if (!partition) { - _DisplayPartitionError("Unable to find the selected partition by ID."); + _DisplayPartitionError(TR("Unable to find the selected partition " + "by ID.")); return; } @@ -682,7 +692,7 @@ partition->GetMountPoint(&path); status_t ret = partition->Unmount(); if (ret < B_OK) { - _DisplayPartitionError("Could not unmount partition %s.", + _DisplayPartitionError(TR("Could not unmount partition %s."), partition, ret); } else { if (dev_for_path(path.Path()) == dev_for_path("/")) @@ -691,7 +701,7 @@ _ScanDrives(); } } else { - _DisplayPartitionError("The partition %s is already unmounted.", + _DisplayPartitionError(TR("The partition %s is already unmounted."), partition); } } @@ -745,35 +755,45 @@ const BString& diskSystemName) { if (!disk || selectedPartition < 0) { - _DisplayPartitionError("You need to select a partition " - "entry from the list."); + _DisplayPartitionError(TR("You need to select a partition " + "entry from the list.")); return; } if (disk->IsReadOnly()) { - _DisplayPartitionError("The selected disk is read-only."); + _DisplayPartitionError(TR("The selected disk is read-only.")); return; } BPartition* partition = disk->FindDescendant(selectedPartition); if (!partition) { - _DisplayPartitionError("Unable to find the selected partition by ID."); + _DisplayPartitionError(TR("Unable to find the selected partition " + "by ID.")); return; } if (partition->IsMounted()) { - _DisplayPartitionError("The partition %s is currently mounted."); + _DisplayPartitionError(TR("The partition %s is currently mounted.")); // TODO: option to unmount and continue on success to unmount return; } - BString message("Are you sure you want to initialize the partition "); - message << "\"" << partition->ContentName(); - message << "\"? After entering the initialization parameters, "; - message << "you can abort this operation right before writing "; - message << "changes back to the disk."; - BAlert* alert = new BAlert("first notice", message.String(), - "Continue", "Cancel", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); + char message[512]; + if (partition->ContentName() && strlen(partition->ContentName()) > 0) { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "initialize the partition \"%s\"? After entering the " + "initialization parameters, you can abort this operation " + "right before writing changes back to the disk."), + partition->ContentName()); + } else { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "initialize the selected partition? After entering the " + "initialization parameters, you can abort this operation " + "right before writing changes back to the disk.")); + } + BAlert* alert = new BAlert("first notice", message, + TR("Continue"), TR("Cancel"), NULL, B_WIDTH_FROM_WIDEST, + B_WARNING_ALERT); int32 choice = alert->Go(); if (choice == 1) @@ -792,8 +812,8 @@ } if (!found) { - BString message("Disk system \""); - message << diskSystemName << "\" not found!"; + snprintf(message, sizeof(message), TR("Disk system \"%s\"\" not " + "found!")); _DisplayPartitionError(message); return; } @@ -804,16 +824,16 @@ if (diskSystemName != "Be File System" && diskSystemName != "Intel Partition Map" && diskSystemName != "Intel Extended Partition") { - _DisplayPartitionError("Don't know how to gather initialization " - "parameters for this file system."); + _DisplayPartitionError(TR("Don't know how to gather initialization " + "parameters for this disk system.")); return; } ModificationPreparer modificationPreparer(disk); status_t ret = modificationPreparer.ModificationStatus(); if (ret != B_OK) { - _DisplayPartitionError("There was an error preparing the " - "disk for modifications.", NULL, ret); + _DisplayPartitionError(TR("There was an error preparing the " + "disk for modifications."), NULL, ret); return; } @@ -835,8 +855,8 @@ ret = partition->ValidateInitialize(diskSystem.PrettyName(), supportsName ? &validatedName : NULL, parameters.String()); if (ret != B_OK) { - _DisplayPartitionError("Validation of the given initialization " - "parameters failed.", partition, ret); + _DisplayPartitionError(TR("Validation of the given initialization " + "parameters failed."), partition, ret); return; } @@ -845,8 +865,8 @@ ret = partition->Initialize(diskSystem.PrettyName(), supportsName ? validatedName.String() : NULL, parameters.String()); if (ret != B_OK) { - _DisplayPartitionError("Initialization of the partition %s " - "failed. (Nothing has been written to disk.)", partition, ret); + _DisplayPartitionError(TR("Initialization of the partition %s " + "failed. (Nothing has been written to disk.)"), partition, ret); return; } @@ -854,17 +874,34 @@ // to disk // Warn the user one more time... - message = "Are you sure you want to write the changes back to " - "disk now?\n\n"; - if (partition->IsDevice()) - message << "All data on the disk"; - else - message << "All data on the partition"; - if (previousName.Length() > 0) - message << " \"" << previousName << "\""; - message << " will be irretrievably lost if you do so!"; - alert = new BAlert("final notice", message.String(), - "Write changes", "Cancel", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); + if (previousName.Length() > 0) { + if (partition->IsDevice()) { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "write the changes back to disk now?\n\n" + "All data on the disk %s will be irretrievably lost if you " + "do so!"), previousName.String()); + } else { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "write the changes back to disk now?\n\n" + "All data on the partition %s will be irretrievably lost if you " + "do so!"), previousName.String()); + } + } else { + if (partition->IsDevice()) { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "write the changes back to disk now?\n\n" + "All data on the selected disk will be irretrievably lost if " + "you do so!")); + } else { + snprintf(message, sizeof(message), TR("Are you sure you want to " + "write the changes back to disk now?\n\n" + "All data on the selected partition will be irretrievably lost " + "if you do so!")); + } + } + alert = new BAlert("final notice", message, + TR("Write changes"), TR("Cancel"), NULL, B_WIDTH_FROM_WIDEST, + B_WARNING_ALERT); choice = alert->Go(); if (choice == 1) @@ -878,11 +915,11 @@ partition = disk->FindDescendant(selectedPartition); if (ret == B_OK) { - _DisplayPartitionError("The partition %s has been successfully " - "initialized.\n", partition); + _DisplayPartitionError(TR("The partition %s has been successfully " + "initialized.\n"), partition); } else { - _DisplayPartitionError("Failed to initialize the partition " - "%s!\n", partition, ret); + _DisplayPartitionError(TR("Failed to initialize the partition " + "%s!\n"), partition, ret); } _ScanDrives(); @@ -893,42 +930,42 @@ MainWindow::_Create(BDiskDevice* disk, partition_id selectedPartition) { if (!disk || selectedPartition > -2) { - _DisplayPartitionError("The currently selected partition is not" - " empty"); + _DisplayPartitionError(TR("The currently selected partition is not " + "empty.")); return; } if (disk->IsReadOnly()) { - _DisplayPartitionError("The selected disk is read-only."); + _DisplayPartitionError(TR("The selected disk is read-only.")); return; } PartitionListRow* currentSelection = dynamic_cast<PartitionListRow*>( fListView->CurrentSelection()); if (!currentSelection) { - _DisplayPartitionError("There was an error acquiring the partition " - "row"); + _DisplayPartitionError(TR("There was an error acquiring the partition " + "row.")); return; } BPartition* parent = disk->FindDescendant(currentSelection->ParentID()); if (!parent) { - _DisplayPartitionError("The currently selected partition does not " - "have a parent partition"); + _DisplayPartitionError(TR("The currently selected partition does not " + "have a parent partition.")); return; } if (!parent->ContainsPartitioningSystem()) { - _DisplayPartitionError("The selected partition does not contain " - "a partitioning system.\n"); + _DisplayPartitionError(TR("The selected partition does not contain " + "a partitioning system.")); return; } ModificationPreparer modificationPreparer(disk); status_t ret = modificationPreparer.ModificationStatus(); if (ret != B_OK) { - _DisplayPartitionError("There was an error preparing the " - "disk for modifications.", NULL, ret); + _DisplayPartitionError(TR("There was an error preparing the " + "disk for modifications."), NULL, ret); return; } @@ -936,14 +973,15 @@ BPartitioningInfo partitioningInfo; status_t error = parent->GetPartitioningInfo(&partitioningInfo); if (error != B_OK) { - _DisplayPartitionError("Could not aquire partitioning information.\n"); + _DisplayPartitionError(TR("Could not aquire partitioning " + "information.")); return; } int32 spacesCount = partitioningInfo.CountPartitionableSpaces(); if (spacesCount == 0) { - _DisplayPartitionError("There's no space on the partition where a " - "child partition could be created\n"); + _DisplayPartitionError(TR("There's no space on the partition where " + "a child partition could be created.")); return; } @@ -960,18 +998,17 @@ &name, parameters.String()); if (ret != B_OK) { - _DisplayPartitionError("Validation of the given creation " - "parameters failed."); + _DisplayPartitionError(TR("Validation of the given creation " + "parameters failed.")); return; } // Warn the user one more time... - BString message = "Are you sure you want to write the changes back to " - "disk now?\n\n"; - message << "All data on the partition"; - message << " will be irretrievably lost if you do so!"; - BAlert* alert = new BAlert("final notice", message.String(), - "Write changes", "Cancel", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); + BAlert* alert = new BAlert("final notice", TR("Are you sure you want " + "to write the changes back to disk now?\n\n" + "All data on the partition will be irretrievably lost if you do " + "so!"), TR("Write changes"), TR("Cancel"), NULL, B_WIDTH_FROM_WIDEST, + B_WARNING_ALERT); int32 choice = alert->Go(); if (choice == 1) @@ -981,7 +1018,7 @@ name.String(), parameters.String()); if (ret != B_OK) { - _DisplayPartitionError("Creation of the partition has failed\n"); + _DisplayPartitionError(TR("Creation of the partition has failed.")); return; } @@ -989,8 +1026,8 @@ ret = modificationPreparer.CommitModifications(); if (ret != B_OK) { - _DisplayPartitionError("Failed to initialize the partition. " - "This operation is exiting.\nNo changes have been made!\n"); + _DisplayPartitionError(TR("Failed to initialize the partition. " + "No changes have been written to disk.")); return; } @@ -1006,49 +1043,49 @@ MainWindow::_Delete(BDiskDevice* disk, partition_id selectedPartition) { if (!disk || selectedPartition < 0) { - _DisplayPartitionError("You need to select a partition " - "entry from the list."); + _DisplayPartitionError(TR("You need to select a partition " + "entry from the list.")); return; } if (disk->IsReadOnly()) { - _DisplayPartitionError("The selected disk is read-only."); + _DisplayPartitionError(TR("The selected disk is read-only.")); return; } BPartition* partition = disk->FindDescendant(selectedPartition); if (!partition) { - _DisplayPartitionError("Unable to find the selected partition by ID."); + _DisplayPartitionError(TR("Unable to find the selected partition " + "by ID.")); return; } BPartition* parent = partition->Parent(); if (!parent) { - _DisplayPartitionError("The currently selected partition does not " - "have a parent partition"); + _DisplayPartitionError(TR("The currently selected partition does " + "not have a parent partition.")); return; } ModificationPreparer modificationPreparer(disk); status_t ret = modificationPreparer.ModificationStatus(); if (ret != B_OK) { - _DisplayPartitionError("There was an error preparing the " - "disk for modifications.", NULL, ret); + _DisplayPartitionError(TR("There was an error preparing the " + "disk for modifications."), NULL, ret); return; } if (!parent->CanDeleteChild(partition->Index())) { - _DisplayPartitionError("Cannot delete the selected partition"); + _DisplayPartitionError(TR("Cannot delete the selected partition.")); return; } // Warn the user one more time... - BString message = "Are you sure you want to delete the selected "; - message << "partition?\n\nAll data on the partition"; - message << " will be irretrievably lost if you do so!"; - BAlert* alert = new BAlert("final notice", message.String(), - "Delete partition", "Cancel", NULL, B_WIDTH_FROM_WIDEST, - B_WARNING_ALERT); + BAlert* alert = new BAlert("final notice", TR("Are you sure you want " + "to delete the selected partition?\n\n" + "All data on the partition will be irretrievably lost if you " + "do so!"), TR("Delete partition"), TR("Cancel"), NULL, + B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); int32 choice = alert->Go(); if (choice == 1) @@ -1056,15 +1093,15 @@ ret = parent->DeleteChild(partition->Index()); if (ret != B_OK) { - _DisplayPartitionError("Could not delete the selected partition"); + _DisplayPartitionError(TR("Could not delete the selected partition.")); return; } ret = modificationPreparer.CommitModifications(); if (ret != B_OK) { - _DisplayPartitionError("Failed to delete the partition. " - "This operation is exiting.\nNo changes have been made!\n"); + _DisplayPartitionError(TR("Failed to delete the partition. " + "No changes have been written to disk.")); return; } Modified: haiku/trunk/src/apps/drivesetup/PartitionList.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/PartitionList.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2009 Haiku Inc. All rights reserved. + * Copyright 2006-2010 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT license. * * Authors: @@ -7,18 +7,25 @@ * James Urquhart * Stephan Aßmus <superstippi@xxxxxx> */ + #include "PartitionList.h" -#include "Support.h" +#include <Catalog.h> #include <ColumnTypes.h> #include <Path.h> +#include "Support.h" + +#define TR_CONTEXT "PartitionList" + + // #pragma mark - BBitmapStringField BBitmapStringField::BBitmapStringField(BBitmap* bitmap, const char* string) - : Inherited(string), + : + Inherited(string), fBitmap(bitmap) { } @@ -47,7 +54,8 @@ PartitionColumn::PartitionColumn(const char* title, float width, float minWidth, float maxWidth, uint32 truncateMode, alignment align) - : Inherited(title, width, minWidth, maxWidth, align), + : + Inherited(title, width, minWidth, maxWidth, align), fTruncateMode(truncateMode) { SetWantsEvents(true); @@ -179,7 +187,8 @@ PartitionListRow::PartitionListRow(BPartition* partition) - : Inherited(), + : + Inherited(), fPartitionID(partition->ID()), fParentID(partition->Parent() ? partition->Parent()->ID() : -1), fOffset(partition->Offset()), @@ -225,7 +234,8 @@ PartitionListRow::PartitionListRow(partition_id parentID, partition_id id, off_t offset, off_t size) - : Inherited(), + : + Inherited(), fPartitionID(id), fParentID(parentID), fOffset(offset), @@ -234,7 +244,7 @@ // TODO: design icon for spaces on partitions SetField(new BBitmapStringField(NULL, "-"), kDeviceColumn); - SetField(new BStringField("<empty>"), kFilesystemColumn); + SetField(new BStringField(TR("<empty>")), kFilesystemColumn); SetField(new BStringField(kUnavailableString), kVolumeNameColumn); SetField(new BStringField(kUnavailableString), kMountedAtColumn); @@ -250,15 +260,15 @@ PartitionListView::PartitionListView(const BRect& frame, uint32 resizeMode) : Inherited(frame, "storagelist", resizeMode, 0, B_NO_BORDER, true) { - AddColumn(new PartitionColumn("Device", 150, 50, 500, + AddColumn(new PartitionColumn(TR("Device"), 150, 50, 500, B_TRUNCATE_MIDDLE), kDeviceColumn); - AddColumn(new PartitionColumn("File system", 100, 50, 500, + AddColumn(new PartitionColumn(TR("File system"), 100, 50, 500, B_TRUNCATE_MIDDLE), kFilesystemColumn); - AddColumn(new PartitionColumn("Volume name", 130, 50, 500, + AddColumn(new PartitionColumn(TR("Volume name"), 130, 50, 500, B_TRUNCATE_MIDDLE), kVolumeNameColumn); - AddColumn(new PartitionColumn("Mounted at", 100, 50, 500, + AddColumn(new PartitionColumn(TR("Mounted at"), 100, 50, 500, B_TRUNCATE_MIDDLE), kMountedAtColumn); - AddColumn(new PartitionColumn("Size", 100, 50, 500, + AddColumn(new PartitionColumn(TR("Size"), 100, 50, 500, B_TRUNCATE_END, B_ALIGN_RIGHT), kSizeColumn); SetSortingEnabled(false); Modified: haiku/trunk/src/apps/drivesetup/Support.cpp =================================================================== --- haiku/trunk/src/apps/drivesetup/Support.cpp 2010-01-21 18:17:06 UTC (rev 35228) +++ haiku/trunk/src/apps/drivesetup/Support.cpp 2010-01-21 20:02:57 UTC (rev 35229) @@ -13,34 +13,38 @@ #include <stdio.h> +#include <Catalog.h> #include <Partition.h> [... truncated: 106 lines follow ...]