Patch by Karvjorm: localize Login.

Fixes #7234.


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