SerialConnect: Add localization.
Add localization for menus, statusbar and system name. Change-Id: I85ef95c1ff940c6d794f49a859ff1b696b866839 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2602 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
693e2f4fb4
commit
2e6ca31c5a
@@ -24,3 +24,10 @@ Application SerialConnect :
|
|||||||
: SerialConnect.rdef
|
: SerialConnect.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs SerialConnect :
|
||||||
|
x-vnd.haiku.SerialConnect
|
||||||
|
:
|
||||||
|
CustomRateWindow.cpp
|
||||||
|
SerialWindow.cpp
|
||||||
|
XModem.cpp
|
||||||
|
;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
resource app_signature "application/x-vnd.haiku.SerialConnect";
|
resource app_signature "application/x-vnd.haiku.SerialConnect";
|
||||||
|
|
||||||
|
resource app_name_catalog_entry "x-vnd.haiku.SerialConnect:System name:SerialConnect";
|
||||||
|
|
||||||
resource app_version {
|
resource app_version {
|
||||||
major = 0,
|
major = 0,
|
||||||
middle = 0,
|
middle = 0,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
@@ -21,6 +22,9 @@
|
|||||||
#include "TermView.h"
|
#include "TermView.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define B_TRANSLATION_CONTEXT "SerialWindow"
|
||||||
|
|
||||||
|
|
||||||
const int SerialWindow::kBaudrates[] = { 50, 75, 110, 134, 150, 200, 300, 600,
|
const int SerialWindow::kBaudrates[] = { 50, 75, 110, 134, 150, 200, 300, 600,
|
||||||
1200, 1800, 2400, 4800, 9600, 19200, 31250, 38400, 57600, 115200, 230400
|
1200, 1800, 2400, 4800, 9600, 19200, 31250, 38400, 57600, 115200, 230400
|
||||||
};
|
};
|
||||||
@@ -35,11 +39,13 @@ const int SerialWindow::kBaudrateConstants[] = { B_50_BPS, B_75_BPS, B_110_BPS,
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const char* SerialWindow::kWindowTitle = "SerialConnect";
|
const char* SerialWindow::kWindowTitle =
|
||||||
|
B_TRANSLATE_MARK_SYSTEM_NAME("SerialConnect");
|
||||||
|
|
||||||
|
|
||||||
SerialWindow::SerialWindow()
|
SerialWindow::SerialWindow()
|
||||||
: BWindow(BRect(100, 100, 400, 400), SerialWindow::kWindowTitle,
|
: BWindow(BRect(100, 100, 400, 400),
|
||||||
|
B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(SerialWindow::kWindowTitle),
|
||||||
B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
|
B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
|
||||||
, fLogFilePanel(NULL)
|
, fLogFilePanel(NULL)
|
||||||
, fSendFilePanel(NULL)
|
, fSendFilePanel(NULL)
|
||||||
@@ -69,7 +75,8 @@ SerialWindow::SerialWindow()
|
|||||||
r = fTermView->Frame();
|
r = fTermView->Frame();
|
||||||
r.top = r.bottom - 37;
|
r.top = r.bottom - 37;
|
||||||
|
|
||||||
fStatusBar = new BStatusBar(r, "file transfer progress", NULL, NULL);
|
fStatusBar = new BStatusBar(r, B_TRANSLATE("file transfer progress"),
|
||||||
|
NULL, NULL);
|
||||||
fStatusBar->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);
|
fStatusBar->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);
|
||||||
fStatusBar->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
fStatusBar->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
fStatusBar->Hide();
|
fStatusBar->Hide();
|
||||||
@@ -79,10 +86,10 @@ SerialWindow::SerialWindow()
|
|||||||
AddChild(scrollBar);
|
AddChild(scrollBar);
|
||||||
AddChild(fStatusBar);
|
AddChild(fStatusBar);
|
||||||
|
|
||||||
fConnectionMenu = new BMenu("Connection");
|
fConnectionMenu = new BMenu(B_TRANSLATE("Connection"));
|
||||||
fFileMenu = new BMenu("File");
|
fFileMenu = new BMenu(B_TRANSLATE("File"));
|
||||||
BMenu* settingsMenu = new BMenu("Settings");
|
BMenu* settingsMenu = new BMenu(B_TRANSLATE("Settings"));
|
||||||
BMenu* editMenu = new BMenu("Edit");
|
BMenu* editMenu = new BMenu(B_TRANSLATE("Edit"));
|
||||||
|
|
||||||
fConnectionMenu->SetRadioMode(true);
|
fConnectionMenu->SetRadioMode(true);
|
||||||
|
|
||||||
@@ -91,20 +98,21 @@ SerialWindow::SerialWindow()
|
|||||||
menuBar->AddItem(fFileMenu);
|
menuBar->AddItem(fFileMenu);
|
||||||
menuBar->AddItem(settingsMenu);
|
menuBar->AddItem(settingsMenu);
|
||||||
|
|
||||||
BMenuItem* logFile = new BMenuItem("Log to file" B_UTF8_ELLIPSIS,
|
BMenuItem* logFile = new BMenuItem(
|
||||||
new BMessage(kMsgLogfile));
|
B_TRANSLATE("Log to file" B_UTF8_ELLIPSIS), new BMessage(kMsgLogfile));
|
||||||
fFileMenu->AddItem(logFile);
|
fFileMenu->AddItem(logFile);
|
||||||
|
|
||||||
// The "send" items are disabled initially. They are enabled only once we
|
// The "send" items are disabled initially. They are enabled only once we
|
||||||
// are connected to a serial port.
|
// are connected to a serial port.
|
||||||
BMessage* sendMsg = new BMessage(kMsgSendFile);
|
BMessage* sendMsg = new BMessage(kMsgSendFile);
|
||||||
sendMsg->AddString("protocol", "xmodem");
|
sendMsg->AddString("protocol", "xmodem");
|
||||||
BMenuItem* xmodemSend = new BMenuItem("XModem send" B_UTF8_ELLIPSIS,
|
BMenuItem* xmodemSend = new BMenuItem(
|
||||||
|
B_TRANSLATE("XModem send" B_UTF8_ELLIPSIS),
|
||||||
sendMsg);
|
sendMsg);
|
||||||
fFileMenu->AddItem(xmodemSend);
|
fFileMenu->AddItem(xmodemSend);
|
||||||
xmodemSend->SetEnabled(false);
|
xmodemSend->SetEnabled(false);
|
||||||
|
|
||||||
BMenuItem* rawSend = new BMenuItem("Raw send" B_UTF8_ELLIPSIS,
|
BMenuItem* rawSend = new BMenuItem(B_TRANSLATE("Raw send" B_UTF8_ELLIPSIS),
|
||||||
new BMessage(kMsgSendFile));
|
new BMessage(kMsgSendFile));
|
||||||
fFileMenu->AddItem(rawSend);
|
fFileMenu->AddItem(rawSend);
|
||||||
rawSend->SetEnabled(false);
|
rawSend->SetEnabled(false);
|
||||||
@@ -118,7 +126,7 @@ SerialWindow::SerialWindow()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Items for the edit menu
|
// Items for the edit menu
|
||||||
BMenuItem* clearScreen = new BMenuItem("Clear history",
|
BMenuItem* clearScreen = new BMenuItem(B_TRANSLATE("Clear history"),
|
||||||
new BMessage(kMsgClear));
|
new BMessage(kMsgClear));
|
||||||
editMenu->AddItem(clearScreen);
|
editMenu->AddItem(clearScreen);
|
||||||
|
|
||||||
@@ -126,41 +134,44 @@ SerialWindow::SerialWindow()
|
|||||||
|
|
||||||
// Configuring all this by menus may be a bit unhandy. Make a setting
|
// Configuring all this by menus may be a bit unhandy. Make a setting
|
||||||
// window instead ?
|
// window instead ?
|
||||||
fBaudrateMenu = new BMenu("Baud rate");
|
fBaudrateMenu = new BMenu(B_TRANSLATE("Baud rate"));
|
||||||
fBaudrateMenu->SetRadioMode(true);
|
fBaudrateMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fBaudrateMenu);
|
settingsMenu->AddItem(fBaudrateMenu);
|
||||||
|
|
||||||
fParityMenu = new BMenu("Parity");
|
fParityMenu = new BMenu(B_TRANSLATE("Parity"));
|
||||||
fParityMenu->SetRadioMode(true);
|
fParityMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fParityMenu);
|
settingsMenu->AddItem(fParityMenu);
|
||||||
|
|
||||||
fStopbitsMenu = new BMenu("Stop bits");
|
fStopbitsMenu = new BMenu(B_TRANSLATE("Stop bits"));
|
||||||
fStopbitsMenu->SetRadioMode(true);
|
fStopbitsMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fStopbitsMenu);
|
settingsMenu->AddItem(fStopbitsMenu);
|
||||||
|
|
||||||
fFlowcontrolMenu = new BMenu("Flow control");
|
fFlowcontrolMenu = new BMenu(B_TRANSLATE("Flow control"));
|
||||||
fFlowcontrolMenu->SetRadioMode(true);
|
fFlowcontrolMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fFlowcontrolMenu);
|
settingsMenu->AddItem(fFlowcontrolMenu);
|
||||||
|
|
||||||
fDatabitsMenu = new BMenu("Data bits");
|
fDatabitsMenu = new BMenu(B_TRANSLATE("Data bits"));
|
||||||
fDatabitsMenu->SetRadioMode(true);
|
fDatabitsMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fDatabitsMenu);
|
settingsMenu->AddItem(fDatabitsMenu);
|
||||||
|
|
||||||
fLineTerminatorMenu = new BMenu("Line terminator");
|
fLineTerminatorMenu = new BMenu(B_TRANSLATE("Line terminator"));
|
||||||
fLineTerminatorMenu->SetRadioMode(true);
|
fLineTerminatorMenu->SetRadioMode(true);
|
||||||
settingsMenu->AddItem(fLineTerminatorMenu);
|
settingsMenu->AddItem(fLineTerminatorMenu);
|
||||||
|
|
||||||
BMessage* message = new BMessage(kMsgSettings);
|
BMessage* message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("parity", B_NO_PARITY);
|
message->AddInt32("parity", B_NO_PARITY);
|
||||||
BMenuItem* parityNone = new BMenuItem("None", message);
|
BMenuItem* parityNone =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("None", "Parity"), message);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("parity", B_ODD_PARITY);
|
message->AddInt32("parity", B_ODD_PARITY);
|
||||||
BMenuItem* parityOdd = new BMenuItem("Odd", message);
|
BMenuItem* parityOdd = new BMenuItem(B_TRANSLATE_COMMENT("Odd", "Parity"),
|
||||||
|
message);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("parity", B_EVEN_PARITY);
|
message->AddInt32("parity", B_EVEN_PARITY);
|
||||||
BMenuItem* parityEven = new BMenuItem("Even", message);
|
BMenuItem* parityEven =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("Even", "Parity"), message);
|
||||||
|
|
||||||
fParityMenu->AddItem(parityNone);
|
fParityMenu->AddItem(parityNone);
|
||||||
fParityMenu->AddItem(parityOdd);
|
fParityMenu->AddItem(parityOdd);
|
||||||
@@ -205,26 +216,32 @@ SerialWindow::SerialWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
message = new BMessage(kMsgCustomBaudrate);
|
message = new BMessage(kMsgCustomBaudrate);
|
||||||
BMenuItem* custom = new BMenuItem("custom" B_UTF8_ELLIPSIS, message);
|
BMenuItem* custom =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("custom" B_UTF8_ELLIPSIS,
|
||||||
|
"Baudrate"), message);
|
||||||
fBaudrateMenu->AddItem(custom);
|
fBaudrateMenu->AddItem(custom);
|
||||||
|
|
||||||
fBaudrateMenu->SetTargetForItems(be_app);
|
fBaudrateMenu->SetTargetForItems(be_app);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("flowcontrol", B_HARDWARE_CONTROL);
|
message->AddInt32("flowcontrol", B_HARDWARE_CONTROL);
|
||||||
BMenuItem* hardware = new BMenuItem("Hardware", message);
|
BMenuItem* hardware =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("Hardware", "Flowcontrol"), message);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("flowcontrol", B_SOFTWARE_CONTROL);
|
message->AddInt32("flowcontrol", B_SOFTWARE_CONTROL);
|
||||||
BMenuItem* software = new BMenuItem("Software", message);
|
BMenuItem* software =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("Software", "Flowcontrol"), message);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("flowcontrol", B_HARDWARE_CONTROL | B_SOFTWARE_CONTROL);
|
message->AddInt32("flowcontrol", B_HARDWARE_CONTROL | B_SOFTWARE_CONTROL);
|
||||||
BMenuItem* both = new BMenuItem("Both", message);
|
BMenuItem* both =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("Both", "Flowcontrol"), message);
|
||||||
|
|
||||||
message = new BMessage(kMsgSettings);
|
message = new BMessage(kMsgSettings);
|
||||||
message->AddInt32("flowcontrol", 0);
|
message->AddInt32("flowcontrol", 0);
|
||||||
BMenuItem* noFlow = new BMenuItem("None", message);
|
BMenuItem* noFlow =
|
||||||
|
new BMenuItem(B_TRANSLATE_COMMENT("None", "Flowcontrol"), message);
|
||||||
|
|
||||||
fFlowcontrolMenu->AddItem(hardware);
|
fFlowcontrolMenu->AddItem(hardware);
|
||||||
fFlowcontrolMenu->AddItem(software);
|
fFlowcontrolMenu->AddItem(software);
|
||||||
@@ -292,14 +309,15 @@ void SerialWindow::MenusBeginning()
|
|||||||
if (deviceCount > 0) {
|
if (deviceCount > 0) {
|
||||||
fConnectionMenu->AddSeparatorItem();
|
fConnectionMenu->AddSeparatorItem();
|
||||||
|
|
||||||
BMenuItem* disconnect = new BMenuItem("Disconnect",
|
BMenuItem* disconnect = new BMenuItem(B_TRANSLATE("Disconnect"),
|
||||||
new BMessage(kMsgOpenPort), 'Z', B_OPTION_KEY);
|
new BMessage(kMsgOpenPort), 'Z', B_OPTION_KEY);
|
||||||
if (!connected)
|
if (!connected)
|
||||||
disconnect->SetEnabled(false);
|
disconnect->SetEnabled(false);
|
||||||
disconnect->SetTarget(be_app);
|
disconnect->SetTarget(be_app);
|
||||||
fConnectionMenu->AddItem(disconnect);
|
fConnectionMenu->AddItem(disconnect);
|
||||||
} else {
|
} else {
|
||||||
BMenuItem* noDevices = new BMenuItem("<no serial port available>", NULL);
|
BMenuItem* noDevices =
|
||||||
|
new BMenuItem(B_TRANSLATE("<no serial port available>"), NULL);
|
||||||
noDevices->SetEnabled(false);
|
noDevices->SetEnabled(false);
|
||||||
fConnectionMenu->AddItem(noDevices);
|
fConnectionMenu->AddItem(noDevices);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,12 +8,16 @@
|
|||||||
|
|
||||||
#include "SerialApp.h"
|
#include "SerialApp.h"
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define B_TRANSLATION_CONTEXT "XModemStatus"
|
||||||
|
|
||||||
|
|
||||||
// ASCII control characters used in XMODEM protocol
|
// ASCII control characters used in XMODEM protocol
|
||||||
static const char kSOH = 1;
|
static const char kSOH = 1;
|
||||||
static const char kEOT = 4;
|
static const char kEOT = 4;
|
||||||
@@ -33,7 +37,7 @@ XModemSender::XModemSender(BDataIO* source, BSerialPort* sink, BHandler* listene
|
|||||||
fEotSent(false),
|
fEotSent(false),
|
||||||
fUseCRC(false)
|
fUseCRC(false)
|
||||||
{
|
{
|
||||||
fStatus = "Waiting for receiver" B_UTF8_ELLIPSIS;
|
fStatus = B_TRANSLATE("Waiting for receiver" B_UTF8_ELLIPSIS);
|
||||||
|
|
||||||
BPositionIO* pos = dynamic_cast<BPositionIO*>(source);
|
BPositionIO* pos = dynamic_cast<BPositionIO*>(source);
|
||||||
if (pos)
|
if (pos)
|
||||||
@@ -65,7 +69,7 @@ XModemSender::BytesReceived(const uint8_t* data, size_t length)
|
|||||||
// in place of an 8-bit checksum.
|
// in place of an 8-bit checksum.
|
||||||
// In any other place, it is ignored.
|
// In any other place, it is ignored.
|
||||||
if (fBlockNumber <= 1) {
|
if (fBlockNumber <= 1) {
|
||||||
fStatus = "CRC requested";
|
fStatus = B_TRANSLATE("CRC requested");
|
||||||
fUseCRC = true;
|
fUseCRC = true;
|
||||||
SendBlock();
|
SendBlock();
|
||||||
} else
|
} else
|
||||||
@@ -74,7 +78,7 @@ XModemSender::BytesReceived(const uint8_t* data, size_t length)
|
|||||||
if (fEotSent) {
|
if (fEotSent) {
|
||||||
fSink->Write(&kEOT, 1);
|
fSink->Write(&kEOT, 1);
|
||||||
} else {
|
} else {
|
||||||
fStatus = "Checksum error, re-send block";
|
fStatus = B_TRANSLATE("Checksum error, re-send block");
|
||||||
SendBlock();
|
SendBlock();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -85,10 +89,11 @@ XModemSender::BytesReceived(const uint8_t* data, size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NextBlock() == B_OK) {
|
if (NextBlock() == B_OK) {
|
||||||
fStatus = "Sending" B_UTF8_ELLIPSIS;
|
fStatus = B_TRANSLATE("Sending" B_UTF8_ELLIPSIS);
|
||||||
SendBlock();
|
SendBlock();
|
||||||
} else {
|
} else {
|
||||||
fStatus = "Everything sent, waiting for acknowledge";
|
fStatus = B_TRANSLATE("Everything sent, "
|
||||||
|
"waiting for acknowledge");
|
||||||
fSink->Write(&kEOT, 1);
|
fSink->Write(&kEOT, 1);
|
||||||
fEotSent = true;
|
fEotSent = true;
|
||||||
}
|
}
|
||||||
@@ -99,7 +104,8 @@ XModemSender::BytesReceived(const uint8_t* data, size_t length)
|
|||||||
BMessage msg(kMsgProgress);
|
BMessage msg(kMsgProgress);
|
||||||
msg.AddInt32("pos", 0);
|
msg.AddInt32("pos", 0);
|
||||||
msg.AddInt32("size", 0);
|
msg.AddInt32("size", 0);
|
||||||
msg.AddString("info", "Remote cancelled transfer");
|
msg.AddString("info",
|
||||||
|
B_TRANSLATE("Remote cancelled transfer"));
|
||||||
fListener.SendMessage(&msg);
|
fListener.SendMessage(&msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user