From f86acdc207e02e0a50e35b0622d510bf69700f32 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 29 Oct 2011 14:44:13 +0000 Subject: [PATCH] Patch by Karvjorm: localize Login. Fixes #7234. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42951 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/login/DesktopWindow.cpp | 10 +++++++-- src/apps/login/Jamfile | 10 ++++++++- src/apps/login/LoginApp.cpp | 36 ++++++++++++++++++-------------- src/apps/login/LoginView.cpp | 22 +++++++++++-------- src/apps/login/LoginWindow.cpp | 7 ++++++- 5 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/apps/login/DesktopWindow.cpp b/src/apps/login/DesktopWindow.cpp index 512a1bb394..aa9b95cb56 100644 --- a/src/apps/login/DesktopWindow.cpp +++ b/src/apps/login/DesktopWindow.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -17,13 +18,16 @@ #include "LoginApp.h" #include "DesktopWindow.h" +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Desktop Window" + const window_feel kPrivateDesktopWindowFeel = window_feel(1024); const window_look kPrivateDesktopWindowLook = window_look(4); // this is a mirror of an app server private values DesktopWindow::DesktopWindow(BRect frame, bool editMode) - : BWindow(frame, "Desktop", + : BWindow(frame, B_TRANSLATE("Desktop"), kPrivateDesktopWindowLook, kPrivateDesktopWindowFeel, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE @@ -71,7 +75,9 @@ DesktopWindow::QuitRequested() { status_t err; err = fDesktopShelf->Save(); - printf("error %s\n", strerror(err)); + printf(B_TRANSLATE_COMMENT("error %s\n", + "A return message from fDesktopShelf->Save(). It can be \"B_OK\""), + strerror(err)); return BWindow::QuitRequested(); } diff --git a/src/apps/login/Jamfile b/src/apps/login/Jamfile index 08f782d020..9c15dea930 100644 --- a/src/apps/login/Jamfile +++ b/src/apps/login/Jamfile @@ -19,7 +19,15 @@ Application Login : LoginWindow.cpp LoginView.cpp main.cpp - : be tracker $(mu_libs) $(TARGET_LIBSTDC++) + : be tracker $(mu_libs) $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS) : Login.rdef ; +DoCatalogs Login : + x-vnd.Haiku-Login + : + LoginApp.cpp + DesktopWindow.cpp + LoginView.cpp + LoginWindow.cpp +; diff --git a/src/apps/login/LoginApp.cpp b/src/apps/login/LoginApp.cpp index 655c55b7fe..8078417524 100644 --- a/src/apps/login/LoginApp.cpp +++ b/src/apps/login/LoginApp.cpp @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -25,6 +26,8 @@ #include "multiuser_utils.h" #endif +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Login App" const char *kLoginAppSig = "application/x-vnd.Haiku-Login"; @@ -48,11 +51,12 @@ LoginApp::ReadyToRun() BScreen screen; if (fEditShelfMode) { - (new BAlert("Info", "You can customize the desktop shown " - "behind the Login application by dropping replicants onto it.\n" + (new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("You can customize the " + "desktop shown behind the Login application by dropping replicants" + " onto it.\n" "\n" - "When you are finished just quit the application (Alt-Q).", - "OK"))->Go(NULL); + "When you are finished just quit the application (Alt-Q)."), + B_TRANSLATE("OK")))->Go(NULL); } else { BRect frame(0, 0, 400, 150); frame.OffsetBySelf(screen.Frame().Width()/2 - frame.Width()/2, @@ -88,14 +92,15 @@ LoginApp::MessageReceived(BMessage *message) BRoster::Private rosterPrivate(roster); status_t error = rosterPrivate.ShutDown(reboot, false, false); if (error < B_OK) { - BString msg("Error: "); - msg << strerror(error); - (new BAlert("Error", msg.String(), "OK"))->Go(); + BString msg(B_TRANSLATE("Error: %1")); + msg.ReplaceFirst("%1", strerror(error)); + (new BAlert(("Error"), msg.String(), B_TRANSLATE("OK")))->Go(); } break; } case kSuspendAction: - (new BAlert("Error", "Unimplemented", "OK"))->Go(); + (new BAlert(B_TRANSLATE("Error"), B_TRANSLATE("Unimplemented"), + B_TRANSLATE("OK")))->Go(); break; #endif default: @@ -115,11 +120,11 @@ LoginApp::ArgvReceived(int32 argc, char **argv) else if (arg == "--nonmodal") fModalMode = false; else /*if (arg == "--help")*/ { - printf("Login application for Haiku\nUsage:\n"); + printf(B_TRANSLATE("Login application for Haiku\nUsage:\n")); printf("%s [--nonmodal] [--edit]\n", argv[0]); - printf("--nonmodal Do not make the window modal\n"); - printf("--edit Launch in shelf editting mode to " - "allow customizing the desktop.\n"); + printf(B_TRANSLATE("--nonmodal Do not make the window modal\n")); + printf(B_TRANSLATE("--edit Launch in shelf editting mode to " + "allow customizing the desktop.\n")); // just return to the shell exit((arg == "--help") ? 0 : 1); return; @@ -139,7 +144,9 @@ LoginApp::TryLogin(BMessage *message) if (message->FindString("password", &password) < B_OK) password = NULL; err = ValidateLogin(login, password); - printf("ValidateLogin: %s\n", strerror(err)); + printf(B_TRANSLATE_COMMENT("ValidateLogin: %s\n", + "A message returned from the ValidateLogin function. " + "It can be \"B_OK\"."), strerror(err)); if (err == B_OK) { reply.what = kLoginOk; message->SendReply(&reply); @@ -224,6 +231,3 @@ LoginApp::getpty(char *pty, char *tty) return fd; } - - - diff --git a/src/apps/login/LoginView.cpp b/src/apps/login/LoginView.cpp index d0fc6769f1..fe64e7a9d4 100644 --- a/src/apps/login/LoginView.cpp +++ b/src/apps/login/LoginView.cpp @@ -2,6 +2,7 @@ * Copyright 2008, François Revol, . All rights reserved. * Distributed under the terms of the MIT License. */ +#include #include #include #include @@ -14,6 +15,9 @@ #include "LoginApp.h" #include "LoginView.h" +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Login View" + #define LW 120 #define CSEP 15 #define BH 20 @@ -57,19 +61,19 @@ LoginView::LoginView(BRect frame) r.Set(LW + 30, Bounds().top + CSEP, Bounds().right - CSEP, Bounds().top + CSEP + CSEP); - fLoginControl = new BTextControl(r, "login", "Login:", "", + fLoginControl = new BTextControl(r, "login", B_TRANSLATE("Login:"), "", new BMessage(kLoginEdited)); AddChild(fLoginControl); r.OffsetBySelf(0, CSEP + CSEP); - fPasswordControl = new BTextControl(r, "password", "Password:", "", - new BMessage(kPasswordEdited)); + fPasswordControl = new BTextControl(r, "password", + B_TRANSLATE("Password:"), "", new BMessage(kPasswordEdited)); fPasswordControl->TextView()->HideTyping(true); AddChild(fPasswordControl); r.OffsetBySelf(0, CSEP + CSEP); - fHidePasswordCheckBox = new BCheckBox(r, "hidepw", "Hide password", - new BMessage(kHidePassword)); + fHidePasswordCheckBox = new BCheckBox(r, "hidepw", + B_TRANSLATE("Hide password"), new BMessage(kHidePassword)); fHidePasswordCheckBox->SetValue(1); AddChild(fHidePasswordCheckBox); @@ -79,12 +83,12 @@ LoginView::LoginView(BRect frame) buttonWidth, Bounds().bottom); buttonRect.OffsetBySelf(CSEP, -CSEP); - fHaltButton = new BButton(buttonRect, "halt", "Halt", + fHaltButton = new BButton(buttonRect, "halt", B_TRANSLATE("Halt"), new BMessage(kHaltAction)); AddChild(fHaltButton); buttonRect.OffsetBySelf(CSEP + buttonWidth, 0); - fRebootButton = new BButton(buttonRect, "reboot", "Reboot", + fRebootButton = new BButton(buttonRect, "reboot", B_TRANSLATE("Reboot"), new BMessage(kRebootAction)); AddChild(fRebootButton); @@ -93,7 +97,7 @@ LoginView::LoginView(BRect frame) buttonRect.OffsetToSelf(Bounds().Width() - CSEP - buttonWidth, Bounds().Height() - CSEP - BH); - fLoginButton = new BButton(buttonRect, "ok", "OK", + fLoginButton = new BButton(buttonRect, "ok", B_TRANSLATE("OK"), new BMessage(kAttemptLogin)); AddChild(fLoginButton); @@ -175,7 +179,7 @@ LoginView::MessageReceived(BMessage *message) case kLoginBad: fPasswordControl->SetText(""); EnableControls(false); - fInfoView->SetText("Invalid login!"); + fInfoView->SetText(B_TRANSLATE("Invalid login!")); if (Window()) { BPoint savedPos = Window()->Frame().LeftTop(); for (int i = 0; i < 10; i++) { diff --git a/src/apps/login/LoginWindow.cpp b/src/apps/login/LoginWindow.cpp index 7ad89be936..40a7729275 100644 --- a/src/apps/login/LoginWindow.cpp +++ b/src/apps/login/LoginWindow.cpp @@ -4,14 +4,19 @@ */ +#include + #include "LoginWindow.h" #include "LoginView.h" +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Login Window" + #define WINDOW_FEEL B_NORMAL_WINDOW_FEEL //#define WINDOW_FEEL B_FLOATING_ALL_WINDOW_FEEL LoginWindow::LoginWindow(BRect frame) - : BWindow(frame, "Welcome to Haiku", B_TITLED_WINDOW_LOOK, + : BWindow(frame, B_TRANSLATE("Welcome to Haiku"), B_TITLED_WINDOW_LOOK, WINDOW_FEEL, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE |