From aaef889bfb923a15df9ed3f6d7a31a941a1fe9ca Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 14 Apr 2010 11:55:17 +0000 Subject: [PATCH] Localize FileTypes. It does not use the layout kit yet, so the tranlation doesn't look perfect. Anyone willing to update it ? git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36252 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../filetypes/ApplicationTypeWindow.cpp | 64 +++++----- .../filetypes/ApplicationTypesWindow.cpp | 53 +++++---- src/preferences/filetypes/AttributeWindow.cpp | 38 +++--- src/preferences/filetypes/ExtensionWindow.cpp | 17 ++- src/preferences/filetypes/FileTypeWindow.cpp | 38 +++--- src/preferences/filetypes/FileTypes.cpp | 25 ++-- src/preferences/filetypes/FileTypesWindow.cpp | 109 ++++++++++-------- src/preferences/filetypes/IconView.cpp | 21 +++- src/preferences/filetypes/Jamfile | 17 ++- .../filetypes/NewFileTypeWindow.cpp | 32 ++--- .../filetypes/PreferredAppMenu.cpp | 22 ++-- src/preferences/filetypes/TypeListWindow.cpp | 18 ++- 12 files changed, 276 insertions(+), 178 deletions(-) diff --git a/src/preferences/filetypes/ApplicationTypeWindow.cpp b/src/preferences/filetypes/ApplicationTypeWindow.cpp index 87a5bb1d08..de0dcdb010 100644 --- a/src/preferences/filetypes/ApplicationTypeWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypeWindow.cpp @@ -16,8 +16,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -36,6 +38,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "Application Type Window" + + const uint32 kMsgSave = 'save'; const uint32 kMsgSignatureChanged = 'sgch'; const uint32 kMsgToggleAppFlags = 'tglf'; @@ -229,7 +235,7 @@ SupportedTypeListView::AcceptsDrag(const BMessage* message) ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry) : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position), - "Application Type", B_TITLED_WINDOW, + TR("Application Type"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fChangedProperties(0) { @@ -238,17 +244,17 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); - BMenu* menu = new BMenu("File"); - fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S'); + BMenu* menu = new BMenu(TR("File")); + fSaveMenuItem = new BMenuItem(TR("Save"), new BMessage(kMsgSave), 'S'); fSaveMenuItem->SetEnabled(false); menu->AddItem(fSaveMenuItem); BMenuItem* item; - menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS, - NULL)); + menu->AddItem(item = new BMenuItem( + TR("Save into resource file" B_UTF8_ELLIPSIS), NULL)); item->SetEnabled(false); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), + menu->AddItem(new BMenuItem(TR("Close"), new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); menuBar->AddItem(menu); @@ -261,7 +267,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr AddChild(topView); rect = topView->Bounds().InsetByCopy(8.0f, 8.0f); - fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL, + fSignatureControl = new BTextControl(rect, "signature", TR("Signature:"), NULL, new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT); fSignatureControl->SetModificationMessage( new BMessage(kMsgSignatureChanged)); @@ -296,40 +302,40 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); topView->AddChild(box); - fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags", + fFlagsCheckBox = new BCheckBox(rect, "flags", TR("Application flags"), new BMessage(kMsgToggleAppFlags)); fFlagsCheckBox->SetValue(B_CONTROL_ON); fFlagsCheckBox->ResizeToPreferred(); box->SetLabel(fFlagsCheckBox); rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f; - fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch", + fSingleLaunchButton = new BRadioButton(rect, "single", TR("Single launch"), new BMessage(kMsgAppFlagsChanged)); fSingleLaunchButton->ResizeToPreferred(); box->AddChild(fSingleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fMultipleLaunchButton = new BRadioButton(rect, "multiple", - "Multiple launch", new BMessage(kMsgAppFlagsChanged)); + TR("Multiple launch"), new BMessage(kMsgAppFlagsChanged)); fMultipleLaunchButton->ResizeToPreferred(); box->AddChild(fMultipleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fExclusiveLaunchButton = new BRadioButton(rect, "exclusive", - "Exclusive launch", new BMessage(kMsgAppFlagsChanged)); + TR("Exclusive launch"), new BMessage(kMsgAppFlagsChanged)); fExclusiveLaunchButton->ResizeToPreferred(); box->AddChild(fExclusiveLaunchButton); rect.top = fSingleLaunchButton->Frame().top; rect.left = fExclusiveLaunchButton->Frame().right + 4.0f; - fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only", + fArgsOnlyCheckBox = new BCheckBox(rect, "args only", TR("Args only"), new BMessage(kMsgAppFlagsChanged)); fArgsOnlyCheckBox->ResizeToPreferred(); box->AddChild(fArgsOnlyCheckBox); rect.top += fArgsOnlyCheckBox->Bounds().Height(); fBackgroundAppCheckBox = new BCheckBox(rect, "background", - "Background app", new BMessage(kMsgAppFlagsChanged)); + TR("Background app"), new BMessage(kMsgAppFlagsChanged)); fBackgroundAppCheckBox->ResizeToPreferred(); box->AddChild(fBackgroundAppCheckBox); @@ -373,12 +379,12 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - typeBox->SetLabel("Supported types"); + typeBox->SetLabel(TR("Supported types")); topView->AddChild(typeBox); rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f); rect.top += ceilf(fontHeight.ascent); - fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS, + fAddTypeButton = new BButton(rect, "add type", TR("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType), B_FOLLOW_RIGHT); fAddTypeButton->ResizeToPreferred(); fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width() @@ -387,7 +393,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect = fAddTypeButton->Frame(); rect.OffsetBy(0, rect.Height() + 4.0f); - fRemoveTypeButton = new BButton(rect, "remove type", "Remove", + fRemoveTypeButton = new BButton(rect, "remove type", TR("Remove"), new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT); typeBox->AddChild(fRemoveTypeButton); @@ -426,7 +432,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect.right = Bounds().Width() - 8.0f; box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); // the resizing mode will later also be set to B_FOLLOW_BOTTOM - box->SetLabel("Version info"); + box->SetLabel(TR("Version info")); topView->AddChild(box); BMenuField* menuField; @@ -446,7 +452,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent); rect.bottom = rect.top + height; - fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL, + fMajorVersionControl = new BTextControl(rect, "major", TR("Version:"), NULL, NULL); fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth( fMajorVersionControl->Label()) + 4.0f); @@ -475,13 +481,13 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr box->AddChild(fMinorVersionControl); fVarietyMenu = new BPopUpMenu("variety", true, true); - fVarietyMenu->AddItem(new BMenuItem("Development", NULL)); - fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL)); - fVarietyMenu->AddItem(new BMenuItem("Beta", NULL)); - fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL)); - fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL)); + fVarietyMenu->AddItem(new BMenuItem(TR("Development"), NULL)); + fVarietyMenu->AddItem(new BMenuItem(TR("Alpha"), NULL)); + fVarietyMenu->AddItem(new BMenuItem(TR("Beta"), NULL)); + fVarietyMenu->AddItem(new BMenuItem(TR("Gamma"), NULL)); + fVarietyMenu->AddItem(item = new BMenuItem(TR("Golden master"), NULL)); item->SetMarked(true); - fVarietyMenu->AddItem(new BMenuItem("Final", NULL)); + fVarietyMenu->AddItem(new BMenuItem(TR("Final"), NULL)); rect.top--; // BMenuField oddity @@ -503,7 +509,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect = box->Bounds().InsetByCopy(8.0f, 0.0f); rect.top = fInternalVersionControl->Frame().bottom + 8.0f; - fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:", + fShortDescriptionControl = new BTextControl(rect, "short desc", TR("Short description:"), NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); float labelWidth = fShortDescriptionControl->StringWidth( fShortDescriptionControl->Label()) + 4.0f; @@ -518,7 +524,7 @@ ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entr rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f); rect.right = rect.left + labelWidth; - StringView* label = new StringView(rect, NULL, "Long description:", NULL); + StringView* label = new StringView(rect, NULL, TR("Long description:"), NULL); label->SetDivider(labelWidth); box->AddChild(label); @@ -1088,9 +1094,9 @@ bool ApplicationTypeWindow::QuitRequested() { if (_NeedsSaving(CHECK_ALL) != 0) { - BAlert* alert = new BAlert("Save request", "Do you want to save " - "the changes?", "Quit, don't save", "Cancel", "Save", - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + BAlert* alert = new BAlert(TR("Save request"), TR("Do you want to " + "save the changes?"), TR("Quit, don't save"), TR("Cancel"), + TR("Save"), B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 choice = alert->Go(); switch (choice) { case 0: diff --git a/src/preferences/filetypes/ApplicationTypesWindow.cpp b/src/preferences/filetypes/ApplicationTypesWindow.cpp index f44cb1c449..df017aead6 100644 --- a/src/preferences/filetypes/ApplicationTypesWindow.cpp +++ b/src/preferences/filetypes/ApplicationTypesWindow.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -35,6 +37,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "Application Types Window" + + class ProgressWindow : public BWindow { public: ProgressWindow(const char* message, int32 max, volatile bool* signalQuit); @@ -68,17 +74,17 @@ variety_to_text(uint32 variety) switch (variety) { case B_DEVELOPMENT_VERSION: - return "Development"; + return TR("Development"); case B_ALPHA_VERSION: - return "Alpha"; + return TR("Alpha"); case B_BETA_VERSION: - return "Beta"; + return TR("Beta"); case B_GAMMA_VERSION: - return "Gamma"; + return TR("Gamma"); case B_GOLDEN_MASTER_VERSION: - return "Golden master"; + return TR("Golden master"); case B_FINAL_VERSION: - return "Final"; + return TR("Final"); } return "-"; @@ -89,7 +95,7 @@ variety_to_text(uint32 variety) ProgressWindow::ProgressWindow(const char* message, int32 max, volatile bool* signalQuit) - : BWindow(BRect(0, 0, 300, 200), "Progress", B_MODAL_WINDOW_LOOK, + : BWindow(BRect(0, 0, 300, 200), TR("Progress"), B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE), fQuitListener(signalQuit) { @@ -109,7 +115,7 @@ ProgressWindow::ProgressWindow(const char* message, int32 max, volatile bool* si fStatusBar->ResizeTo(rect.Width(), height); topView->AddChild(fStatusBar); - fAbortButton = new BButton(rect, "abort", "Abort", new BMessage(B_CANCEL), + fAbortButton = new BButton(rect, "abort", TR("Abort"), new BMessage(B_CANCEL), B_FOLLOW_H_CENTER | B_FOLLOW_TOP); fAbortButton->ResizeToPreferred(); fAbortButton->MoveTo((Bounds().Width() - fAbortButton->Bounds().Width()) / 2, @@ -160,7 +166,7 @@ ProgressWindow::MessageReceived(BMessage* message) ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) - : BWindow(_Frame(settings), "Application types", B_TITLED_WINDOW, + : BWindow(_Frame(settings), TR("Application types"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) { // Application list @@ -170,7 +176,7 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); - BButton* button = new BButton(rect, "remove", "Remove uninstalled", + BButton* button = new BButton(rect, "remove", TR("Remove uninstalled"), new BMessage(kMsgRemoveUninstalled), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(8.0f, rect.bottom - 8.0f - button->Bounds().Height()); @@ -201,15 +207,15 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) rect.right = topView->Bounds().Width() - 8.0f; rect.bottom = rect.top + ceilf(fontHeight.ascent) + 24.0f; BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - box->SetLabel("Information"); + box->SetLabel(TR("Information")); topView->AddChild(box); BRect innerRect = box->Bounds().InsetByCopy(8.0f, 6.0f); - float labelWidth = topView->StringWidth("Description:") + 4.0f; + float labelWidth = topView->StringWidth(TR("Description:")) + 4.0f; innerRect.right = box->Bounds().Width() - 8.0f; innerRect.top += ceilf(fontHeight.ascent); - fNameView = new StringView(innerRect, "name", "Name:", NULL, B_FOLLOW_LEFT_RIGHT); + fNameView = new StringView(innerRect, "name", TR("Name:"), NULL, B_FOLLOW_LEFT_RIGHT); fNameView->SetDivider(labelWidth); float width, height; fNameView->GetPreferredSize(&width, &height); @@ -219,13 +225,13 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f); innerRect.bottom = innerRect.top + height; - fSignatureView = new StringView(innerRect, "signature", "Signature:", NULL, + fSignatureView = new StringView(innerRect, "signature", TR("Signature:"), NULL, B_FOLLOW_LEFT_RIGHT); fSignatureView->SetDivider(labelWidth); box->AddChild(fSignatureView); innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f); - fPathView = new StringView(innerRect, "path", "Path:", NULL, + fPathView = new StringView(innerRect, "path", TR("Path:"), NULL, B_FOLLOW_LEFT_RIGHT); fPathView->SetDivider(labelWidth); box->AddChild(fPathView); @@ -236,18 +242,18 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) rect.bottom = rect.top + ceilf(fontHeight.ascent) + fNameView->Bounds().Height() * 4.0f + 20.0f; box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - box->SetLabel("Version"); + box->SetLabel(TR("Version")); topView->AddChild(box); innerRect = fNameView->Frame(); - fVersionView = new StringView(innerRect, "version", "Version:", NULL, + fVersionView = new StringView(innerRect, "version", TR("Version:"), NULL, B_FOLLOW_LEFT_RIGHT); fVersionView->SetDivider(labelWidth); box->AddChild(fVersionView); innerRect.OffsetBy(0, fNameView->Bounds().Height() + 5.0f); innerRect.right = innerRect.left + labelWidth; - fDescriptionLabel = new StringView(innerRect, "description", "Description:", NULL); + fDescriptionLabel = new StringView(innerRect, "description", TR("Description:"), NULL); fDescriptionLabel->SetDivider(labelWidth); box->AddChild(fDescriptionLabel); @@ -268,20 +274,20 @@ ApplicationTypesWindow::ApplicationTypesWindow(const BMessage &settings) rect = box->Frame(); rect.top = rect.bottom + 8.0f; rect.bottom = rect.top + 20.0f; - fTrackerButton = new BButton(rect, "tracker", "Show in Tracker" B_UTF8_ELLIPSIS, NULL, + fTrackerButton = new BButton(rect, "tracker", TR("Show in Tracker" B_UTF8_ELLIPSIS), NULL, B_FOLLOW_RIGHT); fTrackerButton->ResizeToPreferred(); fTrackerButton->MoveTo(rect.right - fTrackerButton->Bounds().Width(), rect.top); topView->AddChild(fTrackerButton); - fLaunchButton = new BButton(rect, "launch", "Launch", NULL, + fLaunchButton = new BButton(rect, "launch", TR("Launch"), NULL, B_FOLLOW_RIGHT); fLaunchButton->ResizeToPreferred(); fLaunchButton->MoveTo(fTrackerButton->Frame().left - 6.0f - fLaunchButton->Bounds().Width(), rect.top); topView->AddChild(fLaunchButton); - fEditButton = new BButton(rect, "edit", "Edit" B_UTF8_ELLIPSIS, new BMessage(kMsgEdit), + fEditButton = new BButton(rect, "edit", TR("Edit" B_UTF8_ELLIPSIS), new BMessage(kMsgEdit), B_FOLLOW_RIGHT); fEditButton->ResizeToPreferred(); fEditButton->MoveTo(fLaunchButton->Frame().left - 6.0f @@ -322,7 +328,7 @@ ApplicationTypesWindow::_RemoveUninstalled() int32 removed = 0; volatile bool quit = false; - BWindow* progressWindow = new ProgressWindow("Removing uninstalled application types", + BWindow* progressWindow = new ProgressWindow(TR("Removing uninstalled application types"), fTypeListView->FullListCountItems(), &quit); progressWindow->AddToSubset(this); progressWindow->Show(); @@ -375,7 +381,8 @@ ApplicationTypesWindow::_RemoveUninstalled() progressWindow->PostMessage(B_QUIT_REQUESTED); char message[512]; - snprintf(message, sizeof(message), "%ld Application type%s could be removed.", + // TODO : use ICU to properly format this + snprintf(message, sizeof(message), TR("%ld Application type%s could be removed."), removed, removed == 1 ? "" : "s"); error_alert(message, B_OK, B_INFO_ALERT); } diff --git a/src/preferences/filetypes/AttributeWindow.cpp b/src/preferences/filetypes/AttributeWindow.cpp index f1e004b204..2729c33752 100644 --- a/src/preferences/filetypes/AttributeWindow.cpp +++ b/src/preferences/filetypes/AttributeWindow.cpp @@ -10,7 +10,9 @@ #include #include +#include #include +#include #include #include #include @@ -24,6 +26,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "Attribute Window" + + const uint32 kMsgAttributeUpdated = 'atup'; const uint32 kMsgTypeChosen = 'typc'; const uint32 kMsgDisplayAsChosen = 'dach'; @@ -85,7 +91,7 @@ display_as_parameter(const char* special) AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, AttributeItem* attributeItem) - : BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK, + : BWindow(BRect(100, 100, 350, 200), TR("Attribute"), B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target), @@ -100,7 +106,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, AddChild(topView); rect.InsetBy(8.0f, 8.0f); - fPublicNameControl = new BTextControl(rect, "public", "Attribute name:", + fPublicNameControl = new BTextControl(rect, "public", TR("Attribute name:"), fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT); fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); @@ -115,7 +121,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, rect = fPublicNameControl->Frame(); rect.OffsetBy(0.0f, rect.Height() + 5.0f); - fAttributeControl = new BTextControl(rect, "internal", "Internal name:", + fAttributeControl = new BTextControl(rect, "internal", TR("Internal name:"), fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT); fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); fAttributeControl->SetDivider(labelWidth); @@ -145,7 +151,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, rect.OffsetBy(0.0f, rect.Height() + 4.0f); BMenuField* menuField = new BMenuField(rect, "types", - "Type:", fTypeMenu); + TR("Type:"), fTypeMenu); menuField->SetDivider(labelWidth); menuField->SetAlignment(B_ALIGN_RIGHT); menuField->GetPreferredSize(&width, &height); @@ -157,7 +163,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT); topView->AddChild(box); - fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible", + fVisibleCheckBox = new BCheckBox(rect, "visible", TR("Visible"), new BMessage(kMsgVisibilityChanged)); fVisibleCheckBox->SetValue(fAttribute.Visible()); fVisibleCheckBox->ResizeToPreferred(); @@ -185,13 +191,13 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height()); rect.right -= 18.0f; fDisplayAsMenuField = new BMenuField(rect, "display as", - "Display as:", menu); + TR("Display as:"), menu); fDisplayAsMenuField->SetDivider(labelWidth); fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT); fDisplayAsMenuField->ResizeTo(rect.Width(), height); box->AddChild(fDisplayAsMenuField); - fEditableCheckBox = new BCheckBox(rect, "editable", "Editable", + fEditableCheckBox = new BCheckBox(rect, "editable", TR("Editable"), new BMessage(kMsgAttributeUpdated), B_FOLLOW_RIGHT); fEditableCheckBox->SetValue(fAttribute.Editable()); fEditableCheckBox->ResizeToPreferred(); @@ -202,7 +208,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, rect.OffsetBy(0.0f, menuField->Bounds().Height() + 4.0f); rect.bottom = rect.top + fPublicNameControl->Bounds().Height(); - fSpecialControl = new BTextControl(rect, "special", "Special:", + fSpecialControl = new BTextControl(rect, "special", TR("Special:"), display_as_parameter(fAttribute.DisplayAs()), NULL, B_FOLLOW_LEFT_RIGHT); fSpecialControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); @@ -214,7 +220,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, char text[64]; snprintf(text, sizeof(text), "%ld", fAttribute.Width()); rect.OffsetBy(0.0f, fSpecialControl->Bounds().Height() + 4.0f); - fWidthControl = new BTextControl(rect, "width", "Width:", + fWidthControl = new BTextControl(rect, "width", TR("Width:"), text, NULL, B_FOLLOW_LEFT_RIGHT); fWidthControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated)); fWidthControl->SetDivider(labelWidth); @@ -234,9 +240,9 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, int32 alignment; const char* name; } kAlignmentMap[] = { - {B_ALIGN_LEFT, "Left"}, - {B_ALIGN_RIGHT, "Right"}, - {B_ALIGN_CENTER, "Center"}, + {B_ALIGN_LEFT, TR("Left")}, + {B_ALIGN_RIGHT, TR("Right")}, + {B_ALIGN_CENTER, TR("Center")}, {0, NULL} }; @@ -254,7 +260,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, rect.OffsetBy(0.0f, menuField->Bounds().Height() + 1.0f); fAlignmentMenuField = new BMenuField(rect, "alignment", - "Alignment:", menu); + TR("Alignment:"), menu); fAlignmentMenuField->SetDivider(labelWidth); fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT); fAlignmentMenuField->ResizeTo(rect.Width(), height); @@ -262,7 +268,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, box->ResizeBy(0.0f, fAlignmentMenuField->Bounds().Height() * 2.0f + fVisibleCheckBox->Bounds().Height()); - fAcceptButton = new BButton(rect, "add", item ? "Done" : "Add", + fAcceptButton = new BButton(rect, "add", item ? TR("Done") : TR("Add"), new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fAcceptButton->ResizeToPreferred(); fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(), @@ -270,7 +276,7 @@ AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType, fAcceptButton->SetEnabled(false); topView->AddChild(fAcceptButton); - BButton* button = new BButton(rect, "cancel", "Cancel", + BButton* button = new BButton(rect, "cancel", TR("Cancel"), new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(), @@ -489,7 +495,7 @@ AttributeWindow::MessageReceived(BMessage* message) } if (status != B_OK) - error_alert("Could not change attributes", status); + error_alert(TR("Could not change attributes"), status); PostMessage(B_QUIT_REQUESTED); break; diff --git a/src/preferences/filetypes/ExtensionWindow.cpp b/src/preferences/filetypes/ExtensionWindow.cpp index 7ed7c8ad09..c6ad4af22d 100644 --- a/src/preferences/filetypes/ExtensionWindow.cpp +++ b/src/preferences/filetypes/ExtensionWindow.cpp @@ -9,6 +9,8 @@ #include "FileTypesWindow.h" #include +#include +#include #include #include #include @@ -19,6 +21,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "Extension Window" + + const uint32 kMsgExtensionUpdated = 'exup'; const uint32 kMsgAccept = 'acpt'; @@ -103,7 +109,7 @@ replace_extension(BMimeType& type, const char* newExtension, ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type, const char* extension) - : BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK, + : BWindow(BRect(100, 100, 350, 200), TR("Extension"), B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target), @@ -116,7 +122,7 @@ ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type, AddChild(topView); rect.InsetBy(8.0f, 8.0f); - fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension, + fExtensionControl = new BTextControl(rect, "extension", TR("Extension:"), extension, NULL, B_FOLLOW_LEFT_RIGHT); float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f; @@ -136,7 +142,7 @@ ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type, fExtensionControl->ResizeTo(rect.Width(), height); topView->AddChild(fExtensionControl); - fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add", + fAcceptButton = new BButton(rect, "add", extension ? TR("Done") : TR("Add"), new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fAcceptButton->ResizeToPreferred(); fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(), @@ -144,7 +150,7 @@ ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type, fAcceptButton->SetEnabled(false); topView->AddChild(fAcceptButton); - BButton* button = new BButton(rect, "cancel", "Cancel", + BButton* button = new BButton(rect, "cancel", TR("Cancel"), new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(), @@ -202,7 +208,7 @@ ExtensionWindow::MessageReceived(BMessage* message) status_t status = replace_extension(fMimeType, newExtension, fExtension.String()); if (status != B_OK) - error_alert("Could not change file extensions", status); + error_alert(TR("Could not change file extensions"), status); PostMessage(B_QUIT_REQUESTED); break; @@ -213,4 +219,3 @@ ExtensionWindow::MessageReceived(BMessage* message) break; } } - diff --git a/src/preferences/filetypes/FileTypeWindow.cpp b/src/preferences/filetypes/FileTypeWindow.cpp index 6b401589f6..991363ef31 100644 --- a/src/preferences/filetypes/FileTypeWindow.cpp +++ b/src/preferences/filetypes/FileTypeWindow.cpp @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -25,6 +27,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "FileType Window" + + const uint32 kMsgTypeEntered = 'type'; const uint32 kMsgSelectType = 'sltp'; const uint32 kMsgTypeSelected = 'tpsd'; @@ -40,7 +46,7 @@ const uint32 kMsgSamePreferredAppAsOpened = 'spaO'; FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs) : BWindow(BRect(0.0f, 0.0f, 200.0f, 200.0f).OffsetBySelf(position), - "File type", B_TITLED_WINDOW, + TR("File type"), B_TITLED_WINDOW, B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) { BRect rect = Bounds(); @@ -56,7 +62,7 @@ FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs) rect.InsetBy(8.0f, 8.0f); BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - box->SetLabel("File type"); + box->SetLabel(TR("File type")); topView->AddChild(box); rect = box->Bounds(); @@ -77,13 +83,15 @@ FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs) } rect.OffsetBy(0.0f, fTypeControl->Bounds().Height() + 5.0f); - fSelectTypeButton = new BButton(rect, "select type", "Select" B_UTF8_ELLIPSIS, + fSelectTypeButton = new BButton(rect, "select type", + TR("Select" B_UTF8_ELLIPSIS), new BMessage(kMsgSelectType), B_FOLLOW_LEFT | B_FOLLOW_TOP); fSelectTypeButton->ResizeToPreferred(); box->AddChild(fSelectTypeButton); rect.OffsetBy(fSelectTypeButton->Bounds().Width() + 8.0f, 0.0f); - fSameTypeAsButton = new BButton(rect, "same type as", "Same as" B_UTF8_ELLIPSIS, + fSameTypeAsButton = new BButton(rect, "same type as", + TR("Same as" B_UTF8_ELLIPSIS), new BMessage(kMsgSameTypeAs), B_FOLLOW_LEFT | B_FOLLOW_TOP); fSameTypeAsButton->ResizeToPreferred(); box->AddChild(fSameTypeAsButton); @@ -121,12 +129,12 @@ FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs) rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - box->SetLabel("Preferred application"); + box->SetLabel(TR("Preferred application")); topView->AddChild(box); BMenu* menu = new BPopUpMenu("preferred"); BMenuItem* item; - menu->AddItem(item = new BMenuItem("Default application", + menu->AddItem(item = new BMenuItem(TR("Default application"), new BMessage(kMsgPreferredAppChosen))); item->SetMarked(true); @@ -147,13 +155,15 @@ FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs) box->AddChild(constrainingView); rect.OffsetBy(0.0f, height + 5.0f); - fSelectAppButton = new BButton(rect, "select app", "Select" B_UTF8_ELLIPSIS, + fSelectAppButton = new BButton(rect, "select app", + TR("Select" B_UTF8_ELLIPSIS), new BMessage(kMsgSelectPreferredApp), B_FOLLOW_LEFT | B_FOLLOW_TOP); fSelectAppButton->ResizeToPreferred(); box->AddChild(fSelectAppButton); rect.OffsetBy(fSelectAppButton->Bounds().Width() + 8.0f, 0.0f); - fSameAppAsButton = new BButton(rect, "same app as", "Same as" B_UTF8_ELLIPSIS, + fSameAppAsButton = new BButton(rect, "same app as", + TR("Same as" B_UTF8_ELLIPSIS), new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_LEFT | B_FOLLOW_TOP); fSameAppAsButton->ResizeToPreferred(); box->AddChild(fSameAppAsButton); @@ -203,11 +213,11 @@ FileTypeWindow::_Title(const BMessage& refs) char name[B_FILE_NAME_LENGTH]; if (same && parent.GetName(name) == B_OK) { - title = "Multiple files from \""; + title = TR("Multiple files from \""); title.Append(name); title.Append("\""); } else - title = "[Multiple files]"; + title = TR("[Multiple files]"); } else if (refs.FindRef("refs", 0, &ref) == B_OK) title = ref.name; @@ -294,7 +304,7 @@ FileTypeWindow::_AdoptType(BMessage* message) } if (status != B_OK) { - error_alert("Could not open file", status); + error_alert(TR("Could not open file"), status); return; } @@ -391,7 +401,7 @@ FileTypeWindow::MessageReceived(BMessage* message) case kMsgSameTypeAs: { BMessage panel(kMsgOpenFilePanel); - panel.AddString("title", "Select same type as"); + panel.AddString("title", TR("Select same type as")); panel.AddInt32("message", kMsgSameTypeAsOpened); panel.AddMessenger("target", this); @@ -419,7 +429,7 @@ FileTypeWindow::MessageReceived(BMessage* message) case kMsgSelectPreferredApp: { BMessage panel(kMsgOpenFilePanel); - panel.AddString("title", "Select preferred application"); + panel.AddString("title", TR("Select preferred application")); panel.AddInt32("message", kMsgPreferredAppOpened); panel.AddMessenger("target", this); @@ -433,7 +443,7 @@ FileTypeWindow::MessageReceived(BMessage* message) case kMsgSamePreferredAppAs: { BMessage panel(kMsgOpenFilePanel); - panel.AddString("title", "Select same preferred application as"); + panel.AddString("title", TR("Select same preferred application as")); panel.AddInt32("message", kMsgSamePreferredAppAsOpened); panel.AddMessenger("target", this); diff --git a/src/preferences/filetypes/FileTypes.cpp b/src/preferences/filetypes/FileTypes.cpp index 5cb63b6cf3..8e4bf9e131 100644 --- a/src/preferences/filetypes/FileTypes.cpp +++ b/src/preferences/filetypes/FileTypes.cpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -24,6 +26,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "FileTypes" + + const char *kSignature = "application/x-vnd.Haiku-FileTypes"; static const uint32 kMsgFileTypesSettings = 'FTst'; @@ -70,6 +76,8 @@ class FileTypes : public BApplication { BWindow *fApplicationTypesWindow; uint32 fWindowCount; uint32 fTypeWindowCount; + + BCatalog fCatalog; }; @@ -163,6 +171,7 @@ FileTypes::FileTypes() fWindowCount(0), fTypeWindowCount(0) { + be_locale->GetAppCatalog(&fCatalog); fFilePanel = new BFilePanel(B_OPEN_PANEL, NULL, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false); } @@ -207,11 +216,11 @@ FileTypes::RefsReceived(BMessage *message) char buffer[1024]; snprintf(buffer, sizeof(buffer), - "Could not open \"%s\":\n" - "%s", + TR("Could not open \"%s\":\n" + "%s"), ref.name, strerror(status)); - (new BAlert("FileTypes request", + (new BAlert(TR("FileTypes request"), buffer, "Ok", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go(); @@ -278,7 +287,7 @@ FileTypes::ArgvReceived(int32 argc, char **argv) if ((status = entry.SetTo(path.Path(), false)) != B_OK || (status = entry.GetRef(&ref)) != B_OK) { - fprintf(stderr, "Could not open file \"%s\": %s\n", + fprintf(stderr, TR("Could not open file \"%s\": %s\n"), path.Path(), strerror(status)); continue; } @@ -347,7 +356,7 @@ FileTypes::MessageReceived(BMessage *message) // the open file panel sends us a message when it's done const char* subTitle; if (message->FindString("title", &subTitle) != B_OK) - subTitle = "Open File"; + subTitle = TR("Open File"); int32 what; if (message->FindInt32("message", &what) != B_OK) @@ -398,9 +407,9 @@ FileTypes::MessageReceived(BMessage *message) void FileTypes::AboutRequested() { - BAlert *alert = new BAlert("about", "FileTypes\n" + BAlert *alert = new BAlert("about", TR("FileTypes\n" "\twritten by Axel Dörfler\n" - "\tCopyright 2006-2007, Haiku.\n", "Ok"); + "\tCopyright 2006-2007, Haiku.\n"), TR("Ok")); BTextView *view = alert->TextView(); BFont font; @@ -448,7 +457,7 @@ error_alert(const char* message, status_t status, alert_type type) if (status != B_OK) snprintf(warning, sizeof(warning), "%s:\n\t%s\n", message, strerror(status)); - (new BAlert("FileTypes Request", + (new BAlert(TR("FileTypes Request"), status == B_OK ? message : warning, "Ok", NULL, NULL, B_WIDTH_AS_USUAL, type))->Go(); } diff --git a/src/preferences/filetypes/FileTypesWindow.cpp b/src/preferences/filetypes/FileTypesWindow.cpp index 47ba3dd2dd..18a09dbe23 100644 --- a/src/preferences/filetypes/FileTypesWindow.cpp +++ b/src/preferences/filetypes/FileTypesWindow.cpp @@ -21,7 +21,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -39,6 +41,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "FileType Window" + + const uint32 kMsgTypeSelected = 'typs'; const uint32 kMsgAddType = 'atyp'; const uint32 kMsgRemoveType = 'rtyp'; @@ -125,13 +131,13 @@ TypeIconView::Draw(BRect updateRect) switch (IconSource()) { case kNoIcon: - text = "no icon"; + text = TR("no icon"); break; case kApplicationIcon: - text = "(from application)"; + text = TR("(from application)"); break; case kSupertypeIcon: - text = "(from super type)"; + text = TR("(from super type)"); break; default: @@ -160,8 +166,8 @@ void TypeIconView::GetPreferredSize(float* _width, float* _height) { if (_width) { - float a = StringWidth("(from application)"); - float b = StringWidth("(from super type)"); + float a = StringWidth(TR("(from application)")); + float b = StringWidth(TR("(from super type)")); float width = max_c(a, b); if (width < IconSize()) width = IconSize(); @@ -186,7 +192,7 @@ TypeIconView::BitmapRect() const font_height fontHeight; GetFontHeight(&fontHeight); - float width = StringWidth("no icon") + 8.0f; + float width = StringWidth(TR("no icon")) + 8.0f; float height = ceilf(fontHeight.ascent + fontHeight.descent) + 6.0f; float x = (Bounds().Width() - width) / 2.0f; float y = ceilf((IconSize() - fontHeight.ascent - fontHeight.descent) / 2.0f) - 3.0f; @@ -287,37 +293,38 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); - BMenu* menu = new BMenu("File"); + BMenu* menu = new BMenu(TR("File")); BMenuItem* item; - menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS, + menu->AddItem(item = new BMenuItem(TR("New resource file" B_UTF8_ELLIPSIS), NULL, 'N', B_COMMAND_KEY)); item->SetEnabled(false); - BMenu* recentsMenu = BRecentFilesList::NewFileListMenu("Open" B_UTF8_ELLIPSIS, + BMenu* recentsMenu = BRecentFilesList::NewFileListMenu( + TR("Open" B_UTF8_ELLIPSIS), NULL, NULL, be_app, 10, false, NULL, kSignature); item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel)); item->SetShortcut('O', B_COMMAND_KEY); menu->AddItem(item); - menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS, + menu->AddItem(new BMenuItem(TR("Application types" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenApplicationTypesWindow))); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("About FileTypes" B_UTF8_ELLIPSIS, + menu->AddItem(new BMenuItem(TR("About FileTypes" B_UTF8_ELLIPSIS), new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), + menu->AddItem(new BMenuItem(TR("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY)); menu->SetTargetForItems(be_app); menuBar->AddItem(menu); - menu = new BMenu("Settings"); - item = new BMenuItem("Show icons in list", new BMessage(kMsgToggleIcons)); + menu = new BMenu(TR("Settings")); + item = new BMenuItem(TR("Show icons in list"), new BMessage(kMsgToggleIcons)); item->SetMarked(showIcons); item->SetTarget(this); menu->AddItem(item); - item = new BMenuItem("Show recognition rule", new BMessage(kMsgToggleRule)); + item = new BMenuItem(TR("Show recognition rule"), new BMessage(kMsgToggleRule)); item->SetMarked(showRule); item->SetTarget(this); menu->AddItem(item); @@ -331,7 +338,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); - BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS, + BButton* button = new BButton(rect, "add", TR("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType), B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height()); @@ -339,7 +346,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) rect = button->Frame(); rect.OffsetBy(rect.Width() + 8.0f, 0.0f); - fRemoveTypeButton = new BButton(rect, "remove", "Remove", + fRemoveTypeButton = new BButton(rect, "remove", TR("Remove"), new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM); fRemoveTypeButton->ResizeToPreferred(); topView->AddChild(fRemoveTypeButton); @@ -367,7 +374,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) + plainHeight.leading) + 2.0f; BFont font(be_bold_font); - float labelWidth = font.StringWidth("Icon"); + float labelWidth = font.StringWidth(TR("Icon")); font_height boldHeight; font.GetHeight(&boldHeight); @@ -383,7 +390,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f; rect.top -= 2.0f; fIconBox = new BBox(rect); - fIconBox->SetLabel("Icon"); + fIconBox->SetLabel(TR("Icon")); topView->AddChild(fIconBox); innerRect.left = 8.0f; @@ -400,25 +407,25 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) rightRect.left = rect.right + 8.0f; rightRect.right = topView->Bounds().Width() - 8.0f; fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT); - fRecognitionBox->SetLabel("File recognition"); + fRecognitionBox->SetLabel(TR("File recognition")); topView->AddChild(fRecognitionBox); innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f); innerRect.top += ceilf(boldHeight.ascent); - fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL); + fExtensionLabel = new StringView(innerRect, "extension", TR("Extensions:"), NULL); fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT); fExtensionLabel->ResizeToPreferred(); fRecognitionBox->AddChild(fExtensionLabel); innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f; - innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; + innerRect.left = innerRect.right - button->StringWidth(TR("Remove")) - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); - fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS, + fAddExtensionButton = new BButton(innerRect, "add ext", TR("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fAddExtensionButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); - fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove", + fRemoveExtensionButton = new BButton(innerRect, "remove ext", TR("Remove"), new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT); fRecognitionBox->AddChild(fRemoveExtensionButton); @@ -440,7 +447,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) innerRect.top = innerRect.bottom + 10.0f; innerRect.right = fRecognitionBox->Bounds().right - 8.0f; innerRect.bottom = innerRect.top + 20.0f; - fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "", + fRuleControl = new BTextControl(innerRect, "rule", TR("Rule:"), "", new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT); //fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f); @@ -453,13 +460,13 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f; rect.right = rightRect.right; fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - fDescriptionBox->SetLabel("Description"); + fDescriptionBox->SetLabel(TR("Description")); topView->AddChild(fDescriptionBox); innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.bottom = innerRect.top + button->Bounds().Height(); - fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "", + fInternalNameView = new StringView(innerRect, "internal", TR("Internal name:"), "", B_FOLLOW_LEFT_RIGHT); labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f; fInternalNameView->SetDivider(labelWidth); @@ -468,7 +475,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) fDescriptionBox->AddChild(fInternalNameView); innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f); - fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "", + fTypeNameControl = new BTextControl(innerRect, "type", TR("Type name:"), "", new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT); fTypeNameControl->SetDivider(labelWidth); fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); @@ -477,7 +484,7 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) fDescriptionBox->AddChild(fTypeNameControl); innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f); - fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "", + fDescriptionControl = new BTextControl(innerRect, "description", TR("Description:"), "", new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT); fDescriptionControl->SetDivider(labelWidth); fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); @@ -490,26 +497,26 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) rect.bottom = rect.top + ceilf(boldHeight.ascent) + button->Bounds().Height() + 14.0f; fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); - fPreferredBox->SetLabel("Preferred application"); + fPreferredBox->SetLabel(TR("Preferred application")); topView->AddChild(fPreferredBox); innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); innerRect.left = innerRect.right - button->StringWidth( - "Same as" B_UTF8_ELLIPSIS) - 24.0f; + TR("Same as" B_UTF8_ELLIPSIS)) - 24.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fSameAsButton = new BButton(innerRect, "same as", - "Same as" B_UTF8_ELLIPSIS, + TR("Same as" B_UTF8_ELLIPSIS), new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSameAsButton); innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f); - fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS, + fSelectButton = new BButton(innerRect, "select", TR("Select" B_UTF8_ELLIPSIS), new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT); fPreferredBox->AddChild(fSelectButton); menu = new BPopUpMenu("preferred"); - menu->AddItem(item = new BMenuItem("None", + menu->AddItem(item = new BMenuItem(TR("None"), new BMessage(kMsgPreferredAppChosen))); item->SetMarked(true); @@ -531,19 +538,19 @@ FileTypesWindow::FileTypesWindow(const BMessage& settings) rect.bottom = topView->Bounds().Height() - 8.0f; fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); - fAttributeBox->SetLabel("Extra attributes"); + fAttributeBox->SetLabel(TR("Extra attributes")); topView->AddChild(fAttributeBox); innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f); innerRect.top += ceilf(boldHeight.ascent); - innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f; + innerRect.left = innerRect.right - button->StringWidth(TR("Remove")) - 16.0f; innerRect.bottom = innerRect.top + button->Bounds().Height(); fAddAttributeButton = new BButton(innerRect, "add attr", - "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT); + TR("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fAddAttributeButton); innerRect.OffsetBy(0, innerRect.Height() + 4.0f); - fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove", + fRemoveAttributeButton = new BButton(innerRect, "remove attr", TR("Remove"), new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT); fAttributeBox->AddChild(fRemoveAttributeButton); /* @@ -669,7 +676,7 @@ FileTypesWindow::_AdoptPreferredApplication(BMessage* message, bool sameAs) status_t status = fCurrentType.SetPreferredApp(preferred.String()); if (status != B_OK) - error_alert("Could not set preferred application", status); + error_alert(TR("Could not set preferred application"), status); } @@ -863,26 +870,26 @@ FileTypesWindow::MessageReceived(BMessage* message) BAlert* alert; if (fCurrentType.IsSupertypeOnly()) { - alert = new BPrivate::OverrideAlert("FileTypes Request", - "Removing a super type cannot be reverted.\n" + alert = new BPrivate::OverrideAlert(TR("FileTypes Request"), + TR("Removing a super type cannot be reverted.\n" "All file types that belong to this super type " "will be lost!\n\n" "Are you sure you want to do this? To remove the whole " - "group, hold down the Shift key and press \"Remove\".", - "Remove", B_SHIFT_KEY, "Cancel", 0, NULL, 0, + "group, hold down the Shift key and press \"Remove\"."), + TR("Remove"), B_SHIFT_KEY, TR("Cancel"), 0, NULL, 0, B_WIDTH_AS_USUAL, B_STOP_ALERT); } else { - alert = new BAlert("FileTypes Request", - "Removing a file type cannot be reverted.\n" - "Are you sure you want to remove it?", - "Remove", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + alert = new BAlert(TR("FileTypes Request"), + TR("Removing a file type cannot be reverted.\n" + "Are you sure you want to remove it?"), + TR("Remove"), TR("Cancel"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); } if (alert->Go()) break; status_t status = fCurrentType.Delete(); if (status != B_OK) - fprintf(stderr, "Could not remove file type: %s\n", strerror(status)); + fprintf(stderr, TR("Could not remove file type: %s\n"), strerror(status)); break; } @@ -952,7 +959,7 @@ FileTypesWindow::MessageReceived(BMessage* message) // check rule BString parseError; if (BMimeType::CheckSnifferRule(fRuleControl->Text(), &parseError) != B_OK) { - parseError.Prepend("Recognition rule is not valid:\n\n"); + parseError.Prepend(TR("Recognition rule is not valid:\n\n")); error_alert(parseError.String()); } else fCurrentType.SetSnifferRule(fRuleControl->Text()); @@ -988,7 +995,7 @@ FileTypesWindow::MessageReceived(BMessage* message) case kMsgSelectPreferredApp: { BMessage panel(kMsgOpenFilePanel); - panel.AddString("title", "Select preferred application"); + panel.AddString("title", TR("Select preferred application")); panel.AddInt32("message", kMsgPreferredAppOpened); panel.AddMessenger("target", this); @@ -1002,7 +1009,7 @@ FileTypesWindow::MessageReceived(BMessage* message) case kMsgSamePreferredAppAs: { BMessage panel(kMsgOpenFilePanel); - panel.AddString("title", "Select same preferred application as"); + panel.AddString("title", TR("Select same preferred application as")); panel.AddInt32("message", kMsgSamePreferredAppAsOpened); panel.AddMessenger("target", this); diff --git a/src/preferences/filetypes/IconView.cpp b/src/preferences/filetypes/IconView.cpp index 0e216e4269..8ba031014c 100644 --- a/src/preferences/filetypes/IconView.cpp +++ b/src/preferences/filetypes/IconView.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include #include @@ -26,6 +28,11 @@ #include #include + +#undef TR_CONTEXT +#define TR_CONTEXT "Icon View" + + using namespace std; @@ -816,12 +823,16 @@ IconView::MouseDown(BPoint where) menu->SetFont(be_plain_font); bool hasIcon = fHasType ? fSource == kOwnIcon : fIcon != NULL; - if (hasIcon) - menu->AddItem(new BMenuItem("Edit icon" B_UTF8_ELLIPSIS, new BMessage(kMsgEditIcon))); - else - menu->AddItem(new BMenuItem("Add icon" B_UTF8_ELLIPSIS, new BMessage(kMsgAddIcon))); + if (hasIcon) { + menu->AddItem(new BMenuItem(TR("Edit icon" B_UTF8_ELLIPSIS), + new BMessage(kMsgEditIcon))); + } else { + menu->AddItem(new BMenuItem(TR("Add icon" B_UTF8_ELLIPSIS), + new BMessage(kMsgAddIcon))); + } - BMenuItem* item = new BMenuItem("Remove icon", new BMessage(kMsgRemoveIcon)); + BMenuItem* item = new BMenuItem(TR("Remove icon"), + new BMessage(kMsgRemoveIcon)); if (!hasIcon) item->SetEnabled(false); diff --git a/src/preferences/filetypes/Jamfile b/src/preferences/filetypes/Jamfile index c99fa38049..e9d55698bf 100644 --- a/src/preferences/filetypes/Jamfile +++ b/src/preferences/filetypes/Jamfile @@ -25,10 +25,25 @@ Preference FileTypes : PreferredAppMenu.cpp StringView.cpp - : be tracker $(TARGET_LIBSUPC++) + : be tracker $(TARGET_LIBSUPC++) liblocale.so : FileTypes.rdef FileTypes.icons.rdef ; +DoCatalogs FileTypes : + x-vnd.Haiku-FileTypes + : + ApplicationTypeWindow.cpp + AttributeWindow.cpp + ExtensionWindow.cpp + FileTypes.cpp + FileTypeWindow.cpp + FileTypesWindow.cpp + IconView.cpp + NewFileTypeWindow.cpp + PreferredAppMenu.cpp + TypeListWindow.cpp +; + if $(TARGET_PLATFORM) = libbe_test { HaikuInstall install-test-apps : $(HAIKU_APP_TEST_DIR) : FileTypes : tests!apps ; diff --git a/src/preferences/filetypes/NewFileTypeWindow.cpp b/src/preferences/filetypes/NewFileTypeWindow.cpp index 9db8e60bd6..15eae440ef 100644 --- a/src/preferences/filetypes/NewFileTypeWindow.cpp +++ b/src/preferences/filetypes/NewFileTypeWindow.cpp @@ -9,6 +9,8 @@ #include "NewFileTypeWindow.h" #include +#include +#include #include #include #include @@ -19,6 +21,10 @@ #include +#undef TR_CONTEXT +#define TR_CONTEXT "New File Type Window" + + const uint32 kMsgSupertypeChosen = 'sptc'; const uint32 kMsgNewSupertypeChosen = 'nstc'; @@ -28,7 +34,7 @@ const uint32 kMsgAddType = 'atyp'; NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* currentType) - : BWindow(BRect(100, 100, 350, 200), "New file type", B_TITLED_WINDOW, + : BWindow(BRect(100, 100, 350, 200), TR("New file type"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target) { @@ -37,7 +43,7 @@ NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* curren topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); - float labelWidth = be_plain_font->StringWidth("Internal name:") + 2.0f; + float labelWidth = be_plain_font->StringWidth(TR("Internal name:")) + 2.0f; rect.InsetBy(8.0f, 6.0f); fSupertypesMenu = new BPopUpMenu("supertypes"); @@ -61,11 +67,11 @@ NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* curren if (i > 1) fSupertypesMenu->AddSeparatorItem(); } - fSupertypesMenu->AddItem(new BMenuItem("Add new group", + fSupertypesMenu->AddItem(new BMenuItem(TR("Add new group"), new BMessage(kMsgNewSupertypeChosen))); BMenuField* menuField = new BMenuField(rect, "supertypes", - "Group:", fSupertypesMenu); + TR("Group:"), fSupertypesMenu); menuField->SetDivider(labelWidth); menuField->SetAlignment(B_ALIGN_RIGHT); float width, height; @@ -73,7 +79,7 @@ NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* curren menuField->ResizeTo(rect.Width(), height); topView->AddChild(menuField); - fNameControl = new BTextControl(rect, "internal", "Internal name:", "", + fNameControl = new BTextControl(rect, "internal", TR("Internal name:"), "", NULL, B_FOLLOW_LEFT_RIGHT); fNameControl->SetModificationMessage(new BMessage(kMsgNameUpdated)); fNameControl->SetDivider(labelWidth); @@ -91,7 +97,7 @@ NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* curren fNameControl->MoveTo(8.0f, 12.0f + menuField->Bounds().Height()); topView->AddChild(fNameControl); - fAddButton = new BButton(rect, "add", "Add type", new BMessage(kMsgAddType), + fAddButton = new BButton(rect, "add", TR("Add type"), new BMessage(kMsgAddType), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fAddButton->ResizeToPreferred(); fAddButton->MoveTo(Bounds().Width() - 8.0f - fAddButton->Bounds().Width(), @@ -99,7 +105,7 @@ NewFileTypeWindow::NewFileTypeWindow(FileTypesWindow* target, const char* curren fAddButton->SetEnabled(false); topView->AddChild(fAddButton); - BButton* button = new BButton(rect, "cancel", "Cancel", + BButton* button = new BButton(rect, "cancel", TR("Cancel"), new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveTo(fAddButton->Frame().left - 10.0f - button->Bounds().Width(), @@ -128,14 +134,14 @@ NewFileTypeWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgSupertypeChosen: - fAddButton->SetLabel("Add type"); - fNameControl->SetLabel("Internal name:"); + fAddButton->SetLabel(TR("Add type")); + fNameControl->SetLabel(TR("Internal name:")); fNameControl->MakeFocus(true); break; case kMsgNewSupertypeChosen: - fAddButton->SetLabel("Add group"); - fNameControl->SetLabel("Group name:"); + fAddButton->SetLabel(TR("Add group")); + fNameControl->SetLabel(TR("Group name:")); fNameControl->MakeFocus(true); break; @@ -164,13 +170,13 @@ NewFileTypeWindow::MessageReceived(BMessage* message) BMimeType mimeType(type.String()); if (mimeType.IsInstalled()) { - error_alert("This file type already exists."); + error_alert(TR("This file type already exists.")); break; } status_t status = mimeType.Install(); if (status != B_OK) - error_alert("Could not install file type", status); + error_alert(TR("Could not install file type"), status); else { BMessage update(kMsgSelectNewType); update.AddString("type", type.String()); diff --git a/src/preferences/filetypes/PreferredAppMenu.cpp b/src/preferences/filetypes/PreferredAppMenu.cpp index 81548f8409..c94ba5ac32 100644 --- a/src/preferences/filetypes/PreferredAppMenu.cpp +++ b/src/preferences/filetypes/PreferredAppMenu.cpp @@ -15,10 +15,17 @@ #include #include +#include +#include + #include #include +#undef TR_CONTEXT +#define TR_CONTEXT "Preferred App Menu" + + static int compare_menu_items(const void* _a, const void* _b) { @@ -240,13 +247,14 @@ retrieve_preferred_app(BMessage* message, bool sameAs, const char* forType, } if (status != B_OK) { - error_alert("File could not be opened", status, B_STOP_ALERT); + error_alert(TR("File could not be opened"), status, B_STOP_ALERT); return status; } if (!preferred[0]) { - error_alert(sameAs ? "Could not retrieve preferred application of this file." - : "Could not retrieve application signature."); + error_alert(sameAs ? + TR("Could not retrieve preferred application of this file.") + : TR("Could not retrieve application signature.")); return B_ERROR; } @@ -274,13 +282,13 @@ retrieve_preferred_app(BMessage* message, bool sameAs, const char* forType, description[0] = '\0'; char warning[512]; - snprintf(warning, sizeof(warning), "The application \"%s\" does not " - "support this file type.\n" - "Are you sure you want to set it anyway?", + snprintf(warning, sizeof(warning), TR("The application \"%s\" does " + "not support this file type.\n" + "Are you sure you want to set it anyway?"), description[0] ? description : preferred); BAlert* alert = new BAlert("FileTypes Request", warning, - "Set Preferred Application", "Cancel", NULL, B_WIDTH_AS_USUAL, + TR("Set Preferred Application"), "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); if (alert->Go() == 1) return B_ERROR; diff --git a/src/preferences/filetypes/TypeListWindow.cpp b/src/preferences/filetypes/TypeListWindow.cpp index ec75a4b463..aea1f1c8de 100644 --- a/src/preferences/filetypes/TypeListWindow.cpp +++ b/src/preferences/filetypes/TypeListWindow.cpp @@ -8,17 +8,24 @@ #include "TypeListWindow.h" #include +#include +#include #include #include +#undef TR_CONTEXT +#define TR_CONTEXT "TypeListWindow" + + const uint32 kMsgTypeSelected = 'tpsl'; const uint32 kMsgSelected = 'seld'; -TypeListWindow::TypeListWindow(const char* currentType, uint32 what, BWindow* target) - : BWindow(BRect(100, 100, 360, 440), "Choose type", B_MODAL_WINDOW, +TypeListWindow::TypeListWindow(const char* currentType, uint32 what, + BWindow* target) + : BWindow(BRect(100, 100, 360, 440), TR("Choose type"), B_MODAL_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fTarget(target), fWhat(what) @@ -28,15 +35,16 @@ TypeListWindow::TypeListWindow(const char* currentType, uint32 what, BWindow* ta topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); - fSelectButton = new BButton(rect, "select", "Done", + fSelectButton = new BButton(rect, "select", TR("Done"), new BMessage(kMsgSelected), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fSelectButton->ResizeToPreferred(); - fSelectButton->MoveTo(topView->Bounds().right - 8.0f - fSelectButton->Bounds().Width(), + fSelectButton->MoveTo(topView->Bounds().right - 8.0f + - fSelectButton->Bounds().Width(), topView->Bounds().bottom - 8.0f - fSelectButton->Bounds().Height()); fSelectButton->SetEnabled(false); topView->AddChild(fSelectButton); - BButton* button = new BButton(fSelectButton->Frame(), "cancel", "Cancel", + BButton* button = new BButton(fSelectButton->Frame(), "cancel", TR("Cancel"), new BMessage(B_CANCEL), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); button->ResizeToPreferred(); button->MoveBy(-button->Bounds().Width() - 8.0f, 0.0f);