Author: siarzhuk Date: 2011-03-17 21:25:44 +0100 (Thu, 17 Mar 2011) New Revision: 40991 Changeset: https://dev.haiku-os.org/changeset/40991 Ticket: https://dev.haiku-os.org/ticket/7072 Ticket: https://dev.haiku-os.org/ticket/7363 Modified: haiku/trunk/headers/os/interface/Dragger.h haiku/trunk/src/kits/interface/Dragger.cpp haiku/trunk/src/kits/interface/Menu.cpp haiku/trunk/src/kits/interface/PrintJob.cpp haiku/trunk/src/kits/interface/ZombieReplicantView.cpp haiku/trunk/src/kits/locale/Jamfile Log: Localization of some UI parts: - context menu of the replicant dragger. Fixes #7363; - default <empty> menu placeholder. Fixes #7072; - other messages used in PrintJob, Dragger and ZombieReplicantView classes. Modified: haiku/trunk/headers/os/interface/Dragger.h =================================================================== --- haiku/trunk/headers/os/interface/Dragger.h 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/headers/os/interface/Dragger.h 2011-03-17 20:25:44 UTC (rev 40991) @@ -89,6 +89,7 @@ BDragger& operator=(const BDragger& other); + void _InitData(); void _AddToList(); void _RemoveFromList(); status_t _DetermineRelationship(); Modified: haiku/trunk/src/kits/interface/Dragger.cpp =================================================================== --- haiku/trunk/src/kits/interface/Dragger.cpp 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/src/kits/interface/Dragger.cpp 2011-03-17 20:25:44 UTC (rev 40991) @@ -18,7 +18,9 @@ #include <Alert.h> #include <Beep.h> #include <Bitmap.h> +#include <Catalog.h> #include <Dragger.h> +#include <LocaleBackend.h> #include <MenuItem.h> #include <Message.h> #include <PopUpMenu.h> @@ -35,7 +37,16 @@ #include "ZombieReplicantView.h" +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Dragger" + +#undef B_TRANSLATE +#define B_TRANSLATE(str) \ + gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Dragger") + const uint32 kMsgDragStarted = 'Drgs'; const unsigned char @@ -114,8 +125,7 @@ fPopUpIsCustom(false), fPopUp(NULL) { - fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); - fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); + _InitData(); } @@ -132,8 +142,7 @@ { data->FindInt32("_rel", (int32 *)&fRelation); - fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); - fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); + _InitData(); BMessage popupMsg; if (data->FindMessage("_popup", &popupMsg) == B_OK) { @@ -292,10 +301,10 @@ if (fShelf != NULL) Window()->PostMessage(kDeleteReplicant, fTarget, NULL); else { - (new BAlert("??", - "Can't delete this replicant from its original " - "application. Life goes on.", - "OK", NULL, NULL, B_WIDTH_FROM_WIDEST, + (new BAlert(B_TRANSLATE("Warning"), + B_TRANSLATE("Can't delete this replicant from its original " + "application. Life goes on."), + B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT))->Go(NULL); } break; @@ -616,6 +625,19 @@ void +BDragger::_InitData() +{ + fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); + fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); + + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); +} + + +void BDragger::_AddToList() { DraggerManager* manager = DraggerManager::Default(); @@ -722,12 +744,12 @@ if (name) msg->AddString("target", name); - char about[B_OS_NAME_LENGTH]; - snprintf(about, B_OS_NAME_LENGTH, "About %s" B_UTF8_ELLIPSIS, name); + BString about(B_TRANSLATE("About %app"B_UTF8_ELLIPSIS)); + about.ReplaceFirst("%app", name); - fPopUp->AddItem(new BMenuItem(about, msg)); + fPopUp->AddItem(new BMenuItem(about.String(), msg)); fPopUp->AddSeparatorItem(); - fPopUp->AddItem(new BMenuItem("Remove replicant", + fPopUp->AddItem(new BMenuItem(B_TRANSLATE("Remove replicant"), new BMessage(kDeleteReplicant))); } Modified: haiku/trunk/src/kits/interface/Menu.cpp =================================================================== --- haiku/trunk/src/kits/interface/Menu.cpp 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/src/kits/interface/Menu.cpp 2011-03-17 20:25:44 UTC (rev 40991) @@ -17,12 +17,14 @@ #include <string.h> #include <Bitmap.h> +#include <Catalog.h> #include <ControlLook.h> #include <Debug.h> #include <File.h> #include <FindDirectory.h> #include <Layout.h> #include <LayoutUtils.h> +#include <LocaleBackend.h> #include <MenuBar.h> #include <MenuItem.h> #include <Messenger.h> @@ -44,6 +46,17 @@ #define USE_CACHED_MENUWINDOW 1 +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Menu" + +#undef B_TRANSLATE +#define B_TRANSLATE(str) \ + gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Menu") + + using std::nothrow; using BPrivate::BMenuWindow; @@ -180,6 +193,7 @@ }; +// note: this is redefined to localized one in BMenu::_InitData const char* BPrivate::kEmptyMenuLabel = "<empty>"; @@ -1396,6 +1410,13 @@ void BMenu::_InitData(BMessage* archive) { + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); + + BPrivate::kEmptyMenuLabel = B_TRANSLATE("<empty>"); + // TODO: Get _color, _fname, _fflt from the message, if present BFont font; font.SetFamilyAndStyle(sMenuInfo.f_family, sMenuInfo.f_style); Modified: haiku/trunk/src/kits/interface/PrintJob.cpp =================================================================== --- haiku/trunk/src/kits/interface/PrintJob.cpp 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/src/kits/interface/PrintJob.cpp 2011-03-17 20:25:44 UTC (rev 40991) @@ -19,10 +19,12 @@ #include <Alert.h> #include <Application.h> #include <Button.h> +#include <Catalog.h> #include <Debug.h> #include <Entry.h> #include <File.h> #include <FindDirectory.h> +#include <LocaleBackend.h> #include <Messenger.h> #include <NodeInfo.h> #include <OS.h> @@ -34,7 +36,17 @@ #include <pr_server.h> #include <ViewPrivate.h> +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "PrintJob" + +#undef B_TRANSLATE +#define B_TRANSLATE(str) \ + gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "PrintJob") + + /*! Summary of spool file: |-----------------------------------| @@ -92,7 +104,7 @@ static void ShowError(const char* message) { - BAlert* alert = new BAlert("Error", message, "OK"); + BAlert* alert = new BAlert(B_TRANSLATE("Error"), message, B_TRANSLATE("OK")); alert->Go(); } @@ -158,6 +170,11 @@ fCurrentPageHeader = new _page_header_; if (fCurrentPageHeader != NULL) memset(fCurrentPageHeader, 0, sizeof(_page_header_)); + + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); } @@ -282,7 +299,7 @@ return; if (fSpoolFileHeader.page_count == 0) { - ShowError("No Pages to print!"); + ShowError(B_TRANSLATE("No Pages to print!")); CancelJob(); return; } @@ -843,7 +860,7 @@ BMessenger printServer; if (messenger->GetPrintServerMessenger(printServer) != B_OK) { - ShowError("Print Server is not responding."); + ShowError(B_TRANSLATE("Print Server is not responding.")); messenger->SetResult(NULL); return B_ERROR; } Modified: haiku/trunk/src/kits/interface/ZombieReplicantView.cpp =================================================================== --- haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/src/kits/interface/ZombieReplicantView.cpp 2011-03-17 20:25:44 UTC (rev 40991) @@ -7,8 +7,11 @@ */ #include <Alert.h> +#include <Catalog.h> +#include <LocaleBackend.h> #include <Message.h> #include <MimeType.h> +#include <String.h> #include "ZombieReplicantView.h" @@ -17,8 +20,17 @@ #include <string.h> #include <new> +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "ZombieReplicantView" +#undef B_TRANSLATE +#define B_TRANSLATE(str) \ + gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView") + + _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error) : BBox(frame, "<Zombie>", B_FOLLOW_NONE, B_WILL_DRAW), @@ -28,6 +40,11 @@ font.SetSize(9.0f); // TODO SetFont(&font); SetViewColor(kZombieColor); + + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reach liblocale.so + if (gLocaleBackend == NULL) + LocaleBackend::LoadBackend(); } @@ -43,23 +60,23 @@ case B_ABOUT_REQUESTED: { const char* addOn = NULL; - char error[1024]; + BString error; if (fArchive->FindString("add_on", &addOn) == B_OK) { char description[B_MIME_TYPE_LENGTH] = ""; BMimeType type(addOn); type.GetShortDescription(description); - snprintf(error, sizeof(error), - "Cannot create the replicant for \"%s\". (%s)", - description, strerror(fError)); - } else { - snprintf(error, sizeof(error), - "Cannot locate the application for the replicant. " - "No application signature supplied. (%s)", strerror(fError)); - } - + error = B_TRANSLATE("Cannot create the replicant for " + "\"%description\".\n%error"); + error.ReplaceFirst("%description", description); + } else + error = B_TRANSLATE("Cannot locate the application for the " + "replicant. No application signature supplied.\n%error)"); + + error.ReplaceFirst("%error", strerror(fError)); - BAlert* alert = new (std::nothrow) BAlert("Error", error, "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new (std::nothrow) BAlert(B_TRANSLATE("Error"), + error.String(), B_TRANSLATE("OK"), NULL, NULL, + B_WIDTH_AS_USUAL, B_STOP_ALERT); if (alert != NULL) alert->Go(); Modified: haiku/trunk/src/kits/locale/Jamfile =================================================================== --- haiku/trunk/src/kits/locale/Jamfile 2011-03-17 14:20:02 UTC (rev 40990) +++ haiku/trunk/src/kits/locale/Jamfile 2011-03-17 20:25:44 UTC (rev 40991) @@ -68,13 +68,21 @@ SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; SEARCH on [ FGristFiles TextView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; - +SEARCH on [ FGristFiles Dragger.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles Menu.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles PrintJob.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles ZombieReplicantView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; + DoCatalogs liblocale.so : system : AboutMenuItem.cpp AboutWindow.cpp ColorControl.cpp + Dragger.cpp + Menu.cpp + PrintJob.cpp StringForSize.cpp TextView.cpp + ZombieReplicantView.cpp ;