Ticket #5970: bin_dstcheck.patch

File bin_dstcheck.patch, 2.6 KB (added by Karvjorm, 14 years ago)

Localization and 24-hour patch for the dstcheck application

  • src/bin/dstcheck.cpp

     
    66
    77#include <Alert.h>
    88#include <Application.h>
     9#include <Catalog.h>
    910#include <FindDirectory.h>
     11#include <Locale.h>
    1012#include <MessageRunner.h>
    1113#include <Roster.h>
    1214#include <String.h>
     
    1921
    2022const uint32 TIMEDALERT_UPDATE = 'taup';
    2123
     24#define B_TRANSLATE_CONTEXT "dstcheck"
     25
    2226class TimedAlert : public BAlert {
    2327    public:
    2428        TimedAlert(const char *title, const char *text, const char *button1,
     
    3135
    3236    private:
    3337        BMessageRunner *fRunner;
     38        BCatalog    fCatalog;
    3439};
    3540
    3641
     
    6772void
    6873TimedAlert::GetLabel(BString &string)
    6974{
    70     string = "Attention!\n\nBecause of the switch from daylight saving time, "
    71         "your computer's clock may be an hour off. Currently, your computer "
    72         "thinks it is ";
     75    string = B_TRANSLATE("Attention!\n\nBecause of the switch from daylight "
     76        "saving time, your computer's clock may be an hour off. Currently, "
     77        "your computer thinks it is ");
    7378
    7479    time_t t;
    7580    struct tm tm;
    7681    char timestring[15];
    7782    time(&t);
    7883    localtime_r(&t, &tm);
    79     strftime(timestring, 15, "%I:%M %p", &tm);
     84    if (be_locale->Country()->IsClock24Hour())
     85        strftime(timestring, 15, "%H:%M", &tm);
     86    else
     87        strftime(timestring, 15, "%I:%M %p", &tm);
    8088    string += timestring;
    8189
    82     string += ".\n\nIs this the correct time?";
     90    string += B_TRANSLATE(".\n\nIs this the correct time?");
    8391}
    8492
    8593
     
    93101    struct tm tm;
    94102    tzset();
    95103    time(&t);
    96     localtime_r(&t, &tm);   
     104    localtime_r(&t, &tm);
    97105
    98106    char path[B_PATH_NAME_LENGTH]; 
    99107    if (find_directory(B_USER_SETTINGS_DIRECTORY, -1, true, path, B_PATH_NAME_LENGTH) != B_OK) {
     
    123131
    124132    if (dst != tm.tm_isdst) {
    125133        BApplication app("application/x-vnd.Haiku-cmd-dstconfig"); 
     134        be_locale->GetAppCatalog(&fAppCatalog);
    126135
    127136        BString string;
    128137        TimedAlert::GetLabel(string);
    129138
    130         int32 index = (new TimedAlert("timedAlert", string.String(), "Ask me later", "Yes", "No"))->Go();
     139        int32 index = (new TimedAlert("timedAlert", string.String(),
     140            B_TRANSLATE("Ask me later"), B_TRANSLATE("Yes"),
     141            B_TRANSLATE("No")))->Go();
    131142        if (index == 0)
    132143            exit(0);
    133144
    134145        if (index == 2) {
    135146            index = (new BAlert("dstcheck",
    136                 "Would you like to set the clock using the Time and\nDate preference utility?",
    137                 "No", "Yes"))->Go();
     147                B_TRANSLATE("Would you like to set the clock using the Time "
     148                    "and\nDate preference utility?"),
     149                B_TRANSLATE("No"), B_TRANSLATE("Yes")))->Go();
    138150
    139151            if (index == 1)
    140152                be_roster->Launch("application/x-vnd.Haiku-Time");