Patch by Jorma Karvonen: Localization of the Terminal application. Thanks a lot.

Closes ticket #5850.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-05-06 10:25:48 +00:00
parent 637605788a
commit 8989d8a52e
13 changed files with 139 additions and 87 deletions
+7 -4
View File
@@ -12,10 +12,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <ColorControl.h> #include <ColorControl.h>
#include <GridLayoutBuilder.h> #include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <Locale.h>
#include <Menu.h> #include <Menu.h>
#include <MenuField.h> #include <MenuField.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -26,7 +28,8 @@
#include "PrefHandler.h" #include "PrefHandler.h"
#include "TermConst.h" #include "TermConst.h"
#undef TR_CONTEXT ""
#define TR_CONTEXT "Terminal ApperPrefView"
AppearancePrefView::AppearancePrefView(const char* name, AppearancePrefView::AppearancePrefView(const char* name,
const BMessenger& messenger) const BMessenger& messenger)
@@ -67,9 +70,9 @@ AppearancePrefView::AppearancePrefView(const char* name,
BMenu* sizeMenu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, BMenu* sizeMenu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED,
PrefHandler::Default()->getInt32(PREF_HALF_FONT_SIZE)); PrefHandler::Default()->getInt32(PREF_HALF_FONT_SIZE));
fFont = new BMenuField("Font:", fontMenu); fFont = new BMenuField(TR("Font:"), fontMenu);
fFontSize = new BMenuField("Size:", sizeMenu); fFontSize = new BMenuField(TR("Size:"), sizeMenu);
fColorField = new BMenuField("Color:", fColorField = new BMenuField(TR("Color:"),
_MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
kColorTable[0])); kColorTable[0]));
+5 -1
View File
@@ -9,6 +9,8 @@
#include "Arguments.h" #include "Arguments.h"
#include <Catalog.h>
#include <Locale.h>
Arguments::Arguments(int defaultArgsNum, const char * const *defaultArgs) Arguments::Arguments(int defaultArgsNum, const char * const *defaultArgs)
: fUsageRequested(false), : fUsageRequested(false),
@@ -28,6 +30,8 @@ Arguments::~Arguments()
_SetShellArguments(0, NULL); _SetShellArguments(0, NULL);
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal arguments parsing"
void void
Arguments::Parse(int argc, const char *const *argv) Arguments::Parse(int argc, const char *const *argv)
@@ -75,7 +79,7 @@ Arguments::Parse(int argc, const char *const *argv)
argi++; argi++;
} else { } else {
// illegal option // illegal option
fprintf(stderr, "Unrecognized option \"%s\"\n", arg); fprintf(stderr, TR("Unrecognized option \"%s\"\n"), arg);
fUsageRequested = true; fUsageRequested = true;
} }
+11 -7
View File
@@ -10,11 +10,13 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <GridLayoutBuilder.h> #include <GridLayoutBuilder.h>
#include <GroupLayout.h> #include <GroupLayout.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <String.h> #include <String.h>
#include <TextControl.h> #include <TextControl.h>
@@ -24,11 +26,13 @@ const uint32 MSG_FIND_HIDE = 'Fhid';
const uint32 TOGGLE_FIND_CONTROL = 'MTFG'; const uint32 TOGGLE_FIND_CONTROL = 'MTFG';
const BRect kWindowFrame(10, 30, 250, 200); const BRect kWindowFrame(10, 30, 250, 200);
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal FindWindow"
FindWindow::FindWindow(BMessenger messenger, const BString& str, FindWindow::FindWindow(BMessenger messenger, const BString& str,
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) bool findSelection, bool matchWord, bool matchCase, bool forwardSearch)
: :
BWindow(kWindowFrame, "Find", B_FLOATING_WINDOW, BWindow(kWindowFrame, TR("Find"), B_FLOATING_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS), | B_AUTO_UPDATE_SIZE_LIMITS),
fFindDlgMessenger(messenger) fFindDlgMessenger(messenger)
@@ -44,16 +48,16 @@ FindWindow::FindWindow(BMessenger messenger, const BString& str,
BView* layoutView = BGroupLayoutBuilder(B_VERTICAL, 5.0) BView* layoutView = BGroupLayoutBuilder(B_VERTICAL, 5.0)
.SetInsets(spacing, spacing, spacing, spacing) .SetInsets(spacing, spacing, spacing, spacing)
.Add(BGridLayoutBuilder() .Add(BGridLayoutBuilder()
.Add(fTextRadio = new BRadioButton("Use text:", .Add(fTextRadio = new BRadioButton(TR("Use text:"),
new BMessage(TOGGLE_FIND_CONTROL)), 0, 0) new BMessage(TOGGLE_FIND_CONTROL)), 0, 0)
.Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0) .Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0)
.Add(useSelection = new BRadioButton("Use selection", .Add(useSelection = new BRadioButton(TR("Use selection"),
new BMessage(TOGGLE_FIND_CONTROL)), 0, 1)) new BMessage(TOGGLE_FIND_CONTROL)), 0, 1))
.Add(separator) .Add(separator)
.Add(fForwardSearchBox = new BCheckBox("Search forward")) .Add(fForwardSearchBox = new BCheckBox(TR("Search forward")))
.Add(fMatchCaseBox = new BCheckBox("Match case")) .Add(fMatchCaseBox = new BCheckBox(TR("Match case")))
.Add(fMatchWordBox = new BCheckBox("Match word")) .Add(fMatchWordBox = new BCheckBox(TR("Match word")))
.Add(fFindButton = new BButton("Find", new BMessage(MSG_FIND))) .Add(fFindButton = new BButton(TR("Find"), new BMessage(MSG_FIND)))
.End(); .End();
AddChild(layoutView); AddChild(layoutView);
+1 -1
View File
@@ -26,6 +26,6 @@ Application Terminal :
TermWindow.cpp TermWindow.cpp
VTKeyTbl.c VTKeyTbl.c
VTPrsTbl.c VTPrsTbl.c
: be tracker textencoding $(TARGET_LIBSUPC++) : be locale tracker textencoding $(TARGET_LIBSUPC++)
: Terminal.rdef : Terminal.rdef
; ;
+9 -2
View File
@@ -12,12 +12,14 @@
#include "PrefHandler.h" #include "PrefHandler.h"
#include "TermConst.h" #include "TermConst.h"
#include <Catalog.h>
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Font.h> #include <Font.h>
#include <GraphicsDefs.h> #include <GraphicsDefs.h>
#include <Locale.h>
#include <Message.h> #include <Message.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
@@ -239,13 +241,15 @@ PrefHandler::getFloat(const char *key)
return atof(value); return atof(value);
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal getString"
const char* const char*
PrefHandler::getString(const char *key) PrefHandler::getString(const char *key)
{ {
const char *buffer; const char *buffer;
if (fContainer.FindString(key, &buffer) != B_OK) if (fContainer.FindString(key, &buffer) != B_OK)
buffer = "Error!"; buffer = TR("Error!");
//printf("%x GET %s: %s\n", this, key, buf); //printf("%x GET %s: %s\n", this, key, buf);
return buffer; return buffer;
@@ -263,6 +267,9 @@ PrefHandler::getBool(const char *key)
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal getRGB"
/** Returns RGB data from given key. */ /** Returns RGB data from given key. */
rgb_color rgb_color
@@ -274,7 +281,7 @@ PrefHandler::getRGB(const char *key)
if (const char *s = fContainer.FindString(key)) { if (const char *s = fContainer.FindString(key)) {
sscanf(s, "%d, %d, %d", &r, &g, &b); sscanf(s, "%d, %d, %d", &r, &g, &b);
} else { } else {
fprintf(stderr, "PrefHandler::getRGB(%s) - key not found\n", key); fprintf(stderr, TR("PrefHandler::getRGB(%s) - key not found\n"), key);
r = g = b = 0; r = g = b = 0;
} }
+11 -7
View File
@@ -14,16 +14,20 @@
#include <Alert.h> #include <Alert.h>
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <FilePanel.h> #include <FilePanel.h>
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <LayoutBuilder.h> #include <LayoutBuilder.h>
#include <Locale.h>
#include <Path.h> #include <Path.h>
#include <stdio.h> #include <stdio.h>
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal PrefWindow"
PrefWindow::PrefWindow(const BMessenger &messenger) PrefWindow::PrefWindow(const BMessenger &messenger)
: BWindow(BRect(0, 0, 375, 185), "Terminal settings", : BWindow(BRect(0, 0, 375, 185), TR("Terminal settings"),
B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_AUTO_UPDATE_SIZE_LIMITS), B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_AUTO_UPDATE_SIZE_LIMITS),
fPreviousPref(new PrefHandler(PrefHandler::Default())), fPreviousPref(new PrefHandler(PrefHandler::Default())),
@@ -34,16 +38,16 @@ PrefWindow::PrefWindow(const BMessenger &messenger)
BLayoutBuilder::Group<>(this, B_VERTICAL) BLayoutBuilder::Group<>(this, B_VERTICAL)
.AddGroup(B_VERTICAL) .AddGroup(B_VERTICAL)
.SetInsets(10, 10, 10, 10) .SetInsets(10, 10, 10, 10)
.Add(new AppearancePrefView("Appearance", fTerminalMessenger)) .Add(new AppearancePrefView(TR("Appearance"), fTerminalMessenger))
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
.Add(fSaveAsFileButton = new BButton("savebutton", .Add(fSaveAsFileButton = new BButton("savebutton",
"Save to file" B_UTF8_ELLIPSIS, TR("Save to file" B_UTF8_ELLIPSIS),
new BMessage(MSG_SAVEAS_PRESSED), B_WILL_DRAW)) new BMessage(MSG_SAVEAS_PRESSED), B_WILL_DRAW))
.AddGlue() .AddGlue()
.Add(fRevertButton = new BButton("revertbutton", .Add(fRevertButton = new BButton("revertbutton",
"Cancel", new BMessage(MSG_REVERT_PRESSED), TR("Cancel"), new BMessage(MSG_REVERT_PRESSED),
B_WILL_DRAW)) B_WILL_DRAW))
.Add(fSaveButton = new BButton("okbutton", "OK", .Add(fSaveButton = new BButton("okbutton", TR("OK"),
new BMessage(MSG_SAVE_PRESSED), B_WILL_DRAW)) new BMessage(MSG_SAVE_PRESSED), B_WILL_DRAW))
.End() .End()
.End(); .End();
@@ -79,8 +83,8 @@ PrefWindow::QuitRequested()
if (!fDirty) if (!fDirty)
return true; return true;
BAlert *alert = new BAlert("", "Save changes to this settings panel?", BAlert *alert = new BAlert("", TR("Save changes to this settings panel?"),
"Cancel", "Don't save", "Save", TR("Cancel"), TR("Don't save"), TR("Save"),
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WIDTH_AS_USUAL, B_OFFSET_SPACING,
B_WARNING_ALERT); B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
+15 -11
View File
@@ -27,7 +27,9 @@
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <Catalog.h>
#include <OS.h> #include <OS.h>
#include <Locale.h>
#include "TermConst.h" #include "TermConst.h"
#include "TermParse.h" #include "TermParse.h"
@@ -316,6 +318,8 @@ initialize_termios(struct termios &tio)
tio.c_cc[VSUSP] = CSUSP; /* '^Z' */ tio.c_cc[VSUSP] = CSUSP; /* '^Z' */
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal Shell"
status_t status_t
Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **argv) Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **argv)
@@ -360,7 +364,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
} else { } else {
// B_BUSY is a normal case // B_BUSY is a normal case
if (errno != B_BUSY) if (errno != B_BUSY)
fprintf(stderr, "could not open %s: %s\n", ptyName, strerror(errno)); fprintf(stderr, TR("could not open %s: %s\n"), ptyName, strerror(errno));
} }
} }
closedir(dir); closedir(dir);
@@ -368,7 +372,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
#endif /* __HAIKU__ */ #endif /* __HAIKU__ */
if (master < 0) { if (master < 0) {
fprintf(stderr, "Didn't find any available pseudo ttys."); fprintf(stderr, TR("Didn't find any available pseudo ttys."));
return errno; return errno;
} }
@@ -376,7 +380,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
if (grantpt(master) != 0 || unlockpt(master) != 0 if (grantpt(master) != 0 || unlockpt(master) != 0
|| (ttyName = ptsname(master)) == NULL) { || (ttyName = ptsname(master)) == NULL) {
close(master); close(master);
fprintf(stderr, "Failed to init pseudo tty."); fprintf(stderr, TR("Failed to init pseudo tty."));
return errno; return errno;
} }
#endif /* __HAIKU__ */ #endif /* __HAIKU__ */
@@ -411,7 +415,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
if (setsid() < 0) { if (setsid() < 0) {
handshake.status = PTY_NG; handshake.status = PTY_NG;
snprintf(handshake.msg, sizeof(handshake.msg), snprintf(handshake.msg, sizeof(handshake.msg),
"could not set session leader."); TR("could not set session leader."));
send_handshake_message(terminalThread, handshake); send_handshake_message(terminalThread, handshake);
exit(1); exit(1);
} }
@@ -421,7 +425,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
if ((slave = open(ttyName, O_RDWR)) < 0) { if ((slave = open(ttyName, O_RDWR)) < 0) {
handshake.status = PTY_NG; handshake.status = PTY_NG;
snprintf(handshake.msg, sizeof(handshake.msg), snprintf(handshake.msg, sizeof(handshake.msg),
"can't open tty (%s).", ttyName); TR("can't open tty (%s)."), ttyName);
send_handshake_message(terminalThread, handshake); send_handshake_message(terminalThread, handshake);
exit(1); exit(1);
} }
@@ -460,7 +464,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
if (tcsetattr(0, TCSANOW, &tio) == -1) { if (tcsetattr(0, TCSANOW, &tio) == -1) {
handshake.status = PTY_NG; handshake.status = PTY_NG;
snprintf(handshake.msg, sizeof(handshake.msg), snprintf(handshake.msg, sizeof(handshake.msg),
"failed set terminal interface (TERMIOS)."); TR("failed set terminal interface (TERMIOS)."));
send_handshake_message(terminalThread, handshake); send_handshake_message(terminalThread, handshake);
exit(1); exit(1);
} }
@@ -476,7 +480,7 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
if (handshake.status != PTY_WS) { if (handshake.status != PTY_WS) {
handshake.status = PTY_NG; handshake.status = PTY_NG;
snprintf(handshake.msg, sizeof(handshake.msg), snprintf(handshake.msg, sizeof(handshake.msg),
"mismatch handshake."); TR("mismatch handshake."));
send_handshake_message(terminalThread, handshake); send_handshake_message(terminalThread, handshake);
exit(1); exit(1);
} }
@@ -512,10 +516,10 @@ Shell::_Spawn(int row, int col, const char *encoding, int argc, const char **arg
*/ */
sleep(1); sleep(1);
const char *spawnAlertMessage = "alert --stop " BString knonLocalizedPart = "alert --stop ";
"'Cannot execute \"%s\":\n" const char *kLocalizedPart =
"\t%s' " TR("'Cannot execute \"%s\":\n\t%s' 'Use default shell' 'Abort'");
"'Use default shell' 'Abort'"; const char *spawnAlertMessage = knonLocalizedPart << kLocalizedPart;
char errorMessage[256]; char errorMessage[256];
snprintf(errorMessage, sizeof(errorMessage), spawnAlertMessage, argv[0], strerror(errno)); snprintf(errorMessage, sizeof(errorMessage), spawnAlertMessage, argv[0], strerror(errno));
+5 -1
View File
@@ -16,6 +16,8 @@
#include "SmartTabView.h" #include "SmartTabView.h"
#include <Catalog.h>
#include <Locale.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <Messenger.h> #include <Messenger.h>
@@ -60,6 +62,8 @@ SmartTabView::SetInsets(float left, float top, float right, float bottom)
fInsets.bottom = bottom; fInsets.bottom = bottom;
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal SmartTabView"
void void
SmartTabView::MouseDown(BPoint point) SmartTabView::MouseDown(BPoint point)
@@ -76,7 +80,7 @@ SmartTabView::MouseDown(BPoint point)
message->AddInt32("index", tabIndex); message->AddInt32("index", tabIndex);
BPopUpMenu* popUpMenu = new BPopUpMenu("tab menu"); BPopUpMenu* popUpMenu = new BPopUpMenu("tab menu");
popUpMenu->AddItem(new BMenuItem("Close tab", message)); popUpMenu->AddItem(new BMenuItem(TR("Close tab"), message));
popUpMenu->SetAsyncAutoDestruct(true); popUpMenu->SetAsyncAutoDestruct(true);
popUpMenu->SetTargetForItems(BMessenger(this)); popUpMenu->SetTargetForItems(BMessenger(this));
popUpMenu->Go(ConvertToScreen(point), true, true, true); popUpMenu->Go(ConvertToScreen(point), true, true, true);
+17 -9
View File
@@ -17,7 +17,10 @@
#include <unistd.h> #include <unistd.h>
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <Clipboard.h> #include <Clipboard.h>
#include <Catalog.h>
#include <Locale.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <Path.h> #include <Path.h>
#include <Roster.h> #include <Roster.h>
@@ -50,13 +53,16 @@ main()
return 0; return 0;
} }
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal TermApp"
TermApp::TermApp() TermApp::TermApp()
: BApplication(TERM_SIGNATURE), : BApplication(TERM_SIGNATURE),
fStartFullscreen(false), fStartFullscreen(false),
fWindowNumber(-1), fWindowNumber(-1),
fTermWindow(NULL), fTermWindow(NULL),
fArgs(NULL) fArgs(NULL),
fAppCatalog(NULL)
{ {
const char *defaultArgs[2]; const char *defaultArgs[2];
defaultArgs[0] = kDefaultShell; defaultArgs[0] = kDefaultShell;
@@ -70,9 +76,11 @@ TermApp::TermApp()
defaultArgs[0] = passwdStruct.pw_shell; defaultArgs[0] = passwdStruct.pw_shell;
} }
be_locale->GetAppCatalog(&fAppCatalog);
fArgs = new Arguments(2, defaultArgs); fArgs = new Arguments(2, defaultArgs);
fWindowTitle = "Terminal"; fWindowTitle = TR("Terminal");
_RegisterTerminal(); _RegisterTerminal();
if (fWindowNumber > 0) if (fWindowNumber > 0)
@@ -114,7 +122,7 @@ TermApp::ReadyToRun()
#endif #endif
action.sa_userdata = this; action.sa_userdata = this;
if (sigaction(SIGCHLD, &action, NULL) < 0) { if (sigaction(SIGCHLD, &action, NULL) < 0) {
fprintf(stderr, "sigaction() failed: %s\n", strerror(errno)); fprintf(stderr, TR("sigaction() failed: %s\n"), strerror(errno));
// continue anyway // continue anyway
} }
@@ -126,8 +134,8 @@ TermApp::ReadyToRun()
// failed spawn, print stdout and open alert panel // failed spawn, print stdout and open alert panel
// TODO: This alert does never show up. // TODO: This alert does never show up.
if (status < B_OK) { if (status < B_OK) {
(new BAlert("alert", "Terminal couldn't start the shell. Sorry.", (new BAlert("alert", TR("Terminal couldn't start the shell. Sorry."),
"OK", NULL, NULL, B_WIDTH_FROM_LABEL, TR("OK"), NULL, NULL, B_WIDTH_FROM_LABEL,
B_INFO_ALERT))->Go(NULL); B_INFO_ALERT))->Go(NULL);
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
return; return;
@@ -554,17 +562,17 @@ TermApp::_ChildCleanupThread(void* data)
void void
TermApp::_Usage(char *name) TermApp::_Usage(char *name)
{ {
fprintf(stderr, "Haiku Terminal\n" fprintf(stderr, TR("Haiku Terminal\n"
"Copyright 2001-2009 Haiku, Inc.\n" "Copyright 2001-2009 Haiku, Inc.\n"
"Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n" "Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n"
"\n" "\n"
"Usage: %s [OPTION] [SHELL]\n", name); "Usage: %s [OPTION] [SHELL]\n"), name);
fprintf(stderr, fprintf(stderr,
" -h, --help print this help\n" TR(" -h, --help print this help\n"
//" -p, --preference load preference file\n" //" -p, --preference load preference file\n"
" -t, --title set window title\n" " -t, --title set window title\n"
" -f, --fullscreen start fullscreen\n" " -f, --fullscreen start fullscreen\n")
//" -geom, --geometry set window geometry\n" //" -geom, --geometry set window geometry\n"
//" An example of geometry is \"80x25+100+100\"\n" //" An example of geometry is \"80x25+100+100\"\n"
); );
+2
View File
@@ -33,6 +33,7 @@
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <String.h> #include <String.h>
class Arguments; class Arguments;
@@ -76,6 +77,7 @@ class TermApp : public BApplication {
BWindow* fTermWindow; BWindow* fTermWindow;
BRect fTermFrame; BRect fTermFrame;
Arguments *fArgs; Arguments *fArgs;
BCatalog fAppCatalog;
}; };
#endif // TERM_APP_H #endif // TERM_APP_H
+7 -3
View File
@@ -18,6 +18,8 @@
#include <Autolock.h> #include <Autolock.h>
#include <Beep.h> #include <Beep.h>
#include <Catalog.h>
#include <Locale.h>
#include <Message.h> #include <Message.h>
#include <UTF8.h> #include <UTF8.h>
@@ -45,6 +47,8 @@ extern int gMbcsTable[]; /* ESC $ */
#define DEFAULT -1 #define DEFAULT -1
#define NPARAM 10 // Max parameters #define NPARAM 10 // Max parameters
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal TermParse"
//! Get char from pty reader buffer. //! Get char from pty reader buffer.
inline uchar inline uchar
@@ -287,17 +291,17 @@ TermParse::DumpState(int *groundtable, int *parsestate, uchar c)
{ NULL, NULL } { NULL, NULL }
}; };
int i; int i;
fprintf(stderr, "groundtable: "); fprintf(stderr, TR("groundtable: "));
for (i = 0; tables[i].p; i++) { for (i = 0; tables[i].p; i++) {
if (tables[i].p == groundtable) if (tables[i].p == groundtable)
fprintf(stderr, "%s\t", tables[i].name); fprintf(stderr, "%s\t", tables[i].name);
} }
fprintf(stderr, "parsestate: "); fprintf(stderr, TR("parsestate: "));
for (i = 0; tables[i].p; i++) { for (i = 0; tables[i].p; i++) {
if (tables[i].p == parsestate) if (tables[i].p == parsestate)
fprintf(stderr, "%s\t", tables[i].name); fprintf(stderr, "%s\t", tables[i].name);
} }
fprintf(stderr, "char: 0x%02x (%d)\n", c, c); fprintf(stderr, TR("char: 0x%02x (%d)\n"), c, c);
} }
+14 -10
View File
@@ -27,11 +27,13 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Beep.h> #include <Beep.h>
#include <Catalog.h>
#include <Clipboard.h> #include <Clipboard.h>
#include <Debug.h> #include <Debug.h>
#include <Directory.h> #include <Directory.h>
#include <Dragger.h> #include <Dragger.h>
#include <Input.h> #include <Input.h>
#include <Locale.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <MessageRunner.h> #include <MessageRunner.h>
@@ -81,6 +83,8 @@ enum {
SELECT_LINES SELECT_LINES
}; };
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal TermView"
static property_info sPropList[] = { static property_info sPropList[] = {
{ "encoding", { "encoding",
@@ -1427,7 +1431,7 @@ TermView::FrameResized(float width, float height)
bool hasResizeView = fResizeRunner != NULL; bool hasResizeView = fResizeRunner != NULL;
if (!hasResizeView) { if (!hasResizeView) {
// show the current size in a view // show the current size in a view
fResizeView = new BStringView(BRect(100, 100, 300, 140), "size", ""); fResizeView = new BStringView(BRect(100, 100, 300, 140), TR("size"), "");
fResizeView->SetAlignment(B_ALIGN_CENTER); fResizeView->SetAlignment(B_ALIGN_CENTER);
fResizeView->SetFont(be_bold_font); fResizeView->SetFont(be_bold_font);
@@ -1821,12 +1825,12 @@ TermView::_SecondaryMouseButtonDropped(BMessage* msg)
cpMessage->what = kSecondaryMouseDropAction; cpMessage->what = kSecondaryMouseDropAction;
cpMessage->AddInt8("action", kCopyFiles); cpMessage->AddInt8("action", kCopyFiles);
BMenuItem* insertItem = new BMenuItem("Insert path", insertMessage); BMenuItem* insertItem = new BMenuItem(TR("Insert path"), insertMessage);
BMenuItem* cdItem = new BMenuItem("Change directory", cdMessage); BMenuItem* cdItem = new BMenuItem(TR("Change directory"), cdMessage);
BMenuItem* lnItem = new BMenuItem("Create link here", lnMessage); BMenuItem* lnItem = new BMenuItem(TR("Create link here"), lnMessage);
BMenuItem* mvItem = new BMenuItem("Move here", mvMessage); BMenuItem* mvItem = new BMenuItem(TR("Move here"), mvMessage);
BMenuItem* cpItem = new BMenuItem("Copy here", cpMessage); BMenuItem* cpItem = new BMenuItem(TR("Copy here"), cpMessage);
BMenuItem* chItem = new BMenuItem("Cancel", NULL); BMenuItem* chItem = new BMenuItem(TR("Cancel"), NULL);
// if the refs point to different directorys disable the cd menu item // if the refs point to different directorys disable the cd menu item
bool differentDirs = false; bool differentDirs = false;
@@ -1854,7 +1858,7 @@ TermView::_SecondaryMouseButtonDropped(BMessage* msg)
if (differentDirs) if (differentDirs)
cdItem->SetEnabled(false); cdItem->SetEnabled(false);
BPopUpMenu *menu = new BPopUpMenu("Secondary Mouse Button Drop Menu"); BPopUpMenu *menu = new BPopUpMenu(TR("Secondary mouse button drop menu"));
menu->SetAsyncAutoDestruct(true); menu->SetAsyncAutoDestruct(true);
menu->AddItem(insertItem); menu->AddItem(insertItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
@@ -2764,10 +2768,10 @@ void
TermView::AboutRequested() TermView::AboutRequested()
{ {
BAlert *alert = new (std::nothrow) BAlert("about", BAlert *alert = new (std::nothrow) BAlert("about",
"Terminal\n\n" TR("Terminal\n\n"
"written by Kazuho Okui and Takashi Murai\n" "written by Kazuho Okui and Takashi Murai\n"
"updated by Kian Duffy and others\n\n" "updated by Kian Duffy and others\n\n"
"Copyright " B_UTF8_COPYRIGHT "2003-2009, Haiku.\n", "OK"); "Copyright " B_UTF8_COPYRIGHT "2003-2009, Haiku.\n"), TR("OK"));
if (alert != NULL) if (alert != NULL)
alert->Go(); alert->Go();
} }
+34 -30
View File
@@ -16,8 +16,10 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <Clipboard.h> #include <Clipboard.h>
#include <Dragger.h> #include <Dragger.h>
#include <Locale.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
@@ -52,6 +54,8 @@ const static uint32 kIncreaseFontSize = 'InFs';
const static uint32 kDecreaseFontSize = 'DcFs'; const static uint32 kDecreaseFontSize = 'DcFs';
const static uint32 kSetActiveTab = 'STab'; const static uint32 kSetActiveTab = 'STab';
#undef TR_CONTEXT
#define TR_CONTEXT "Terminal TermWindow"
class CustomTermView : public TermView { class CustomTermView : public TermView {
public: public:
@@ -253,7 +257,7 @@ TermWindow::MenusBeginning()
BMenu * BMenu *
TermWindow::_MakeEncodingMenu() TermWindow::_MakeEncodingMenu()
{ {
BMenu *menu = new (std::nothrow) BMenu("Text encoding"); BMenu *menu = new (std::nothrow) BMenu(TR("Text encoding"));
if (menu == NULL) if (menu == NULL)
return NULL; return NULL;
@@ -282,44 +286,44 @@ TermWindow::_SetupMenu()
fMenubar = new BMenuBar(Bounds(), "mbar"); fMenubar = new BMenuBar(Bounds(), "mbar");
// Make File Menu. // Make File Menu.
fFilemenu = new BMenu("Terminal"); fFilemenu = new BMenu(TR("Terminal"));
fFilemenu->AddItem(new BMenuItem("Switch Terminals", fFilemenu->AddItem(new BMenuItem(TR("Switch Terminals"),
new BMessage(MENU_SWITCH_TERM), B_TAB)); new BMessage(MENU_SWITCH_TERM), B_TAB));
fFilemenu->AddItem(new BMenuItem("New Terminal", fFilemenu->AddItem(new BMenuItem(TR("New Terminal"),
new BMessage(MENU_NEW_TERM), 'N')); new BMessage(MENU_NEW_TERM), 'N'));
fFilemenu->AddItem(new BMenuItem("New tab", new BMessage(kNewTab), 'T')); fFilemenu->AddItem(new BMenuItem(TR("New tab"), new BMessage(kNewTab), 'T'));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Page setup" B_UTF8_ELLIPSIS, fFilemenu->AddItem(new BMenuItem(TR("Page setup" B_UTF8_ELLIPSIS),
new BMessage(MENU_PAGE_SETUP))); new BMessage(MENU_PAGE_SETUP)));
fFilemenu->AddItem(new BMenuItem("Print", new BMessage(MENU_PRINT),'P')); fFilemenu->AddItem(new BMenuItem(TR("Print"), new BMessage(MENU_PRINT),'P'));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("About Terminal" B_UTF8_ELLIPSIS, fFilemenu->AddItem(new BMenuItem(TR("About Terminal" B_UTF8_ELLIPSIS),
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
fFilemenu->AddSeparatorItem(); fFilemenu->AddSeparatorItem();
fFilemenu->AddItem(new BMenuItem("Close active tab", fFilemenu->AddItem(new BMenuItem(TR("Close active tab"),
new BMessage(kCloseView), 'W', B_SHIFT_KEY)); new BMessage(kCloseView), 'W', B_SHIFT_KEY));
fFilemenu->AddItem(new BMenuItem("Quit", fFilemenu->AddItem(new BMenuItem(TR("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q')); new BMessage(B_QUIT_REQUESTED), 'Q'));
fMenubar->AddItem(fFilemenu); fMenubar->AddItem(fFilemenu);
// Make Edit Menu. // Make Edit Menu.
fEditmenu = new BMenu("Edit"); fEditmenu = new BMenu("Edit");
fEditmenu->AddItem(new BMenuItem("Copy", new BMessage(B_COPY),'C')); fEditmenu->AddItem(new BMenuItem(TR("Copy"), new BMessage(B_COPY),'C'));
fEditmenu->AddItem(new BMenuItem("Paste", new BMessage(B_PASTE),'V')); fEditmenu->AddItem(new BMenuItem(TR("Paste"), new BMessage(B_PASTE),'V'));
fEditmenu->AddSeparatorItem(); fEditmenu->AddSeparatorItem();
fEditmenu->AddItem(new BMenuItem("Select all", fEditmenu->AddItem(new BMenuItem(TR("Select all"),
new BMessage(B_SELECT_ALL), 'A')); new BMessage(B_SELECT_ALL), 'A'));
fEditmenu->AddItem(new BMenuItem("Clear all", fEditmenu->AddItem(new BMenuItem(TR("Clear all"),
new BMessage(MENU_CLEAR_ALL), 'L')); new BMessage(MENU_CLEAR_ALL), 'L'));
fEditmenu->AddSeparatorItem(); fEditmenu->AddSeparatorItem();
fEditmenu->AddItem(new BMenuItem("Find" B_UTF8_ELLIPSIS, fEditmenu->AddItem(new BMenuItem(TR("Find" B_UTF8_ELLIPSIS),
new BMessage(MENU_FIND_STRING),'F')); new BMessage(MENU_FIND_STRING),'F'));
fFindPreviousMenuItem = new BMenuItem("Find previous", fFindPreviousMenuItem = new BMenuItem(TR("Find previous"),
new BMessage(MENU_FIND_PREVIOUS), 'G', B_SHIFT_KEY); new BMessage(MENU_FIND_PREVIOUS), 'G', B_SHIFT_KEY);
fEditmenu->AddItem(fFindPreviousMenuItem); fEditmenu->AddItem(fFindPreviousMenuItem);
fFindPreviousMenuItem->SetEnabled(false); fFindPreviousMenuItem->SetEnabled(false);
fFindNextMenuItem = new BMenuItem("Find next", fFindNextMenuItem = new BMenuItem(TR("Find next"),
new BMessage(MENU_FIND_NEXT), 'G'); new BMessage(MENU_FIND_NEXT), 'G');
fEditmenu->AddItem(fFindNextMenuItem); fEditmenu->AddItem(fFindNextMenuItem);
fFindNextMenuItem->SetEnabled(false); fFindNextMenuItem->SetEnabled(false);
@@ -327,17 +331,17 @@ TermWindow::_SetupMenu()
fMenubar->AddItem(fEditmenu); fMenubar->AddItem(fEditmenu);
// Make Help Menu. // Make Help Menu.
fHelpmenu = new BMenu("Settings"); fHelpmenu = new BMenu(TR("Settings"));
fWindowSizeMenu = _MakeWindowSizeMenu(); fWindowSizeMenu = _MakeWindowSizeMenu();
fEncodingmenu = _MakeEncodingMenu(); fEncodingmenu = _MakeEncodingMenu();
fSizeMenu = new BMenu("Text size"); fSizeMenu = new BMenu(TR("Text size"));
fIncreaseFontSizeMenuItem = new BMenuItem("Increase", fIncreaseFontSizeMenuItem = new BMenuItem(TR("Increase"),
new BMessage(kIncreaseFontSize), '+', B_COMMAND_KEY); new BMessage(kIncreaseFontSize), '+', B_COMMAND_KEY);
fDecreaseFontSizeMenuItem = new BMenuItem("Decrease", fDecreaseFontSizeMenuItem = new BMenuItem(TR("Decrease"),
new BMessage(kDecreaseFontSize), '-', B_COMMAND_KEY); new BMessage(kDecreaseFontSize), '-', B_COMMAND_KEY);
fSizeMenu->AddItem(fIncreaseFontSizeMenuItem); fSizeMenu->AddItem(fIncreaseFontSizeMenuItem);
@@ -347,10 +351,10 @@ TermWindow::_SetupMenu()
fHelpmenu->AddItem(fEncodingmenu); fHelpmenu->AddItem(fEncodingmenu);
fHelpmenu->AddItem(fSizeMenu); fHelpmenu->AddItem(fSizeMenu);
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
fHelpmenu->AddItem(new BMenuItem("Settings" B_UTF8_ELLIPSIS, fHelpmenu->AddItem(new BMenuItem(TR("Settings" B_UTF8_ELLIPSIS),
new BMessage(MENU_PREF_OPEN))); new BMessage(MENU_PREF_OPEN)));
fHelpmenu->AddSeparatorItem(); fHelpmenu->AddSeparatorItem();
fHelpmenu->AddItem(new BMenuItem("Save as default", fHelpmenu->AddItem(new BMenuItem(TR("Save as default"),
new BMessage(SAVE_AS_DEFAULT))); new BMessage(SAVE_AS_DEFAULT)));
fMenubar->AddItem(fHelpmenu); fMenubar->AddItem(fHelpmenu);
@@ -451,8 +455,8 @@ TermWindow::MessageReceived(BMessage *message)
if (fFindString.Length() == 0) { if (fFindString.Length() == 0) {
const char* errorMsg = !fFindSelection const char* errorMsg = !fFindSelection
? "No search string was entered." : "Nothing is selected."; ? TR("No search string was entered.") : TR("Nothing is selected.");
BAlert* alert = new BAlert("Find failed", errorMsg, "OK", NULL, BAlert* alert = new BAlert(TR("Find failed"), errorMsg, TR("OK"), NULL,
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->Go(); alert->Go();
@@ -467,7 +471,7 @@ TermWindow::MessageReceived(BMessage *message)
findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord); findresult = _ActiveTermView()->Find(fFindString, fForwardSearch, fMatchCase, fMatchWord);
if (!findresult) { if (!findresult) {
BAlert *alert = new BAlert("Find failed", "Text not found.", "OK", NULL, BAlert *alert = new BAlert(TR("Find failed"), TR("Text not found."), TR("OK"), NULL,
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
@@ -488,7 +492,7 @@ TermWindow::MessageReceived(BMessage *message)
(message->what == MENU_FIND_NEXT) == fForwardSearch, (message->what == MENU_FIND_NEXT) == fForwardSearch,
fMatchCase, fMatchWord); fMatchCase, fMatchWord);
if (!findresult) { if (!findresult) {
BAlert *alert = new BAlert("Find failed", "Not found.", "OK", BAlert *alert = new BAlert(TR("Find failed"), TR("Not found."), TR("OK"),
NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
alert->Go(); alert->Go();
@@ -719,7 +723,7 @@ void
TermWindow::_DoPrint() TermWindow::_DoPrint()
{ {
if (!fPrintSettings || (_DoPageSetup() != B_OK)) { if (!fPrintSettings || (_DoPageSetup() != B_OK)) {
(new BAlert("Cancel", "Print cancelled.", "OK"))->Go(); (new BAlert(TR("Cancel"), TR("Print cancelled."), TR("OK")))->Go();
return; return;
} }
@@ -978,7 +982,7 @@ TermWindow::_ResizeView(TermView *view)
BMenu* BMenu*
TermWindow::_MakeWindowSizeMenu() TermWindow::_MakeWindowSizeMenu()
{ {
BMenu *menu = new (std::nothrow) BMenu("Window size"); BMenu *menu = new (std::nothrow) BMenu(TR("Window size"));
if (menu == NULL) if (menu == NULL)
return NULL; return NULL;
@@ -1002,7 +1006,7 @@ TermWindow::_MakeWindowSizeMenu()
} }
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Full screen", new BMessage(FULLSCREEN), menu->AddItem(new BMenuItem(TR("Full screen"), new BMessage(FULLSCREEN),
B_ENTER)); B_ENTER));
return menu; return menu;