Apply another patch from Hamish from ticket #2412 which adds more localization

and removes unneeded whitespace. Thanks!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2011-06-06 03:03:53 +00:00
parent b184abda90
commit 8c333297c1
3 changed files with 34 additions and 24 deletions

View File

@ -39,6 +39,7 @@ DoCatalogs Time :
: :
DateTimeView.cpp DateTimeView.cpp
NetworkTimeView.cpp NetworkTimeView.cpp
ntp.cpp
Time.cpp Time.cpp
TimeWindow.cpp TimeWindow.cpp
ZoneView.cpp ZoneView.cpp

View File

@ -31,6 +31,7 @@
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Time" #define B_TRANSLATE_CONTEXT "Time"
Settings::Settings() Settings::Settings()
: :
fMessage(kMsgNetworkTimeSettings) fMessage(kMsgNetworkTimeSettings)
@ -293,13 +294,13 @@ NetworkTimeView::MessageReceived(BMessage* message)
_UpdateServerList(); _UpdateServerList();
Looper()->PostMessage(new BMessage(kMsgChange)); Looper()->PostMessage(new BMessage(kMsgChange));
break; break;
case kMsgResetServerList: case kMsgResetServerList:
fSettings.ResetServersToDefaults(); fSettings.ResetServersToDefaults();
_UpdateServerList(); _UpdateServerList();
Looper()->PostMessage(new BMessage(kMsgChange)); Looper()->PostMessage(new BMessage(kMsgChange));
break; break;
case kMsgTryAllServers: case kMsgTryAllServers:
fSettings.SetTryAllServers( fSettings.SetTryAllServers(
fTryAllServersCheckBox->Value()); fTryAllServersCheckBox->Value());
@ -325,7 +326,7 @@ NetworkTimeView::MessageReceived(BMessage* message)
BMessenger* messenger = new BMessenger(this); BMessenger* messenger = new BMessenger(this);
update_time(fSettings, messenger, &fUpdateThread); update_time(fSettings, messenger, &fUpdateThread);
fSynchronizeButton->SetLabel("Stop"); fSynchronizeButton->SetLabel(B_TRANSLATE("Stop"));
fSynchronizeButton->Message()->what = kMsgStopSynchronization; fSynchronizeButton->Message()->what = kMsgStopSynchronization;
break; break;
} }
@ -341,21 +342,22 @@ NetworkTimeView::MessageReceived(BMessage* message)
const char* errorString; const char* errorString;
message->FindString("error string", &errorString); message->FindString("error string", &errorString);
char buffer[256]; char buffer[256];
int32 errorCode; int32 errorCode;
if (message->FindInt32("error code", &errorCode) if (message->FindInt32("error code", &errorCode)
== B_OK) == B_OK)
snprintf(buffer, sizeof(buffer), snprintf(buffer, sizeof(buffer),
"The following error occured " B_TRANSLATE("The following error occured "
"while synchronizing:\r\n%s: %s", "while synchronizing:\r\n%s: %s"),
errorString, strerror(errorCode)); errorString, strerror(errorCode));
else else
snprintf(buffer, sizeof(buffer), snprintf(buffer, sizeof(buffer),
"The following error occured " B_TRANSLATE("The following error occured "
"while synchronizing:\r\n%s", "while synchronizing:\r\n%s"),
errorString); errorString);
(new BAlert("Time", buffer, "OK"))->Go(); (new BAlert(B_TRANSLATE("Time"), buffer,
B_TRANSLATE("OK")))->Go();
} }
break; break;
} }
@ -409,19 +411,20 @@ NetworkTimeView::_InitView()
BScrollView* scrollView = new BScrollView("serverScrollView", BScrollView* scrollView = new BScrollView("serverScrollView",
fServerListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fServerListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
_UpdateServerList(); _UpdateServerList();
fTryAllServersCheckBox = new BCheckBox("tryAllServers", fTryAllServersCheckBox = new BCheckBox("tryAllServers",
B_TRANSLATE("Try all servers"), new BMessage(kMsgTryAllServers)); B_TRANSLATE("Try all servers"), new BMessage(kMsgTryAllServers));
fTryAllServersCheckBox->SetValue(fSettings.GetTryAllServers()); fTryAllServersCheckBox->SetValue(fSettings.GetTryAllServers());
fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate", fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate",
B_TRANSLATE("Synchronize at boot"), new BMessage(kMsgSynchronizeAtBoot)); B_TRANSLATE("Synchronize at boot"),
new BMessage(kMsgSynchronizeAtBoot));
fSynchronizeAtBootCheckBox->SetValue(fSettings.GetSynchronizeAtBoot()); fSynchronizeAtBootCheckBox->SetValue(fSettings.GetSynchronizeAtBoot());
fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize now"), fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize"),
new BMessage(kMsgSynchronize)); new BMessage(kMsgSynchronize));
fSynchronizeButton->SetExplicitAlignment( fSynchronizeButton->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM)); BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
const float kInset = be_control_look->DefaultItemSpacing(); const float kInset = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(this) BLayoutBuilder::Group<>(this)
.AddGroup(B_HORIZONTAL) .AddGroup(B_HORIZONTAL)
@ -480,7 +483,7 @@ update_time(const Settings& settings, const char** errorString,
status_t status = B_ENTRY_NOT_FOUND; status_t status = B_ENTRY_NOT_FOUND;
const char* server = settings.GetServer(defaultServer); const char* server = settings.GetServer(defaultServer);
if (server != NULL) if (server != NULL)
status = ntp_update_time(server, errorString, errorCode); status = ntp_update_time(server, errorString, errorCode);
@ -497,7 +500,7 @@ update_time(const Settings& settings, const char** errorString,
break; break;
} }
} }
return status; return status;
} }
@ -519,7 +522,7 @@ update_thread(void* params)
if (errorCode != 0) if (errorCode != 0)
result.AddInt32("error code", errorCode); result.AddInt32("error code", errorCode);
messenger->SendMessage(&result); messenger->SendMessage(&result);
delete messenger; delete messenger;
return B_OK; return B_OK;
} }

