Ticket #5908: codycamLocalization.2.patch

File codycamLocalization.2.patch, 36.0 KB (added by Karvjorm, 12 years ago)

A fixed localization patch for CodyCam application.

  • src/apps/codycam/SettingsHandler.cpp

     
    55#include <stdlib.h>
    66#include <string.h>
    77
     8#include <Catalog.h>
    89#include <Debug.h>
    910#include <Directory.h>
    1011#include <Entry.h>
     
    1314#include <Path.h>
    1415#include <StopWatch.h>
    1516
     17#undef TR_CONTEXT
     18#define TR_CONTEXT "SettingsHandler"
    1619
     20#define B_TRANSLATE(str) \
     21    be_catalog->GetString((str), TR_CONTEXT)
     22
    1723#if 0
    1824static int
    1925Compare(const SettingsArgvDispatcher* p1, const SettingsArgvDispatcher* p2)
     
    5662{
    5763    fFile = fopen(fFileName, "r");
    5864    if (!fFile) {
    59         PRINT(("Error opening %s\n", fFileName));
     65        PRINT((B_TRANSLATE("Error opening %s\n"), fFileName));
    6066        return;
    6167    }
    6268    fBuffer = new char [kBufferSize];
     
    95101        fCurrentArgv[fArgc] = 0;
    96102        const char *result = (argvHandlerFunc)(fArgc, fCurrentArgv, passThru);
    97103        if (result)
    98             printf("File %s; Line %ld # %s", fFileName, fLineNo, result);
     104            printf(B_TRANSLATE("File %s; Line %ld # %s"), fFileName, fLineNo, result);
    99105        MakeArgvEmpty();
    100106        if (result)
    101107            return B_ERROR;
     
    148154
    149155
    150156status_t
    151 ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc, void* passThru)
     157ArgvParser::EachArgv(const char* name, ArgvHandler argvHandlerFunc,
     158    void* passThru)
    152159{
    153160    ArgvParser parser(name);
    154161    return parser.EachArgvPrivate(name, argvHandlerFunc, passThru);
     
    166173        if (ch == EOF) {
    167174            // done with file
    168175            if (fInDoubleQuote || fInSingleQuote) {
    169                 printf("File %s # unterminated quote at end of file\n", name);
     176                printf(B_TRANSLATE("File %s # unterminated quote at end of "
     177                    "file\n"), name);
    170178                result = B_ERROR;
    171179                break;
    172180            }
     
    178186            // handle new line
    179187            fEatComment = false;
    180188            if (!fSawBackslash && (fInDoubleQuote || fInSingleQuote)) {
    181                 printf("File %s ; Line %ld # unterminated quote\n", name, fLineNo);
     189                printf(B_TRANSLATE("File %s ; Line %ld # unterminated "
     190                    "quote\n"), name, fLineNo);
    182191                result = B_ERROR;
    183192                break;
    184193            }
     
    350359
    351360    SettingsArgvDispatcher* handler = settings->_Find(*argv);
    352361    if (!handler)
    353         return "unknown command";
     362        return B_TRANSLATE("unknown command");
    354363    return handler->Handle(argv);
    355364}
    356365
  • src/apps/codycam/Settings.cpp

     
    44#include <stdlib.h>
    55#include <string.h>
    66
     7#include <Catalog.h>
    78#include <Debug.h>
     9#include <Locale.h>
    810
     11#undef TR_CONTEXT
     12#define TR_CONTEXT "Settings"
    913
     14#define B_TRANSLATE(str) \
     15    be_catalog->GetString((str), TR_CONTEXT)
     16
     17#define B_TRANSLATE_CMT(str,cmt) \
     18    be_catalog->GetString((str), TR_CONTEXT, (cmt))
     19
    1020Settings* settings = NULL;
    1121
    1222
     
    230240BooleanValueSetting::Handle(const char *const *argv)
    231241{
    232242    if (!*++argv)
    233         return "on or off expected";
     243        return B_TRANSLATE_CMT("on or off expected","Do not translate 'on' and 'off'");
    234244
    235245    if (strcmp(*argv, "on") == 0)
    236246        fValue = true;
    237247    else if (strcmp(*argv, "off") == 0)
    238248        fValue = false;
    239249    else
    240         return "on or off expected";
     250        return B_TRANSLATE_CMT("on or off expected", "Do not translate 'on' and 'off'");
    241251
    242252    return 0;
    243253}
  • src/apps/codycam/SftpClient.cpp

     
    2626    cmd << " " << dir.c_str() << "\n";
    2727    SendCommand(cmd.String());
    2828    if ((len = ReadReply(&reply)) < 0) {
    29         fprintf(stderr, "read: %d\n", len);
     29        fprintf(stderr, GetReadText(), len);
    3030        return false;
    3131    }
    32     fprintf(stderr, "reply: '%s'\n", reply.String());
     32    fprintf(stderr, GetReplyText(), reply.String());
    3333    if (reply.FindFirst("sftp>") < 0)
    3434        return false;
    3535    rc = true;
     
    4646    BString reply;
    4747    do {
    4848        if ((len = ReadReply(&reply)) < 0) {
    49             fprintf(stderr, "read: %d\n", len);
     49            fprintf(stderr, GetReadText(), len);
    5050            return false;
    5151        }
    52         fprintf(stderr, "reply: '%s'\n", reply.String());
     52        fprintf(stderr, GetReplyText(), reply.String());
    5353        printf("%s", reply.String());
    5454        if (reply.FindFirst("sftp>") == 0)
    5555            return true;
     
    6969
    7070
    7171bool
    72 SftpClient::Connect(const string& server, const string& login, const string& passwd)
     72SftpClient::Connect(const string& server, const string& login,
     73    const string& passwd)
    7374{
    7475    bool rc = false;
    7576    BString cmd("sftp ");
     
    8990    ssize_t len;
    9091   
    9192    if ((len = ReadReply(&reply)) < 0) {
    92         fprintf(stderr, "read: %ld\n", len);
     93        fprintf(stderr, GetLongReadText(), len);
    9394        return false;
    9495    }
    95     fprintf(stderr, "reply: '%s'\n", reply.String());
     96    fprintf(stderr, GetReplyText(), reply.String());
    9697    if (reply.FindFirst("Connecting to ") != 0)
    9798        return false;
    9899   
    99100    if ((len = ReadReply(&reply)) < 0) {
    100         fprintf(stderr, "read: %ld\n", len);
     101        fprintf(stderr, GetLongReadText(), len);
    101102        return false;
    102103    }
    103     fprintf(stderr, "reply: '%s'\n", reply.String());
     104    fprintf(stderr, GetReplyText(), reply.String());
    104105    if (reply.FindFirst(/*[pP]*/"assword:") < 0)
    105106        return false;
    106107   
     
    108109    write(OutputPipe(), "\n", 1);
    109110   
    110111    if ((len = ReadReply(&reply)) < 0) {
    111         fprintf(stderr, "read: %ld\n", len);
     112        fprintf(stderr, GetLongReadText(), len);
    112113        return false;
    113114    }
    114     fprintf(stderr, "reply: '%s'\n", reply.String());
     115    fprintf(stderr, GetReplyText(), reply.String());
    115116    if (reply != "\n")
    116117        return false;
    117118   
    118119    if ((len = ReadReply(&reply)) < 0) {
    119         fprintf(stderr, "read: %ld\n", len);
     120        fprintf(stderr, GetLongReadText(), len);
    120121        return false;
    121122    }
    122     fprintf(stderr, "reply: '%s'\n", reply.String());
     123    fprintf(stderr, GetReplyText(), reply.String());
    123124    if (reply.FindFirst("sftp>") < 0)
    124125        return false;
    125126    return rc;
     
    138139    BString reply;
    139140
    140141    if ((len = ReadReply(&reply)) < 0) {
    141         fprintf(stderr, "read: %d\n", len);
     142        fprintf(stderr, GetReadText(), len);
    142143        return false;
    143144    }
    144     fprintf(stderr, "reply: '%s'\n", reply.String());
     145    fprintf(stderr, GetReplyText(), reply.String());
    145146    if (reply.FindFirst("Uploading") < 0)
    146147        return false;
    147148
    148149    if ((len = ReadReply(&reply)) < 0) {
    149         fprintf(stderr, "read: %d\n", len);
     150        fprintf(stderr, GetReadText(), len);
    150151        return false;
    151152    }
    152     fprintf(stderr, "reply: '%s'\n", reply.String());
     153    fprintf(stderr, GetReplyText(), reply.String());
    153154    if (reply.FindFirst("sftp>") < 0)
    154155        return false;
    155156
     
    183184    BString reply;
    184185
    185186    if ((len = ReadReply(&reply)) < 0) {
    186         fprintf(stderr, "read: %d\n", len);
     187        fprintf(stderr, GetReadText(), len);
    187188        return false;
    188189    }
    189     fprintf(stderr, "reply: '%s'\n", reply.String());
     190    fprintf(stderr, GetReplyText(), reply.String());
    190191    // we don't care if it worked or not.
    191192    //if (reply.FindFirst("Removing") != 0 && reply.FindFirst("Couldn't") )
    192193    //  return false;
    193194
    194195    if ((len = ReadReply(&reply)) < 0) {
    195         fprintf(stderr, "read: %d\n", len);
     196        fprintf(stderr, GetReadText(), len);
    196197        return false;
    197198    }
    198     fprintf(stderr, "reply: '%s'\n", reply.String());
     199    fprintf(stderr, GetReplyText(), reply.String());
    199200    if (reply.FindFirst("sftp>") < 0)
    200201        return false;
    201202
     
    203204    cmd << " " << oldPath.c_str() << " " << newPath.c_str() << "\n";
    204205    SendCommand(cmd.String());
    205206    if ((len = ReadReply(&reply)) < 0) {
    206         fprintf(stderr, "read: %d\n", len);
     207        fprintf(stderr, GetReadText(), len);
    207208        return false;
    208209    }
    209     fprintf(stderr, "reply: '%s'\n", reply.String());
     210    fprintf(stderr, GetReplyText(), reply.String());
    210211    if (reply.FindFirst("sftp>") < 0)
    211212        return false;
    212213    rc = true;
     
    226227    BString reply;
    227228
    228229    if ((len = ReadReply(&reply)) < 0) {
    229         fprintf(stderr, "read: %d\n", len);
     230        fprintf(stderr, GetReadText(), len);
    230231        return false;
    231232    }
    232     fprintf(stderr, "reply: '%s'\n", reply.String());
     233    fprintf(stderr, GetReplyText(), reply.String());
    233234    if (reply.FindFirst("Changing") < 0)
    234235        return false;
    235236
    236237    if ((len = ReadReply(&reply)) < 0) {
    237         fprintf(stderr, "read: %d\n", len);
     238        fprintf(stderr, GetReadText(), len);
    238239        return false;
    239240    }
    240     fprintf(stderr, "reply: '%s'\n", reply.String());
     241    fprintf(stderr, GetReplyText(), reply.String());
    241242    if (reply.FindFirst("sftp>") < 0)
    242243        return false;
    243244
  • src/apps/codycam/CodyCam.cpp

     
    127127    fVideoConsumer(NULL),
    128128    fWindow(NULL),
    129129    fPort(0),
    130     fVideoControlWindow(NULL)
     130    fVideoControlWindow(NULL),
     131    fAppCatalog(NULL)
    131132{
     133    be_locale->GetAppCatalog(&fAppCatalog);
    132134    chdir("/boot/home");
    133135}
    134136
     
    152154CodyCam::ReadyToRun()
    153155{
    154156    fWindow = new VideoWindow(BRect(28, 28, 28, 28),
    155         (const char*) "CodyCam", B_TITLED_WINDOW,
     157        (const char*) B_TRANSLATE("CodyCam"), B_TITLED_WINDOW,
    156158        B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, &fPort);
    157159
    158160    _SetUpNodes();
     
    178180    switch (message->what) {
    179181        case msg_start:
    180182        {
    181             BTimeSource* timeSource = fMediaRoster->MakeTimeSourceFor(fTimeSourceNode);
     183            BTimeSource* timeSource = fMediaRoster->MakeTimeSourceFor(
     184                fTimeSourceNode);
    182185            bigtime_t real = BTimeSource::RealTime();
    183186            bigtime_t perf = timeSource->PerformanceTimeFor(real) + 10000;
    184187            status_t status = fMediaRoster->StartNode(fProducerNode, perf);
     
    208211                    BRect(2 * WINDOW_OFFSET_X + WINDOW_SIZE_X, WINDOW_OFFSET_Y,
    209212                    2 * WINDOW_OFFSET_X + WINDOW_SIZE_X + view->Bounds().right,
    210213                    WINDOW_OFFSET_Y + view->Bounds().bottom), view, node);
    211                 fMediaRoster->StartWatching(BMessenger(NULL, fVideoControlWindow), node,
    212                     B_MEDIA_WEB_CHANGED);
     214                fMediaRoster->StartWatching(BMessenger(NULL,
     215                    fVideoControlWindow), node, B_MEDIA_WEB_CHANGED);
    213216                fVideoControlWindow->Show();
    214217            }
    215218            break;
    216219        }
    217220
    218221        case msg_about:
    219             (new BAlert("About CodyCam", "CodyCam\n\nThe Original BeOS webcam",
    220                 "Close"))->Go();
     222            (new BAlert(B_TRANSLATE("About CodyCam"), B_TRANSLATE("CodyCam\n\n"
     223                "The Original BeOS webcam"), B_TRANSLATE("Close")))->Go();
    221224            break;
    222225
    223226        case msg_control_win:
     
    241244    /* find the media roster */
    242245    fMediaRoster = BMediaRoster::Roster(&status);
    243246    if (status != B_OK) {
    244         ErrorAlert("Cannot find the media roster", status, fWindow);
     247        ErrorAlert(B_TRANSLATE("Cannot find the media roster"), status,
     248            fWindow);
    245249        return status;
    246250    }
    247251
    248252    /* find the time source */
    249253    status = fMediaRoster->GetTimeSource(&fTimeSourceNode);
    250254    if (status != B_OK) {
    251         ErrorAlert("Cannot get a time source", status, fWindow);
     255        ErrorAlert(B_TRANSLATE("Cannot get a time source"), status, fWindow);
    252256        return status;
    253257    }
    254258
     
    256260    INFO("CodyCam acquiring VideoInput node\n");
    257261    status = fMediaRoster->GetVideoInput(&fProducerNode);
    258262    if (status != B_OK) {
    259         ErrorAlert("Cannot find a video source. You need a webcam to use CodyCam.", status, fWindow);
     263        ErrorAlert(B_TRANSLATE("Cannot find a video source. You need a webcam "
     264            "to use CodyCam."), status, fWindow);
    260265        return status;
    261266    }
    262267
    263268    /* create the video consumer node */
    264     fVideoConsumer = new VideoConsumer("CodyCam", ((VideoWindow*)fWindow)->VideoView(),
     269    fVideoConsumer = new VideoConsumer("CodyCam",
     270        ((VideoWindow*)fWindow)->VideoView(),
    265271        ((VideoWindow*)fWindow)->StatusLine(), NULL, 0);
    266272    if (!fVideoConsumer) {
    267         ErrorAlert("Cannot create a video window", B_ERROR, fWindow);
     273        ErrorAlert(B_TRANSLATE("Cannot create a video window"), B_ERROR,
     274            fWindow);
    268275        return B_ERROR;
    269276    }
    270277
    271278    /* register the node */
    272279    status = fMediaRoster->RegisterNode(fVideoConsumer);
    273280    if (status != B_OK) {
    274         ErrorAlert("Cannot register the video window", status, fWindow);
     281        ErrorAlert(B_TRANSLATE("Cannot register the video window"), status,
     282            fWindow);
    275283        return status;
    276284    }
    277285    fPort = fVideoConsumer->ControlPort();
    278286
    279287    /* find free producer output */
    280288    int32 cnt = 0;
    281     status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1,  &cnt,
    282         B_MEDIA_RAW_VIDEO);
     289    status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1,
     290        &cnt, B_MEDIA_RAW_VIDEO);
    283291    if (status != B_OK || cnt < 1) {
    284292        status = B_RESOURCE_UNAVAILABLE;
    285         ErrorAlert("Cannot find an available video stream", status, fWindow);
     293        ErrorAlert(B_TRANSLATE("Cannot find an available video stream"),
     294            status, fWindow);
    286295        return status;
    287296    }
    288297
    289298    /* find free consumer input */
    290299    cnt = 0;
    291     status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), &fConsumerIn, 1,
    292         &cnt, B_MEDIA_RAW_VIDEO);
     300    status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(),
     301        &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO);
    293302    if (status != B_OK || cnt < 1) {
    294303        status = B_RESOURCE_UNAVAILABLE;
    295         ErrorAlert("Can't find an available connection to the video window", status, fWindow);
     304        ErrorAlert(B_TRANSLATE("Can't find an available connection to the "
     305            "video window"), status, fWindow);
    296306        return status;
    297307    }
    298308
     
    304314    format.u.raw_video = vid_format;
    305315
    306316    /* connect producer to consumer */
    307     status = fMediaRoster->Connect(fProducerOut.source, fConsumerIn.destination,
    308                 &format, &fProducerOut, &fConsumerIn);
     317    status = fMediaRoster->Connect(fProducerOut.source,
     318        fConsumerIn.destination, &format, &fProducerOut, &fConsumerIn);
    309319    if (status != B_OK) {
    310         ErrorAlert("Cannot connect the video source to the video window", status);
     320        ErrorAlert(B_TRANSLATE("Cannot connect the video source to the video "
     321            "window"), status);
    311322        return status;
    312323    }
    313324
    314325
    315326    /* set time sources */
    316     status = fMediaRoster->SetTimeSourceFor(fProducerNode.node, fTimeSourceNode.node);
     327    status = fMediaRoster->SetTimeSourceFor(fProducerNode.node,
     328        fTimeSourceNode.node);
    317329    if (status != B_OK) {
    318         ErrorAlert("Cannot set the time source for the video source", status);
     330        ErrorAlert(B_TRANSLATE("Cannot set the time source for the video "
     331            "source"), status);
    319332        return status;
    320333    }
    321334
    322     status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(), fTimeSourceNode.node);
     335    status = fMediaRoster->SetTimeSourceFor(fVideoConsumer->ID(),
     336        fTimeSourceNode.node);
    323337    if (status != B_OK) {
    324         ErrorAlert("Cannot set the time source for the video window", status);
     338        ErrorAlert(B_TRANSLATE("Cannot set the time source for the video "
     339            "window"), status);
    325340        return status;
    326341    }
    327342
     
    334349    bigtime_t initLatency = 0;
    335350    status = fMediaRoster->GetInitialLatencyFor(fProducerNode, &initLatency);
    336351    if (status < B_OK) {
    337         ErrorAlert("Error getting initial latency for the capture node", status);
     352        ErrorAlert(B_TRANSLATE("Error getting initial latency for the capture "
     353            "node"), status);
    338354        return status;
    339355    }
    340356
     
    350366        status = fMediaRoster->StartTimeSource(fTimeSourceNode, real);
    351367        if (status != B_OK) {
    352368            timeSource->Release();
    353             ErrorAlert("Cannot start time source!", status);
     369            ErrorAlert(B_TRANSLATE("Cannot start time source!"), status);
    354370            return status;
    355371        }
    356372        status = fMediaRoster->SeekTimeSource(fTimeSourceNode, 0, real);
    357373        if (status != B_OK) {
    358374            timeSource->Release();
    359             ErrorAlert("Cannot seek time source!", status);
     375            ErrorAlert(B_TRANSLATE("Cannot seek time source!"), status);
    360376            return status;
    361377        }
    362378    }
    363379
    364     bigtime_t perf = timeSource->PerformanceTimeFor(real + latency + initLatency);
     380    bigtime_t perf = timeSource->PerformanceTimeFor(real + latency
     381        + initLatency);
    365382    timeSource->Release();
    366383
    367384    /* start the nodes */
    368385    status = fMediaRoster->StartNode(fProducerNode, perf);
    369386    if (status != B_OK) {
    370         ErrorAlert("Cannot start the video source", status);
     387        ErrorAlert(B_TRANSLATE("Cannot start the video source"), status);
    371388        return status;
    372389    }
    373390    status = fMediaRoster->StartNode(fVideoConsumer->Node(), perf);
    374391    if (status != B_OK) {
    375         ErrorAlert("Cannot start the video window", status);
     392        ErrorAlert(B_TRANSLATE("Cannot start the video window"), status);
    376393        return status;
    377394    }
    378395
     
    436453    BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "menu bar");
    437454
    438455    BMenuItem* menuItem;
    439     BMenu* menu = new BMenu("File");
     456    BMenu* menu = new BMenu(B_TRANSLATE("File"));
    440457
    441     menuItem = new BMenuItem("Video settings", new BMessage(msg_video), 'P');
     458    menuItem = new BMenuItem(B_TRANSLATE("Video settings"),
     459        new BMessage(msg_video), 'P');
    442460    menuItem->SetTarget(be_app);
    443461    menu->AddItem(menuItem);
    444462
    445463    menu->AddSeparatorItem();
    446464
    447     menuItem = new BMenuItem("Start video", new BMessage(msg_start), 'A');
     465    menuItem = new BMenuItem(B_TRANSLATE("Start video"),
     466        new BMessage(msg_start), 'A');
    448467    menuItem->SetTarget(be_app);
    449468    menu->AddItem(menuItem);
    450469
    451     menuItem = new BMenuItem("Stop video", new BMessage(msg_stop), 'O');
     470    menuItem = new BMenuItem(B_TRANSLATE("Stop video"),
     471        new BMessage(msg_stop), 'O');
    452472    menuItem->SetTarget(be_app);
    453473    menu->AddItem(menuItem);
    454474
    455475    menu->AddSeparatorItem();
    456476
    457     menuItem = new BMenuItem("About Codycam" B_UTF8_ELLIPSIS,
     477    menuItem = new BMenuItem(B_TRANSLATE("About Codycam" B_UTF8_ELLIPSIS),
    458478        new BMessage(msg_about), 'B');
    459479    menuItem->SetTarget(be_app);
    460480    menu->AddItem(menuItem);
    461481
    462482    menu->AddSeparatorItem();
    463483
    464     menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q');
     484    menuItem = new BMenuItem(B_TRANSLATE("Quit"),
     485        new BMessage(B_QUIT_REQUESTED), 'Q');
    465486    menuItem->SetTarget(be_app);
    466487    menu->AddItem(menuItem);
    467488
    468489    menuBar->AddItem(menu);
    469490
    470491    /* give it a gray background view */
    471     fView = new BView("Background View", B_WILL_DRAW);
     492    fView = new BView(B_TRANSLATE("Background View"), B_WILL_DRAW);
    472493    fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    473494
    474495    /* add some controls */
     
    659680
    660681    // Capture controls
    661682    fCaptureSetupBox = new BBox("Capture Controls", B_WILL_DRAW);
    662     fCaptureSetupBox->SetLabel("Capture controls");
     683    fCaptureSetupBox->SetLabel(B_TRANSLATE("Capture controls"));
    663684
    664685    BGridLayout *controlsLayout = new BGridLayout(kXBuffer, 0);
    665686    controlsLayout->SetInsets(10, 15, 5, 5);
    666687    fCaptureSetupBox->SetLayout(controlsLayout);
    667688
    668     fFileName = new BTextControl("File Name", "File name:",
     689    fFileName = new BTextControl("File Name", B_TRANSLATE("File name:"),
    669690        fFilenameSetting->Value(), new BMessage(msg_filename));
    670691    fFileName->SetTarget(BMessenger(NULL, this));
    671692
    672     fImageFormatMenu = new BPopUpMenu("Image Format Menu");
     693    fImageFormatMenu = new BPopUpMenu(B_TRANSLATE("Image Format Menu"));
    673694    AddTranslationItems(fImageFormatMenu, B_TRANSLATOR_BITMAP);
    674695    fImageFormatMenu->SetTargetForItems(this);
    675696
     
    682703    else
    683704        fImageFormatMenu->ItemAt(0)->SetMarked(true);
    684705
    685     fImageFormatSelector = new BMenuField("Format", "Format:",
     706    fImageFormatSelector = new BMenuField("Format", B_TRANSLATE("Format:"),
    686707        fImageFormatMenu, NULL);
    687708
    688     fCaptureRateMenu = new BPopUpMenu("Capture Rate Menu");
    689     fCaptureRateMenu->AddItem(new BMenuItem("Every 15 seconds",
     709    fCaptureRateMenu = new BPopUpMenu(B_TRANSLATE("Capture Rate Menu"));
     710    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[0],
    690711        new BMessage(msg_rate_15s)));
    691     fCaptureRateMenu->AddItem(new BMenuItem("Every 30 seconds",
     712    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[1],
    692713        new BMessage(msg_rate_30s)));
    693     fCaptureRateMenu->AddItem(new BMenuItem("Every minute",
     714    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[2],
    694715        new BMessage(msg_rate_1m)));
    695     fCaptureRateMenu->AddItem(new BMenuItem("Every 5 minutes",
     716    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[3],
    696717        new BMessage(msg_rate_5m)));
    697     fCaptureRateMenu->AddItem(new BMenuItem("Every 10 minutes",
     718    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[4],
    698719        new BMessage(msg_rate_10m)));
    699     fCaptureRateMenu->AddItem(new BMenuItem("Every 15 minutes",
     720    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[5],
    700721        new BMessage(msg_rate_15m)));
    701     fCaptureRateMenu->AddItem(new BMenuItem("Every 30 minutes",
     722    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[6],
    702723        new BMessage(msg_rate_30m)));
    703     fCaptureRateMenu->AddItem(new BMenuItem("Every hour",
     724    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[7],
    704725        new BMessage(msg_rate_1h)));
    705     fCaptureRateMenu->AddItem(new BMenuItem("Every 2 hours",
     726    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[8],
    706727        new BMessage(msg_rate_2h)));
    707     fCaptureRateMenu->AddItem(new BMenuItem("Every 4 hours",
     728    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[9],
    708729        new BMessage(msg_rate_4h)));
    709     fCaptureRateMenu->AddItem(new BMenuItem("Every 8 hours",
     730    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[10],
    710731        new BMessage(msg_rate_8h)));
    711     fCaptureRateMenu->AddItem(new BMenuItem("Every 24 hours",
     732    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[11],
    712733        new BMessage(msg_rate_24h)));
    713     fCaptureRateMenu->AddItem(new BMenuItem("Never",
     734    fCaptureRateMenu->AddItem(new BMenuItem(kCaptureRate[12],
    714735        new BMessage(msg_rate_never)));
    715736    fCaptureRateMenu->SetTargetForItems(this);
    716737    fCaptureRateMenu->FindItem(fCaptureRateSetting->Value())->SetMarked(true);
    717     fCaptureRateSelector = new BMenuField("Rate", "Rate:",
     738    fCaptureRateSelector = new BMenuField("Rate", B_TRANSLATE("Rate:"),
    718739        fCaptureRateMenu, NULL);
    719740
    720741    controlsLayout->AddItem(fFileName->CreateLabelLayoutItem(), 0, 0);
    721742    controlsLayout->AddItem(fFileName->CreateTextViewLayoutItem(), 1, 0);
    722     controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0, 1);
    723     controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1, 1);
    724     controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0, 2);
    725     controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1, 2);
     743    controlsLayout->AddItem(fImageFormatSelector->CreateLabelLayoutItem(), 0,
     744        1);
     745    controlsLayout->AddItem(fImageFormatSelector->CreateMenuBarLayoutItem(), 1,
     746        1);
     747    controlsLayout->AddItem(fCaptureRateSelector->CreateLabelLayoutItem(), 0,
     748        2);
     749    controlsLayout->AddItem(fCaptureRateSelector->CreateMenuBarLayoutItem(), 1,
     750        2);
    726751    controlsLayout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, 3, 2);
    727752
    728753    // FTP setup box
    729     fFtpSetupBox = new BBox("FTP Setup", B_WILL_DRAW);
     754    fFtpSetupBox = new BBox(B_TRANSLATE("FTP Setup"), B_WILL_DRAW);
    730755
    731     fUploadClientMenu = new BPopUpMenu("Send to" B_UTF8_ELLIPSIS);
     756    fUploadClientMenu = new BPopUpMenu(B_TRANSLATE("Send to" B_UTF8_ELLIPSIS));
    732757    for (int i = 0; kUploadClient[i]; i++) {
    733758        BMessage *m = new BMessage(msg_upl_client);
    734759        m->AddInt32("client", i);
     
    739764    fUploadClientSelector = new BMenuField("UploadClient", NULL,
    740765        fUploadClientMenu, NULL);
    741766
    742     fFtpSetupBox->SetLabel("Output");
     767    fFtpSetupBox->SetLabel(B_TRANSLATE("Output"));
    743768    // this doesn't work with the layout manager
    744769    // fFtpSetupBox->SetLabel(fUploadClientSelector);
    745     fUploadClientSelector->SetLabel("Type:");
     770    fUploadClientSelector->SetLabel(B_TRANSLATE("Type:"));
    746771
    747772    BGridLayout *ftpLayout = new BGridLayout(kXBuffer, 0);
    748773    ftpLayout->SetInsets(10, 15, 5, 5);
    749774    fFtpSetupBox->SetLayout(ftpLayout);
    750775
    751     fServerName = new BTextControl("Server", "Server:",
     776    fServerName = new BTextControl("Server", B_TRANSLATE("Server:"),
    752777        fServerSetting->Value(), new BMessage(msg_server));
    753778    fServerName->SetTarget(this);
    754779
    755     fLoginId = new BTextControl("Login", "Login:",
     780    fLoginId = new BTextControl("Login", B_TRANSLATE("Login:"),
    756781        fLoginSetting->Value(), new BMessage(msg_login));
    757782    fLoginId->SetTarget(this);
    758783
    759     fPassword = new BTextControl("Password", "Password:",
     784    fPassword = new BTextControl("Password", B_TRANSLATE("Password:"),
    760785        fPasswordSetting->Value(), new BMessage(msg_password));
    761786    fPassword->SetTarget(this);
    762787    fPassword->TextView()->HideTyping(true);
    763788    // BeOS HideTyping() seems broken, it empties the text
    764789    fPassword->SetText(fPasswordSetting->Value());
    765790
    766     fDirectory = new BTextControl("Directory", "Directory:",
     791    fDirectory = new BTextControl("Directory", B_TRANSLATE("Directory:"),
    767792        fDirectorySetting->Value(), new BMessage(msg_directory));
    768793    fDirectory->SetTarget(this);
    769794
    770     fPassiveFtp = new BCheckBox("Passive FTP", "Passive FTP",
     795    fPassiveFtp = new BCheckBox("Passive FTP", B_TRANSLATE("Passive FTP"),
    771796        new BMessage(msg_passiveftp));
    772797    fPassiveFtp->SetTarget(this);
    773798    fPassiveFtp->SetValue(fPassiveFtpSetting->Value());
     
    784809    ftpLayout->AddItem(fDirectory->CreateTextViewLayoutItem(), 1, 4);
    785810    ftpLayout->AddView(fPassiveFtp, 0, 5, 2);
    786811
    787     fStatusLine = new BStringView("Status Line", "Waiting" B_UTF8_ELLIPSIS);
     812    fStatusLine = new BStringView("Status Line", B_TRANSLATE("Waiting" B_UTF8_ELLIPSIS));
    788813
    789814    BGroupLayout *groupLayout = new BGroupLayout(B_VERTICAL);
    790815    groupLayout->SetInsets(kXBuffer, kYBuffer, kXBuffer, kYBuffer);
     
    834859    fSettings = new Settings(filename, dirname);
    835860
    836861    fServerSetting = new StringValueSetting("Server", "ftp.my.server",
    837         "server address expected", "");
     862        B_TRANSLATE("server address expected"), "");
    838863    fLoginSetting = new StringValueSetting("Login", "loginID",
    839         "login ID expected", "");
    840     fPasswordSetting = new StringValueSetting("Password", "password",
    841         "password expected", "");
     864        B_TRANSLATE("login ID expected"), "");
     865    fPasswordSetting = new StringValueSetting("Password",
     866        B_TRANSLATE("password"), B_TRANSLATE("password expected"), "");
    842867    fDirectorySetting = new StringValueSetting("Directory", "web/images",
    843         "destination directory expected", "");
     868        B_TRANSLATE("destination directory expected"), "");
    844869    fPassiveFtpSetting = new BooleanValueSetting("PassiveFtp", 1);
    845870    fFilenameSetting = new StringValueSetting("StillImageFilename",
    846         "codycam.jpg", "still image filename expected", "");
     871        "codycam.jpg", B_TRANSLATE("still image filename expected"), "");
    847872    fImageFormatSettings = new StringValueSetting("ImageFileFormat",
    848         "JPEG image", "image file format expected", "");
     873        B_TRANSLATE("JPEG image"), B_TRANSLATE("image file format expected"),
     874        "");
    849875    fCaptureRateSetting = new EnumeratedStringValueSetting("CaptureRate",
    850         "Every 5 minutes", kCaptureRate, "capture rate expected",
     876        kCaptureRate[3], kCaptureRate, B_TRANSLATE("capture rate expected"),
    851877        "unrecognized capture rate specified");
    852878    fUploadClientSetting = new EnumeratedStringValueSetting("UploadClient",
    853         "FTP", kUploadClient, "upload client name expected",
    854         "unrecognized upload client specified");
     879        B_TRANSLATE("FTP"), kUploadClient,
     880        B_TRANSLATE("upload client name expected"),
     881        B_TRANSLATE("unrecognized upload client specified"));
    855882
    856883    fSettings->Add(fServerSetting);
    857884    fSettings->Add(fLoginSetting);
     
    900927//  #pragma mark -
    901928
    902929
    903 ControlWindow::ControlWindow(const BRect& frame, BView* controls, media_node node)
    904     : BWindow(frame, "Video settings", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
     930ControlWindow::ControlWindow(const BRect& frame, BView* controls,
     931    media_node node)
     932    : BWindow(frame, B_TRANSLATE("Video settings"), B_TITLED_WINDOW,
     933    B_ASYNCHRONOUS_CONTROLS)
    905934{
    906935    fView = controls;
    907936    fNode = node;
  • src/apps/codycam/SftpClient.h

     
    55#include <stdio.h>
    66#include <string>
    77
     8#include <Catalog.h>
    89#include <File.h>
     10#include <Locale.h>
     11
    912#include "SpawningUploadClient.h"
    1013
     14#undef TR_CONTEXT
     15#define TR_CONTEXT "SftpClient"
     16
     17#define B_TRANSLATE(str) \
     18    be_catalog->GetString((str), TR_CONTEXT)
     19
    1120using std::string;
    1221
    1322
     
    3443        void SetPassive(bool on);
    3544   
    3645    protected:
    37 
     46    private:
     47        const char* GetLongReadText() {return B_TRANSLATE("read: %ld\n");};
     48        const char* GetReadText() {return B_TRANSLATE("read: %d\n");};
     49        const char* GetReplyText() {return B_TRANSLATE("reply: '%s'\n");};
    3850};
    3951
    4052#endif  // SFTP_CLIENT_H
  • src/apps/codycam/VideoConsumer.cpp

     
    1616#include <Application.h>
    1717#include <Buffer.h>
    1818#include <BufferGroup.h>
     19#include <Catalog.h>
     20#include <Locale.h>
    1921#include <MediaRoster.h>
    2022#include <NodeInfo.h>
    2123#include <scheduler.h>
     
    2325#include <TimeSource.h>
    2426#include <View.h>
    2527
     28#undef TR_CONTEXT
     29#define TR_CONTEXT "VideoConsumer.cpp"
    2630
    2731#define M1 ((double)1000000.0)
    2832#define JITTER      20000
     
    3842    1, 1, {B_RGB16, 320, 240, 320 * 4, 0, 0}};
    3943
    4044
    41 VideoConsumer::VideoConsumer(const char* name, BView* view, BStringView* statusLine,
     45VideoConsumer::VideoConsumer(const char* name, BView* view,
     46    BStringView* statusLine,
    4247    BMediaAddOn* addon, const uint32 internalId)
    43     : BMediaNode(name), BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO),
     48    : BMediaNode(name),
     49    BMediaEventLooper(),
     50    BBufferConsumer(B_MEDIA_RAW_VIDEO),
    4451    fStatusLine(statusLine),
    4552    fInternalID(internalId),
    4653    fAddOn(addon),
     
    8693    Quit();
    8794
    8895    if (fWindow) {
    89         printf("Locking the window\n");
     96        printf(B_TRANSLATE("Locking the window\n"));
    9097        if (fWindow->Lock()) {
    91             printf("Closing the window\n");
     98            printf(B_TRANSLATE("Closing the window\n"));
    9299            fWindow->Close();
    93100            fWindow = 0;
    94101        }
     
    652659{
    653660    BFile* output;
    654661
    655     UpdateFtpStatus("Capturing Image" B_UTF8_ELLIPSIS);
     662    UpdateFtpStatus(B_TRANSLATE("Capturing Image" B_UTF8_ELLIPSIS));
    656663
    657664    /* save a local copy of the image in the requested format */
    658665    output = new BFile();
     
    663670        if (err == B_OK) {
    664671            err = SetFileType(output, fTranslator, fImageFormat);
    665672            if (err != B_OK)
    666                 UpdateFtpStatus("Error setting type of output file");                           
     673                UpdateFtpStatus(B_TRANSLATE("Error setting type of output file"));
    667674        }
    668675        else
    669             UpdateFtpStatus("Error writing output file");                           
     676            UpdateFtpStatus(B_TRANSLATE("Error writing output file"));
    670677
    671678        input.DetachBitmap(&bitmap);
    672679        output->Unset();
    673680        delete output;
    674681        return B_OK;
    675682    } else {
    676         UpdateFtpStatus("Error creating output file");
     683        UpdateFtpStatus(B_TRANSLATE("Error creating output file"));
    677684        return B_ERROR;
    678685    }                           
    679686}
     
    695702        case 2:
    696703            return B_OK;
    697704        default:
    698             fprintf(stderr, "invalid upload client %ld\n", fUploadClient);
     705            fprintf(stderr, B_TRANSLATE("invalid upload client %ld\n"),
     706                fUploadClient);
    699707            return EINVAL;
    700708    }
    701709
    702710    ftp->SetPassive(fPassiveFtp);
    703711        // ftp the local file to our web site
    704712
    705     UpdateFtpStatus("Logging in" B_UTF8_ELLIPSIS);
    706     if (ftp->Connect((string)fServerText, (string)fLoginText, (string)fPasswordText)) {
     713    UpdateFtpStatus(B_TRANSLATE("Logging in" B_UTF8_ELLIPSIS));
     714    if (ftp->Connect((string)fServerText, (string)fLoginText,
     715        (string)fPasswordText)) {
    707716        // connect to server
    708         UpdateFtpStatus("Connected" B_UTF8_ELLIPSIS);
     717        UpdateFtpStatus(B_TRANSLATE("Connected" B_UTF8_ELLIPSIS));
    709718
    710719        if (ftp->ChangeDir((string)fDirectoryText)) {
    711720            // cd to the desired directory
    712             UpdateFtpStatus("Transmitting" B_UTF8_ELLIPSIS);
     721            UpdateFtpStatus(B_TRANSLATE("Transmitting" B_UTF8_ELLIPSIS));
    713722
    714723            if (ftp->PutFile((string)filename, (string)"temp")) {
    715724                // send the file to the server
     
    717726                ftp->Chmod((string)"temp", (string)"644");
    718727                // make it world readable
    719728
    720                 UpdateFtpStatus("Renaming" B_UTF8_ELLIPSIS);
     729                UpdateFtpStatus(B_TRANSLATE("Renaming" B_UTF8_ELLIPSIS));
    721730
    722731                if (ftp->MoveFile((string)"temp", (string)filename)) {
    723732                    // change to the desired name
    724733                    uint32 time = real_time_clock();
    725734                    char s[80];
    726                     strcpy(s, "Last Capture: ");
     735                    strcpy(s, B_TRANSLATE("Last Capture: "));
    727736                    strcat(s, ctime((const long*)&time));
    728737                    s[strlen(s) - 1] = 0;
    729738                    UpdateFtpStatus(s);
     
    731740                    return B_OK;
    732741                }
    733742                else
    734                     UpdateFtpStatus("Rename failed");
     743                    UpdateFtpStatus(B_TRANSLATE("Rename failed"));
    735744            }
    736745            else
    737                 UpdateFtpStatus("File transmission failed");
     746                UpdateFtpStatus(B_TRANSLATE("File transmission failed"));
    738747        }
    739748        else
    740             UpdateFtpStatus("Couldn't find requested directory on server");
     749            UpdateFtpStatus(B_TRANSLATE("Couldn't find requested directory on "
     750                "server"));
    741751    }
    742752    else
    743         UpdateFtpStatus("Server login failed");
     753        UpdateFtpStatus(B_TRANSLATE("Server login failed"));
    744754
    745755    delete ftp;
    746756    return B_ERROR;
  • src/apps/codycam/CodyCam.h

     
    99
    1010#include <Application.h>
    1111#include <Box.h>
     12#include <Catalog.h>
    1213#include <CheckBox.h>
     14#include <Locale.h>
    1315#include <Menu.h>
    1416#include <MenuField.h>
    1517#include <StringView.h>
    1618#include <TextControl.h>
    1719#include <Window.h>
    1820
     21#undef TR_CONTEXT
     22#define TR_CONTEXT "CodyCam"
    1923
     24#define B_TRANSLATE(str) \
     25    be_catalog->GetString((str), TR_CONTEXT)
     26
    2027class BMediaRoster;
    2128
    2229
     
    2532
    2633    msg_rate_15s    = 'r15s',
    2734    msg_rate_30s    = 'r30s',
    28     msg_rate_1m     = 'r1m ',
    29     msg_rate_5m     = 'r5m ',
     35    msg_rate_1m = 'r1m ',
     36    msg_rate_5m = 'r5m ',
    3037    msg_rate_10m    = 'r10m',
    3138    msg_rate_15m    = 'r15m',
    3239    msg_rate_30m    = 'r30m',
    33     msg_rate_1h     = 'r1h ',   
    34     msg_rate_2h     = 'r2h ',   
    35     msg_rate_4h     = 'r4h ',   
    36     msg_rate_8h     = 'r8h ',   
     40    msg_rate_1h = 'r1h ',   
     41    msg_rate_2h = 'r2h ',   
     42    msg_rate_4h = 'r4h ',   
     43    msg_rate_8h = 'r8h ',   
    3744    msg_rate_24h    = 'r24h',
    3845    msg_rate_never  = 'nevr',   
    3946
    4047    msg_translate   = 'tran',
    4148
    4249    msg_upl_client  = 'ucli',
    43     msg_server      = 'srvr',
    44     msg_login       = 'lgin',
     50    msg_server  = 'srvr',
     51    msg_login   = 'lgin',
    4552    msg_password    = 'pswd',
    4653    msg_directory   = 'drct',
    4754    msg_passiveftp  = 'pasv',
    4855    msg_pswrd_text  = 'pstx',
    4956   
    50     msg_start       = 'strt',
    51     msg_stop        = 'stop',
     57    msg_start   = 'strt',
     58    msg_stop    = 'stop',
    5259
    53     msg_about       = 'abut',
    54     msg_setup       = 'setp',
    55     msg_video       = 'vdeo',
     60    msg_about   = 'abut',
     61    msg_setup   = 'setp',
     62    msg_video   = 'vdeo',
    5663   
    5764    msg_control_win = 'ctlw'
    5865};
    5966
    6067
    6168const char* kCaptureRate[] = {
    62     "Every 15 seconds",
    63     "Every 30 seconds",
    64     "Every minute",
    65     "Every 5 minutes",
    66     "Every 10 minutes",
    67     "Every 15 minutes",
    68     "Every 30 minutes",
    69     "Every hour",
    70     "Every 2 hours",
    71     "Every 4 hours",
    72     "Every 8 hours",
    73     "Every 24 hours",
    74     "Never",   
     69    B_TRANSLATE("Every 15 seconds"),
     70    B_TRANSLATE("Every 30 seconds"),
     71    B_TRANSLATE("Every minute"),
     72    B_TRANSLATE("Every 5 minutes"),
     73    B_TRANSLATE("Every 10 minutes"),
     74    B_TRANSLATE("Every 15 minutes"),
     75    B_TRANSLATE("Every 30 minutes"),
     76    B_TRANSLATE("Every hour"),
     77    B_TRANSLATE("Every 2 hours"),
     78    B_TRANSLATE("Every 4 hours"),
     79    B_TRANSLATE("Every 8 hours"),
     80    B_TRANSLATE("Every 24 hours"),
     81    B_TRANSLATE("Never"),   
    7582    0
    7683};
    7784
    7885
    7986const char* kUploadClient[] = {
    80     "FTP",
    81     "SFTP",
    82     "Local",
     87    B_TRANSLATE("FTP"),
     88    B_TRANSLATE("SFTP"),
     89    B_TRANSLATE("Local"),
    8390    0
    8491};
    8592
     
    106113            BWindow*        fWindow;
    107114            port_id         fPort;
    108115            BWindow*        fVideoControlWindow;
     116            BCatalog        fAppCatalog;
    109117};
    110118
    111119
  • src/apps/codycam/Jamfile

     
    1111    Settings.cpp
    1212    SettingsHandler.cpp
    1313    VideoConsumer.cpp
    14     : be media translation $(TARGET_NETAPI_LIB) $(TARGET_LIBSTDC++)
     14    : be locale media translation liblocale.so $(TARGET_NETAPI_LIB)
     15$(TARGET_LIBSTDC++)
    1516    : CodyCam.rdef
    1617;
    1718
  • src/apps/codycam/FtpClient.cpp

     
    11#include "FtpClient.h"
    22
     3#include <Catalog.h>
     4#include <Locale.h>
     5
    36#include <stdlib.h>
    47#include <string.h>
    58
     9#undef TR_CONTEXT
     10#define TR_CONTEXT "FtpClient"
     11
     12#define B_TRANSLATE(str) \
     13    be_catalog->GetString((str), TR_CONTEXT)
     14
    615FtpClient::FtpClient()
    716    : FileUploadClient(),
    817    fState(0),
     
    373382   
    374383    if (path.length() == 0)
    375384        cmd += '/';
    376 printf("cmd: '%s'\n", cmd.c_str());
     385printf(B_TRANSLATE("cmd: '%s'\n"), cmd.c_str());
    377386    if (_SendRequest(cmd) == true) {
    378387        if (_GetReply(replyString, code, codeType) == true) {
    379 printf("reply: %d, %d\n", code, codeType);
     388printf(B_TRANSLATE("reply: %d, %d\n"), code, codeType);
    380389            if (codeType == 2)
    381390                rc = true;
    382391        }
     
    424433   
    425434    if (fControl != 0) {
    426435        if (cmd.find("PASS") != string::npos)
    427             printf("PASS <suppressed>  (real password sent)\n");
     436            printf(B_TRANSLATE("PASS <suppressed>  (real password sent)\n"));
    428437        else
    429438            printf("%s\n", ccmd.c_str());
    430439
     
    540549    }
    541550   
    542551    if (!rc && outCode != 421) {
    543         outString += "Remote host has closed the connection.\n";
     552        outString += B_TRANSLATE("Remote host has closed the connection.\n");
    544553        outCode = 421;
    545554    }
    546555