From 504f70a6e1f46a849989435584fe7de980b3f415 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 4 Nov 2011 05:22:05 +0000 Subject: [PATCH] Change the text and button label of the activate button on Tracker dialogs that appear when you try to rename or move an important system folder such as 'system' or 'config' from the generic (and a little non-standard) 'Do It' to a proper verb such as 'Rename' or 'Move'. I take localization into account, there are now 3 different variables that need to be translated, first is %ifYouDoAction which is the action verb in one form, second is %toDoAction which is the action verb but in a different form, and third is %toConfirmAction which is the text that appears on the button label itself. Although in English there is no distinction between %ifYouDoAction and %toDoAction (both use the same verb e.g. rename) there is a distinction in other languages such as German. Comments are provided in English and German using B_TRANSLATE_COMMENT as a help for translators. I had some help from DeadYak and Humdinger getting the German translations right since I only speak English (thanks guys). Humdinger also directed me to the verb form translation issue in the first place. I also removed the OSNAME macro and just use 'Haiku' instead since we aren't maintaining an OpenTracker port for BeOS anymore. Ingo aka bonefish indicated that this change could be a bit of a problem for distributions (were there any) but if we actually wanted to support distributions we'd want to use a global OSNAME macro somewhere else as I am sure the word 'Haiku' must appear in the source in other places. Closes #7767 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43175 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/FSUtils.cpp | 72 ++++++++++++++++++++------------- src/kits/tracker/FSUtils.h | 3 +- src/kits/tracker/InfoWindow.cpp | 25 +++++++++--- src/kits/tracker/TextWidget.cpp | 10 ++++- 4 files changed, 72 insertions(+), 38 deletions(-) diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index 1af1220c2d..a213147687 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -135,12 +135,6 @@ bool DirectoryMatches(const BEntry *, const char *additionalPath, status_t empty_trash(void *); -#ifdef __HAIKU__ - #define OS_NAME "Haiku" -#else - #define OS_NAME "BeOS" -#endif - static const char* kDeleteConfirmationStr = B_TRANSLATE_MARK("Are you sure you want to delete the " @@ -612,8 +606,9 @@ enum { bool -ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction, - const char *toDoAction, bool dontAsk, int32 *confirmedAlready) +ConfirmChangeIfWellKnownDirectory(const BEntry *entry, + const char *ifYouDoAction, const char *toDoAction, + const char *toConfirmAction, bool dontAsk, int32 *confirmedAlready) { // Don't let the user casually move/change important files/folders // @@ -638,21 +633,22 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction if (DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY)) { warning.SetTo( B_TRANSLATE("If you %ifYouDoAction the system folder or its " - "contents, you won't be able to boot " OS_NAME "! Are you sure you " - "want to do this? To %toDoAction the system folder or its contents " - "anyway, hold down the Shift key and click \"Do it\".")); + "contents, you won't be able to boot Haiku! Are you sure you " + "want to do this? To %toDoAction the system folder or its " + "contents anyway, hold down the Shift key and click " + "\"%toConfirmAction\".")); } else if (DirectoryMatches(entry, B_COMMON_DIRECTORY)) { warning.SetTo( - B_TRANSLATE("If you %ifYouDoAction the common folder, " OS_NAME - " may not behave properly! Are you sure you want to do this? " + B_TRANSLATE("If you %ifYouDoAction the common folder, Haiku " + "may not behave properly! Are you sure you want to do this? " "To %toDoAction the common folder anyway, hold down the " - "Shift key and click \"Do it\".")); + "Shift key and click \"%toConfirmAction\".")); } else if (DirectoryMatches(entry, B_USER_DIRECTORY)) { warning .SetTo( - B_TRANSLATE("If you %ifYouDoAction the home folder, " OS_NAME - " may not behave properly! Are you sure you want to do this? " + B_TRANSLATE("If you %ifYouDoAction the home folder, Haiku " + "may not behave properly! Are you sure you want to do this? " "To %toDoAction the home folder anyway, hold down the " - "Shift key and click \"Do it\".")); + "Shift key and click \"%toConfirmAction\".")); } else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY) || DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) { @@ -661,22 +657,25 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction || DirectoryMatchesOrContains(entry, "beos_mime", B_COMMON_SETTINGS_DIRECTORY)) { warning.SetTo( - B_TRANSLATE("If you %ifYouDoAction the mime settings, " OS_NAME - " may not behave properly! Are you sure you want to do this? " - "To %toDoAction the mime settings anyway, click \"Do it\".")); + B_TRANSLATE("If you %ifYouDoAction the mime settings, Haiku " + "may not behave properly! Are you sure you want to do this? " + "To %toDoAction the mime settings anyway, click " + "\"%toConfirmAction\".")); requireOverride = false; } else if (DirectoryMatches(entry, B_USER_CONFIG_DIRECTORY)) { warning.SetTo( - B_TRANSLATE("If you %ifYouDoAction the config folder, " OS_NAME - " may not behave properly! Are you sure you want to do this? " - "To %toDoAction the config folder anyway, click \"Do it\".")); + B_TRANSLATE("If you %ifYouDoAction the config folder, Haiku " + "may not behave properly! Are you sure you want to do this? " + "To %toDoAction the config folder anyway, click " + "\"%toConfirmAction\".")); requireOverride = false; } else if (DirectoryMatches(entry, B_USER_SETTINGS_DIRECTORY) || DirectoryMatches(entry, B_COMMON_SETTINGS_DIRECTORY)) { warning.SetTo( - B_TRANSLATE("If you %ifYouDoAction the settings folder, " OS_NAME - " may not behave properly! Are you sure you want to do this? " - "To %toDoAction the settings folder anyway, click \"Do it\".")); + B_TRANSLATE("If you %ifYouDoAction the settings folder, Haiku " + "may not behave properly! Are you sure you want to do this? " + "To %toDoAction the settings folder anyway, click " + "\"%toConfirmAction\".")); requireOverride = false; } } @@ -694,9 +693,18 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction warning.ReplaceFirst("%ifYouDoAction", ifYouDoAction); warning.ReplaceFirst("%toDoAction", toDoAction); + warning.ReplaceFirst("%toConfirmAction", + BString(toConfirmAction).Capitalize().String()); + warning.ReplaceLast("%toConfirmAction", + BString(toConfirmAction).Capitalize().String()); + + BString buttonLabel(B_TRANSLATE_COMMENT("%toConfirmAction", + "Action label for the button, e.g. Rename")); + buttonLabel.ReplaceFirst("%toConfirmAction", + BString(toConfirmAction).Capitalize().String()); OverrideAlert *alert = new OverrideAlert("", warning.String(), - B_TRANSLATE("Do it"), (requireOverride ? B_SHIFT_KEY : 0), + buttonLabel.String(), (requireOverride ? B_SHIFT_KEY : 0), B_TRANSLATE("Cancel"), 0, NULL, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(1, B_ESCAPE); if (alert->Go() == 1) { @@ -756,8 +764,14 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode, } if (moveMode == kMoveSelectionTo && !ConfirmChangeIfWellKnownDirectory(&entry, - B_TRANSLATE_COMMENT("move", "As in 'If you move ...'"), - B_TRANSLATE_COMMENT("move", "As in 'To move ...'"), + B_TRANSLATE_COMMENT("move", + "As in 'if you move this folder...' (en) " + "'Wird dieser Ordner verschoben...' (de)"), + B_TRANSLATE_COMMENT("move", + "As in 'to move this folder...' (en) " + "Um diesen Ordner zu verschieben...' (de)"), + B_TRANSLATE_COMMENT("move", + "Button label, 'Move' (en), 'Verschieben' (de)"), false, &askOnceOnly)) { return B_ERROR; } diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h index eb359028b2..d033e0be2b 100644 --- a/src/kits/tracker/FSUtils.h +++ b/src/kits/tracker/FSUtils.h @@ -247,7 +247,8 @@ bool FSIsDeskDir(const BEntry *); // the second one in the "To do action" sentence. bool ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction, const char *toDoAction, - bool dontAsk = false, int32 *confirmedAlready = NULL); + const char *toConfirmAction, bool dontAsk = false, + int32 *confirmedAlready = NULL); bool CheckDevicesEqual(const entry_ref *entry, const Model *targetModel); diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index ade064c560..d164af3f61 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -433,8 +433,14 @@ BInfoWindow::MessageReceived(BMessage *message) BEntry entry(fModel->EntryRef()); if (!fModel->HasLocalizedName() && ConfirmChangeIfWellKnownDirectory(&entry, - B_TRANSLATE_COMMENT("rename", "As in 'If you rename ...'"), - B_TRANSLATE_COMMENT("rename", "As in 'To rename ...'"))) + B_TRANSLATE_COMMENT("rename", + "As in 'if you rename this folder...' (en) " + "'Wird dieser Ordner umbenannt...' (de)"), + B_TRANSLATE_COMMENT("rename", + "As in 'to rename this folder...' (en) " + "'Um diesen Ordner umzubenennen...' (de)"), + B_TRANSLATE_COMMENT("rename", + "Button label, 'Rename' (en), 'Umbenennen' (de)"))); fAttributeView->BeginEditingTitle(); break; } @@ -799,7 +805,8 @@ BInfoWindow::OpenFilePanel(const entry_ref *ref) if (fFilePanel != NULL) { fFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select")); fFilePanel->Window()->ResizeTo(500, 300); - BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:", "File dialog title for new sym link")); + BString title(B_TRANSLATE_COMMENT("Link \"%name\" to:", + "File dialog title for new sym link")); title.ReplaceFirst("%name", fModel->Name()); fFilePanel->Window()->SetTitle(title.String()); fFilePanel->Show(); @@ -1223,9 +1230,15 @@ AttributeView::MouseDown(BPoint point) } else if (fTitleRect.Contains(point)) { if (!fModel->HasLocalizedName() && ConfirmChangeIfWellKnownDirectory(&entry, - B_TRANSLATE_COMMENT("rename", "As in 'If you rename ...'"), - B_TRANSLATE_COMMENT("rename", "As in 'To rename ...'"), true) - && fTitleEditView == 0) + B_TRANSLATE_COMMENT("rename", + "As in 'if you rename this folder...' (en) " + "'Wird dieser Ordner umbenannt...' (de)"), + B_TRANSLATE_COMMENT("rename", + "As in 'to rename this folder...' (en) " + "'Um diesen Ordner umzubenennen...' (de)"), + B_TRANSLATE_COMMENT("rename", + "Button label, 'Rename' (en), 'Umbenennen' (de)"), true) + && fTitleEditView == 0); BeginEditingTitle(); } else if (fTitleEditView) { FinishEditingTitle(true); diff --git a/src/kits/tracker/TextWidget.cpp b/src/kits/tracker/TextWidget.cpp index 8a47fcf9e0..6ebeb1abbd 100644 --- a/src/kits/tracker/TextWidget.cpp +++ b/src/kits/tracker/TextWidget.cpp @@ -324,8 +324,14 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) BEntry entry(pose->TargetModel()->EntryRef()); if (entry.InitCheck() == B_OK && !ConfirmChangeIfWellKnownDirectory(&entry, - B_TRANSLATE_COMMENT("rename", "As in 'If you rename ...'"), - B_TRANSLATE_COMMENT("rename", "As in 'To rename ...'"))) + B_TRANSLATE_COMMENT("rename", + "As in 'if you rename this folder...' (en) " + "'Wird dieser Ordner umbenannt...' (de)"), + B_TRANSLATE_COMMENT("rename", + "As in 'to rename this folder...' (en) " + "'Um diesen Ordner umzubenennen...' (de)"), + B_TRANSLATE_COMMENT("rename", + "Button label, 'Rename' (en), 'Umbenennen' (de)"))) return; // get bounds with full text length