View File

@ -17,6 +17,12 @@
#include <OS.h> #include <OS.h>
#include <Catalog.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Time"
/* This structure and its data fields are described in RFC 1305 /* This structure and its data fields are described in RFC 1305
* "Network Time Protocol (Version 3)" in appendix A. * "Network Time Protocol (Version 3)" in appendix A.
@ -112,7 +118,7 @@ ntp_update_time(const char* hostname, const char** errorString,
if (server == NULL) { if (server == NULL) {
*errorString = "Could not contact server"; *errorString = B_TRANSLATE("Could not contact server");
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
} }
@ -133,7 +139,7 @@ ntp_update_time(const char* hostname, const char** errorString,
int connection = socket(AF_INET, SOCK_DGRAM, 0); int connection = socket(AF_INET, SOCK_DGRAM, 0);
if (connection < 0) { if (connection < 0) {
*errorString = "Could not create socket"; *errorString = B_TRANSLATE("Could not create socket");
*errorCode = errno; *errorCode = errno;
return B_ERROR; return B_ERROR;
} }
@ -145,7 +151,7 @@ ntp_update_time(const char* hostname, const char** errorString,
if (sendto(connection, (char *)&message, sizeof(ntp_data), if (sendto(connection, (char *)&message, sizeof(ntp_data),
0, (struct sockaddr *)&address, sizeof(address)) < 0) { 0, (struct sockaddr *)&address, sizeof(address)) < 0) {
*errorString = "Sending request failed"; *errorString = B_TRANSLATE("Sending request failed");
*errorCode = errno; *errorCode = errno;
return B_ERROR; return B_ERROR;
} }
@ -160,7 +166,7 @@ ntp_update_time(const char* hostname, const char** errorString,
// we'll wait 3 seconds for the answer // we'll wait 3 seconds for the answer
if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) { if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) {
*errorString = "Waiting for answer failed"; *errorString = B_TRANSLATE("Waiting for answer failed");
*errorCode = errno; *errorCode = errno;
return B_ERROR; return B_ERROR;
} }
@ -170,7 +176,7 @@ ntp_update_time(const char* hostname, const char** errorString,
socklen_t addressSize = sizeof(address); socklen_t addressSize = sizeof(address);
if (recvfrom(connection, (char *)&message, sizeof(ntp_data), 0, if (recvfrom(connection, (char *)&message, sizeof(ntp_data), 0,
(sockaddr *)&address, &addressSize) < (ssize_t)sizeof(ntp_data)) { (sockaddr *)&address, &addressSize) < (ssize_t)sizeof(ntp_data)) {
*errorString = "Message receiving failed"; *errorString = B_TRANSLATE("Message receiving failed");
*errorCode = errno; *errorCode = errno;
close(connection); close(connection);
return B_ERROR; return B_ERROR;
@ -179,7 +185,7 @@ ntp_update_time(const char* hostname, const char** errorString,
close(connection); close(connection);
if (message.transmit_timestamp.Integer() == 0) { if (message.transmit_timestamp.Integer() == 0) {
*errorString = "Received invalid time"; *errorString = B_TRANSLATE("Received invalid time");
return B_BAD_VALUE; return B_BAD_VALUE;
} }