Ticket #7532: 0001-Added-localization-support-for-Playground-app.patch

File 0001-Added-localization-support-for-Playground-app.patch, 10.9 KB (added by dsjonny, 11 years ago)
  • src/tests/servers/app/playground/Jamfile

    From 62943728a803f81d5bd3155e0c6d4f34668535aa Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?Dancs=C3=B3=20R=C3=B3bert?= <dancso.robert@d-rendszer.hu>
    Date: Fri, 4 Jan 2013 19:05:33 +0100
    Subject: [PATCH] Added localization support for Playground app.
    
    ---
     src/tests/servers/app/playground/Jamfile          |    9 ++-
     src/tests/servers/app/playground/ObjectView.cpp   |    9 ++-
     src/tests/servers/app/playground/ObjectWindow.cpp |   61 +++++++++++----------
     src/tests/servers/app/playground/main.cpp         |    7 ++-
     4 files changed, 54 insertions(+), 32 deletions(-)
    
    diff --git a/src/tests/servers/app/playground/Jamfile b/src/tests/servers/app/playground/Jamfile
    index 343845d..327085d 100644
    a b Application Playground :  
    1111    ObjectView.cpp
    1212    ObjectWindow.cpp
    1313    States.cpp
    14     : be $(TARGET_LIBSUPC++)
     14    : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
    1515    : Playground.rdef
    1616;
    1717
    if ( $(TARGET_PLATFORM) = libbe_test ) {  
    2020        : tests!apps ;
    2121}
    2222
     23DoCatalogs Playground :
     24    application/x-vnd.Haiku-Playground
     25    :
     26    main.cpp
     27    ObjectView.cpp
     28    ObjectWindow.cpp
     29;
  • src/tests/servers/app/playground/ObjectView.cpp

    diff --git a/src/tests/servers/app/playground/ObjectView.cpp b/src/tests/servers/app/playground/ObjectView.cpp
    index 497304f..932cfc1 100644
    a b  
    1111#include <Shape.h>
    1212#include <String.h>
    1313#include <Window.h>
     14// Locale Kit
     15#include <Catalog.h>
     16
     17#undef B_TRANSLATION_CONTEXT
     18#define B_TRANSLATION_CONTEXT "Playground"
    1419
    1520#include "States.h"
    1621
    ObjectView::Draw(BRect updateRect)  
    157162    SetDrawingMode(B_OP_OVER);
    158163    SetHighColor(255, 0, 0, 128);
    159164
    160     const char* message = "Click and drag to draw an object";
     165    const char* message = B_TRANSLATE("Click and drag to draw an object");
    161166    float width = StringWidth(message);
    162167
    163168    BPoint p((r.Width() - width) / 2.0, r.Height() / 2.0);
    if (dragMessage) {  
    341346                helper->FillRect(r);
    342347
    343348                helper->SetHighColor(0, 0, 0, 255);
    344                 const char* text = "Test";
     349                const char* text = B_TRANSLATE("Test");
    345350                float pos = (r.Width() - helper->StringWidth(text)) / 2;
    346351                helper->DrawString(text, BPoint(pos, 25));
    347352                helper->Sync();
  • src/tests/servers/app/playground/ObjectWindow.cpp

    diff --git a/src/tests/servers/app/playground/ObjectWindow.cpp b/src/tests/servers/app/playground/ObjectWindow.cpp
    index 3b9129b..ca9e90e 100644
    a b  
    2626#include <TabView.h>
    2727#include <TextControl.h>
    2828#include <TextView.h>
     29// Locale Kit
     30#include <Catalog.h>
     31
     32#undef B_TRANSLATION_CONTEXT
     33#define B_TRANSLATION_CONTEXT "Playground"
    2934
    3035#include "ObjectView.h"
    3136#include "States.h"
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    126131    BMenuBar* menuBar = new BMenuBar(b, "menu bar");
    127132    AddChild(menuBar);
    128133
    129     BMenu* menu = new BMenu("File");
     134    BMenu* menu = new BMenu(B_TRANSLATE("File"));
    130135    menuBar->AddItem(menu);
    131136
    132     menu->AddItem(new BMenu("Submenu"));
     137    menu->AddItem(new BMenu(B_TRANSLATE("Submenu")));
    133138
    134     BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
     139    BMenuItem* menuItem = new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED),
    135140                                        'Q');
    136141    menu->AddItem(menuItem);
    137142
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    170175    BBox* controlGroup = new BBox(b, "controls box",
    171176        B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW, B_FANCY_BORDER);
    172177
    173     controlGroup->SetLabel("Controls");
     178    controlGroup->SetLabel(B_TRANSLATE("Controls"));
    174179    bg->AddChild(controlGroup);
    175180
    176181    b = controlGroup->Bounds();
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    180185    b.right = b.left + b.Width() / 2.0 - 5.0;
    181186
    182187    // new button
    183     fNewB = new BButton(b, "new button", "New Object",
     188    fNewB = new BButton(b, "new button", B_TRANSLATE("New Object"),
    184189        new BMessage(MSG_NEW_OBJECT));
    185190    controlGroup->AddChild(fNewB);
    186191    SetDefaultButton(fNewB);
    187192
    188193    // clear button
    189194    b.OffsetBy(0, fNewB->Bounds().Height() + 5.0);
    190     fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR));
     195    fClearB = new BButton(b, "clear button", B_TRANSLATE("Clear"), new BMessage(MSG_CLEAR));
    191196    controlGroup->AddChild(fClearB);
    192197
    193198    // object type radio buttons
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    197202    b.OffsetBy(0, fClearB->Bounds().Height() + 5.0);
    198203    message = new BMessage(MSG_SET_OBJECT_TYPE);
    199204    message->AddInt32("type", OBJECT_LINE);
    200     radioButton = new BRadioButton(b, "radio 1", "Line", message);
     205    radioButton = new BRadioButton(b, "radio 1", B_TRANSLATE("Line"), message);
    201206    controlGroup->AddChild(radioButton);
    202207
    203208    radioButton->SetValue(B_CONTROL_ON);
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    205210    b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
    206211    message = new BMessage(MSG_SET_OBJECT_TYPE);
    207212    message->AddInt32("type", OBJECT_RECT);
    208     radioButton = new BRadioButton(b, "radio 2", "Rect", message);
     213    radioButton = new BRadioButton(b, "radio 2", B_TRANSLATE("Rect"), message);
    209214    controlGroup->AddChild(radioButton);
    210215
    211216    b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
    212217    message = new BMessage(MSG_SET_OBJECT_TYPE);
    213218    message->AddInt32("type", OBJECT_ROUND_RECT);
    214     radioButton = new BRadioButton(b, "radio 3", "Round Rect", message);
     219    radioButton = new BRadioButton(b, "radio 3", B_TRANSLATE("Round Rect"), message);
    215220    controlGroup->AddChild(radioButton);
    216221
    217222    b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
    218223    message = new BMessage(MSG_SET_OBJECT_TYPE);
    219224    message->AddInt32("type", OBJECT_ELLIPSE);
    220     radioButton = new BRadioButton(b, "radio 4", "Ellipse", message);
     225    radioButton = new BRadioButton(b, "radio 4", B_TRANSLATE("Ellipse"), message);
    221226    controlGroup->AddChild(radioButton);
    222227
    223228    // drawing mode
    224     BPopUpMenu* popupMenu = new BPopUpMenu("<pick>");
     229    BPopUpMenu* popupMenu = new BPopUpMenu(B_TRANSLATE("<pick>"));
    225230
    226231    message = new BMessage(MSG_SET_DRAWING_MODE);
    227232    message->AddInt32("mode", B_OP_COPY);
    228     popupMenu->AddItem(new BMenuItem("Copy", message));
     233    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy"), message));
    229234
    230235    message = new BMessage(MSG_SET_DRAWING_MODE);
    231236    message->AddInt32("mode", B_OP_OVER);
    232     popupMenu->AddItem(new BMenuItem("Over", message));
     237    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Over"), message));
    233238
    234239    message = new BMessage(MSG_SET_DRAWING_MODE);
    235240    message->AddInt32("mode", B_OP_INVERT);
    236     popupMenu->AddItem(new BMenuItem("Invert", message));
     241    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Invert"), message));
    237242
    238243    message = new BMessage(MSG_SET_DRAWING_MODE);
    239244    message->AddInt32("mode", B_OP_BLEND);
    240     popupMenu->AddItem(new BMenuItem("Blend", message));
     245    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Blend"), message));
    241246
    242247    message = new BMessage(MSG_SET_DRAWING_MODE);
    243248    message->AddInt32("mode", B_OP_SELECT);
    244     popupMenu->AddItem(new BMenuItem("Select", message));
     249    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Select"), message));
    245250
    246251    message = new BMessage(MSG_SET_DRAWING_MODE);
    247252    message->AddInt32("mode", B_OP_ERASE);
    248     popupMenu->AddItem(new BMenuItem("Erase", message));
     253    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Erase"), message));
    249254
    250255    message = new BMessage(MSG_SET_DRAWING_MODE);
    251256    message->AddInt32("mode", B_OP_ADD);
    252     popupMenu->AddItem(new BMenuItem("Add", message));
     257    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Add"), message));
    253258
    254259    message = new BMessage(MSG_SET_DRAWING_MODE);
    255260    message->AddInt32("mode", B_OP_SUBTRACT);
    256     popupMenu->AddItem(new BMenuItem("Subtract", message));
     261    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Subtract"), message));
    257262
    258263    message = new BMessage(MSG_SET_DRAWING_MODE);
    259264    message->AddInt32("mode", B_OP_MIN);
    260     popupMenu->AddItem(new BMenuItem("Min", message));
     265    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Min"), message));
    261266
    262267    message = new BMessage(MSG_SET_DRAWING_MODE);
    263268    message->AddInt32("mode", B_OP_MAX);
    264     popupMenu->AddItem(new BMenuItem("Max", message));
     269    popupMenu->AddItem(new BMenuItem(B_TRANSLATE("Max"), message));
    265270
    266271    message = new BMessage(MSG_SET_DRAWING_MODE);
    267272    message->AddInt32("mode", B_OP_ALPHA);
    268     BMenuItem* item = new BMenuItem("Alpha", message);
     273    BMenuItem* item = new BMenuItem(B_TRANSLATE("Alpha"), message);
    269274    item->SetMarked(true);
    270275    popupMenu->AddItem(item);
    271276
    272277    b.OffsetBy(0, radioButton->Bounds().Height() + 10.0);
    273     fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode:",
     278    fDrawingModeMF = new BMenuField(b, "drawing mode field", B_TRANSLATE("Mode:"),
    274279        popupMenu);
    275280
    276281    controlGroup->AddChild(fDrawingModeMF);
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    286291   
    287292    // alpha text control
    288293    b.OffsetBy(0, fColorControl-> Bounds().Height() + 5.0);
    289     fAlphaTC = new BTextControl(b, "alpha text control", "Alpha:", "",
     294    fAlphaTC = new BTextControl(b, "alpha text control", B_TRANSLATE("Alpha:"), "",
    290295        new BMessage(MSG_SET_COLOR));
    291296    controlGroup->AddChild(fAlphaTC);
    292297
    ObjectWindow::ObjectWindow(BRect frame, const char* name)  
    300305
    301306    // fill check box
    302307    b.OffsetBy(0, fAlphaTC->Bounds().Height() + 5.0);
    303     fFillCB = new BCheckBox(b, "fill check box", "Fill",
     308    fFillCB = new BCheckBox(b, "fill check box", B_TRANSLATE("Fill"),
    304309        new BMessage(MSG_SET_FILL_OR_STROKE));
    305310    controlGroup->AddChild(fFillCB);
    306311
    307312    // pen size text control
    308313    b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
    309314    b.bottom = b.top + 10.0;//35;
    310     fPenSizeS = new BSlider(b, "width slider", "Width:", NULL, 1, 100,
     315    fPenSizeS = new BSlider(b, "width slider", B_TRANSLATE("Width:"), NULL, 1, 100,
    311316        B_TRIANGLE_THUMB);
    312317    fPenSizeS->SetLimitLabels("1", "100");
    313318    fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE));
    ObjectWindow::MessageReceived(BMessage* message)  
    417422            break;
    418423        case MSG_CLEAR: {
    419424            BAlert *alert = new BAlert("Playground",
    420                                        "Do you really want to clear all drawing objects?",
    421                                        "No", "Yes");
     425                                       B_TRANSLATE("Do you really want to clear all drawing objects?"),
     426                                       B_TRANSLATE("No"), B_TRANSLATE("Yes"));
    422427            if (alert->Go() == 1) {
    423428                fObjectView->MakeEmpty();
    424429                fObjectLV->MakeEmpty();
  • src/tests/servers/app/playground/main.cpp

    diff --git a/src/tests/servers/app/playground/main.cpp b/src/tests/servers/app/playground/main.cpp
    index 5612123..db3c202 100644
    a b  
    33
    44#include <Application.h>
    55#include <Message.h>
     6// Locale Kit
     7#include <Catalog.h>
     8
     9#undef B_TRANSLATION_CONTEXT
     10#define B_TRANSLATION_CONTEXT "Playground"
    611
    712#include "ObjectWindow.h"
    813
    main(int argc, char** argv)  
    1318    BApplication* app = new BApplication("application/x-vnd.Haiku-Playground");
    1419
    1520    BRect frame(50.0, 50.0, 600.0, 400.0);
    16     BWindow* window = new ObjectWindow(frame, "Playground");
     21    BWindow* window = new ObjectWindow(frame, B_TRANSLATE_SYSTEM_NAME("Playground"));
    1722
    1823    window->Show();
    1924