From 757e70593ce141fee4777aab3c3d8c097ce2faaa Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Fri, 2 Jul 2010 13:03:33 +0000 Subject: [PATCH] * Patch by Jorma Karvonnen updated by me : localize NetworkStatus * Fix a small bug in LocaleRoster : a / was left out in the mimesignature. Didn't cause any harm, but it's cleaner this way. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37337 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/networkstatus/Jamfile | 11 ++- src/apps/networkstatus/NetworkStatus.cpp | 19 +++-- src/apps/networkstatus/NetworkStatusView.cpp | 72 ++++++++++++++----- .../networkstatus/NetworkStatusWindow.cpp | 9 ++- src/kits/locale/LocaleRoster.cpp | 1 + 5 files changed, 84 insertions(+), 28 deletions(-) diff --git a/src/apps/networkstatus/Jamfile b/src/apps/networkstatus/Jamfile index a4d9effcc4..4e682060ff 100644 --- a/src/apps/networkstatus/Jamfile +++ b/src/apps/networkstatus/Jamfile @@ -14,6 +14,15 @@ Application NetworkStatus : NetworkStatusWindow.cpp NetworkStatusView.cpp NetworkStatus.cpp - : be $(icon_libs) $(TARGET_NETWORK_LIBS) $(TARGET_LIBSUPC++) + : be $(HAIKU_LOCALE_LIBS) $(icon_libs) $(TARGET_NETWORK_LIBS) + $(TARGET_LIBSUPC++) : NetworkStatus.rdef NetworkStatusIcons.rdef ; + +DoCatalogs NetworkStatus : + x-vnd.Haiku-NetworkStatus + : + NetworkStatus.cpp + NetworkStatusWindow.cpp + NetworkStatusView +; diff --git a/src/apps/networkstatus/NetworkStatus.cpp b/src/apps/networkstatus/NetworkStatus.cpp index 5c35c53509..49baf0e59b 100644 --- a/src/apps/networkstatus/NetworkStatus.cpp +++ b/src/apps/networkstatus/NetworkStatus.cpp @@ -13,14 +13,20 @@ #include #include +#include #include #include +#include #include #include #include +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "NetworkStatus" + + class NetworkStatus : public BApplication { public: NetworkStatus(); @@ -80,9 +86,10 @@ NetworkStatus::ArgvReceived(int32 argc, char** argv) if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) { - printf("NetworkStatus options:\n"); - printf(" --deskbar automatically add replicant to Deskbar\n"); - printf(" --help print this info and exit\n"); + const char* str = B_TRANSLATE("NetworkStatus options:\n" + "\t--deskbar\tautomatically add replicant to Deskbar\n" + "\t--help\t\tprint this info and exit\n"); + printf(str); fQuitImmediately = true; return; } @@ -144,9 +151,9 @@ NetworkStatus::ReadyToRun() } if (isDeskbarRunning && !isInstalled) { - BAlert* alert = new BAlert("", "Do you want NetworkStatus to live in " - "the Deskbar?", "Don't", "Install", NULL, B_WIDTH_AS_USUAL, - B_WARNING_ALERT); + BAlert* alert = new BAlert("", B_TRANSLATE("Do you want NetworkStatus " + "to live in the Deskbar?"), B_TRANSLATE("Don't"), + B_TRANSLATE("Install"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go() == 1) { diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp index b10ea22fef..df28cc2162 100644 --- a/src/apps/networkstatus/NetworkStatusView.cpp +++ b/src/apps/networkstatus/NetworkStatusView.cpp @@ -22,11 +22,13 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -41,12 +43,16 @@ #include "NetworkStatusIcons.h" +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "NetworkStatusView" + + static const char *kStatusDescriptions[] = { - "Unknown", - "No link", - "No stateful configuration", - "Configuring", - "Ready" + B_TRANSLATE_MARK("Unknown"), + B_TRANSLATE_MARK("No link"), + B_TRANSLATE_MARK("No stateful configuration"), + B_TRANSLATE_MARK("Configuring"), + B_TRANSLATE_MARK("Ready") }; extern "C" _EXPORT BView *instantiate_deskbar_item(void); @@ -314,8 +320,16 @@ NetworkStatusView::_ShowConfiguration(BMessage* message) if (!_PrepareRequest(request, name)) return; - BString text = name; - text += " information:\n"; + BString text = NULL; + if (strncmp("Address", name, strlen(name)) == 0) + text = B_TRANSLATE("Address information:\n"); + + if (strncmp("Broadcast", name, strlen(name)) == 0) + text = B_TRANSLATE("Broadcast information:\n"); + + if (strncmp("Netmask", name, strlen(name)) == 0) + text = B_TRANSLATE("Netmask information:\n"); + size_t boldLength = text.Length(); for (int i = 0; kInformationEntries[i].label; i++) { @@ -341,12 +355,24 @@ NetworkStatusView::_ShowConfiguration(BMessage* message) } text += "\n"; - text += kInformationEntries[i].label; + + if (strncmp("Address", kInformationEntries[i].label, + strlen(kInformationEntries[i].label)) == 0) + text += B_TRANSLATE("Address"); + + if (strncmp("Broadcast", kInformationEntries[i].label, + strlen(kInformationEntries[i].label)) == 0) + text += B_TRANSLATE("Broadcast"); + + if (strncmp("Netmask", kInformationEntries[i].label, + strlen(kInformationEntries[i].label)) == 0) + text += B_TRANSLATE("Netmask"); + text += ": "; text += address; } - BAlert* alert = new BAlert(name, text.String(), "OK"); + BAlert* alert = new BAlert(name, text.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; @@ -380,13 +406,16 @@ NetworkStatusView::MouseDown(BPoint point) } menu->AddSeparatorItem(); - //menu->AddItem(new BMenuItem("About NetworkStatus" B_UTF8_ELLIPSIS, - // new BMessage(B_ABOUT_REQUESTED))); - menu->AddItem(new BMenuItem("Open network preferences" B_UTF8_ELLIPSIS, + //menu->AddItem(new BMenuItem(B_TRANSLATE( + // "About NetworkStatus" B_UTF8_ELLIPSIS), + // new BMessage(B_ABOUT_REQUESTED))); + menu->AddItem(new BMenuItem(B_TRANSLATE( + "Open network preferences" B_UTF8_ELLIPSIS), new BMessage(kMsgOpenNetworkPreferences))); if (fInDeskbar) - menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); + menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), + new BMessage(B_QUIT_REQUESTED))); menu->SetTargetForItems(this); ConvertToScreen(&point); @@ -397,9 +426,14 @@ NetworkStatusView::MouseDown(BPoint point) void NetworkStatusView::_AboutRequested() { - BAlert* alert = new BAlert("about", "NetworkStatus\n" - "\twritten by Axel Dörfler and Hugo Santos\n" - "\tCopyright 2007, Haiku, Inc.\n", "OK"); + BString _about = B_TRANSLATE( + "NetworkStatus\n\twritten by %1 and Hugo Santos\n\t%2, Haiku, Inc.\n" + ); + _about.ReplaceFirst("%1", "Axel Dörfler"); + // Append a new developer here + _about.ReplaceFirst("%2", "Copyright 2007-2010"); + // Append a new year here + BAlert* alert = new BAlert("about", _about, B_TRANSLATE("OK")); BTextView *view = alert->TextView(); BFont font; @@ -512,11 +546,11 @@ NetworkStatusView::_OpenNetworksPreferences() { status_t status = be_roster->Launch("application/x-vnd.Haiku-Network"); if (status != B_OK && status != B_ALREADY_RUNNING) { - BString errorMessage("Launching the network preflet failed.\n\n" - "Error: "); + BString errorMessage(B_TRANSLATE("Launching the network preflet " + "failed.\n\nError: ")); errorMessage << strerror(status); BAlert* alert = new BAlert("launch error", errorMessage.String(), - "OK"); + B_TRANSLATE("OK")); // asynchronous alert in order to not block replicant host application alert->Go(NULL); diff --git a/src/apps/networkstatus/NetworkStatusWindow.cpp b/src/apps/networkstatus/NetworkStatusWindow.cpp index e57056f19b..6864f3d04e 100644 --- a/src/apps/networkstatus/NetworkStatusWindow.cpp +++ b/src/apps/networkstatus/NetworkStatusWindow.cpp @@ -11,11 +11,16 @@ #include "NetworkStatusView.h" #include +#include +#include + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "NetworkStatusWindow" NetworkStatusWindow::NetworkStatusWindow() - : BWindow(BRect(150, 150, 249, 249), "NetworkStatus", B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) + : BWindow(BRect(150, 150, 249, 249), B_TRANSLATE("NetworkStatus"), + B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS) { BView* topView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index 4038c59d48..f93e1d36d3 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -461,6 +461,7 @@ BLocaleRoster::GetCatalog(BCatalog* catalog, vint32* catalogInitStatus) char* stripSignature = objectSignature; while(*stripSignature != '/') stripSignature ++; + stripSignature ++; log_team(LOG_DEBUG, "Image %s (address %x) requested catalog with mimetype %s",