Ticket #2412: net_time_loc.patch

File net_time_loc.patch, 5.7 KB (added by hamish, 13 years ago)

Adds more localisation

  • src/preferences/time/ntp.cpp

     
    1717
    1818#include <OS.h>
    1919
     20#include <Catalog.h>
    2021
     22
     23#undef B_TRANSLATE_CONTEXT
     24#define B_TRANSLATE_CONTEXT "Time"
     25
     26
    2127/* This structure and its data fields are described in RFC 1305
    2228 * "Network Time Protocol (Version 3)" in appendix A.
    2329 */
     
    112118
    113119    if (server == NULL) {
    114120   
    115         *errorString = "Could not contact server";
     121        *errorString = B_TRANSLATE("Could not contact server");
    116122        return B_ENTRY_NOT_FOUND;
    117123    }
    118124
     
    133139
    134140    int connection = socket(AF_INET, SOCK_DGRAM, 0);
    135141    if (connection < 0) {
    136         *errorString = "Could not create socket";
     142        *errorString = B_TRANSLATE("Could not create socket");
    137143        *errorCode = errno;
    138144        return B_ERROR;
    139145    }
     
    145151
    146152    if (sendto(connection, (char *)&message, sizeof(ntp_data),
    147153            0, (struct sockaddr *)&address, sizeof(address)) < 0) {
    148         *errorString = "Sending request failed";
     154        *errorString = B_TRANSLATE("Sending request failed");
    149155        *errorCode = errno;
    150156        return B_ERROR;
    151157    }
     
    160166    // we'll wait 3 seconds for the answer
    161167
    162168    if (select(connection + 1, &waitForReceived, NULL, NULL, &timeout) <= 0) {
    163         *errorString = "Waiting for answer failed";
     169        *errorString = B_TRANSLATE("Waiting for answer failed");
    164170        *errorCode = errno;
    165171        return B_ERROR;
    166172    }
     
    170176    socklen_t addressSize = sizeof(address);
    171177    if (recvfrom(connection, (char *)&message, sizeof(ntp_data), 0,
    172178            (sockaddr *)&address, &addressSize) < (ssize_t)sizeof(ntp_data)) {
    173         *errorString = "Message receiving failed";
     179        *errorString = B_TRANSLATE("Message receiving failed");
    174180        *errorCode = errno;
    175181        close(connection);
    176182        return B_ERROR;
     
    179185    close(connection);
    180186
    181187    if (message.transmit_timestamp.Integer() == 0) {
    182         *errorString = "Received invalid time";
     188        *errorString = B_TRANSLATE("Received invalid time");
    183189        return B_BAD_VALUE;
    184190    }
    185191
  • src/preferences/time/NetworkTimeView.cpp

     
    3131#undef B_TRANSLATE_CONTEXT
    3232#define B_TRANSLATE_CONTEXT "Time"
    3333
     34
    3435Settings::Settings()
    3536    :
    3637    fMessage(kMsgNetworkTimeSettings)
     
    293294            _UpdateServerList();
    294295            Looper()->PostMessage(new BMessage(kMsgChange));
    295296            break;
    296            
     297
    297298        case kMsgResetServerList:
    298299            fSettings.ResetServersToDefaults();
    299300            _UpdateServerList();
    300301            Looper()->PostMessage(new BMessage(kMsgChange));
    301302            break;
    302        
     303
    303304        case kMsgTryAllServers:
    304305            fSettings.SetTryAllServers(
    305306                fTryAllServersCheckBox->Value());
     
    325326
    326327            BMessenger* messenger = new BMessenger(this);
    327328            update_time(fSettings, messenger, &fUpdateThread);
    328             fSynchronizeButton->SetLabel("Stop");
     329            fSynchronizeButton->SetLabel(B_TRANSLATE("Stop"));
    329330            fSynchronizeButton->Message()->what = kMsgStopSynchronization;
    330331            break;
    331332        }
     
    341342                const char* errorString;
    342343                message->FindString("error string", &errorString); 
    343344                char buffer[256];
    344                    
     345
    345346                int32 errorCode;
    346347                if (message->FindInt32("error code", &errorCode)
    347348                    == B_OK)
    348349                    snprintf(buffer, sizeof(buffer),
    349                         "The following error occured "
    350                         "while synchronizing:\r\n%s: %s",
     350                        B_TRANSLATE("The following error occured "
     351                        "while synchronizing:\r\n%s: %s"),
    351352                        errorString, strerror(errorCode));
    352353                else
    353354                    snprintf(buffer, sizeof(buffer),
    354                         "The following error occured "
    355                         "while synchronizing:\r\n%s",
     355                        B_TRANSLATE("The following error occured "
     356                        "while synchronizing:\r\n%s"),
    356357                        errorString);
    357358
    358                 (new BAlert("Time", buffer, "OK"))->Go();
     359                (new BAlert(B_TRANSLATE("Time"), buffer,
     360                    B_TRANSLATE("OK")))->Go();
    359361            }
    360362            break;
    361363        }
     
    409411    BScrollView* scrollView = new BScrollView("serverScrollView",
    410412        fServerListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
    411413    _UpdateServerList();
    412    
     414
    413415    fTryAllServersCheckBox = new BCheckBox("tryAllServers",
    414416        B_TRANSLATE("Try all servers"), new BMessage(kMsgTryAllServers));
    415417    fTryAllServersCheckBox->SetValue(fSettings.GetTryAllServers());
    416    
    417     fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate",
    418         B_TRANSLATE("Synchronize at boot"), new BMessage(kMsgSynchronizeAtBoot));
     418
     419    fSynchronizeAtBootCheckBox = new BCheckBox("autoUpdate",
     420        B_TRANSLATE("Synchronize at boot"),
     421        new BMessage(kMsgSynchronizeAtBoot));
    419422    fSynchronizeAtBootCheckBox->SetValue(fSettings.GetSynchronizeAtBoot());
    420     fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize now"),
     423    fSynchronizeButton = new BButton("update", B_TRANSLATE("Synchronize"),
    421424        new BMessage(kMsgSynchronize));
    422425    fSynchronizeButton->SetExplicitAlignment(
    423426        BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
    424    
     427
    425428    const float kInset = be_control_look->DefaultItemSpacing();
    426429    BLayoutBuilder::Group<>(this)
    427430        .AddGroup(B_HORIZONTAL)
     
    467470NetworkTimeView::_DoneSynchronizing()
    468471{
    469472    fUpdateThread = -1;
    470     fSynchronizeButton->SetLabel(B_TRANSLATE("Synchronize again"));
     473    fSynchronizeButton->SetLabel(B_TRANSLATE("Synchronize"));
    471474    fSynchronizeButton->Message()->what = kMsgSynchronize;
    472475}
    473476
     
    480483
    481484    status_t status = B_ENTRY_NOT_FOUND;
    482485    const char* server = settings.GetServer(defaultServer);
    483    
     486
    484487    if (server != NULL)
    485488        status = ntp_update_time(server, errorString, errorCode);
    486489
     
    497500                break;
    498501        }
    499502    }
    500    
     503
    501504    return status;
    502505}
    503506
     
    519522    if (errorCode != 0)
    520523        result.AddInt32("error code", errorCode);
    521524    messenger->SendMessage(&result);
    522    
     525
    523526    delete messenger;
    524527    return B_OK;
    525528}