Ticket #7349: fontdemo-localization.patch

File fontdemo-localization.patch, 8.7 KB (added by Karvjorm, 10 years ago)

A localization patch for FontDemo application

  • src/apps/fontdemo/FontDemoView.cpp

     
    1414#include <stdio.h>
    1515#include <string.h>
    1616
     17#include <Catalog.h>
    1718#include <Bitmap.h>
    1819#include <Font.h>
    1920#include <Message.h>
     
    2122
    2223#include "messages.h"
    2324
     25#undef B_TRANSLATE_CONTEXT
     26#define B_TRANSLATE_CONTEXT "FontDemoView"
    2427
    2528FontDemoView::FontDemoView(BRect rect)
    2629    : BView(rect, "FontDemoView", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS),
     
    3639    fShapes(NULL)
    3740{
    3841    SetViewColor(B_TRANSPARENT_COLOR);
    39     SetString("Haiku, Inc.");
     42    BString setStr = B_TRANSLATE("Haiku, Inc.");
     43    SetString(setStr);
    4044    SetFontSize(fFontSize);
    4145    SetAntialiasing(true);
    4246
  • src/apps/fontdemo/Jamfile

     
    66    ControlView.cpp
    77    FontDemo.cpp
    88    FontDemoView.cpp
    9     : be $(TARGET_LIBSUPC++)
     9    : be $(HAIKU_LOCALE_LIBS) $(TARGET_LIBSUPC++)
    1010    : FontDemo.rdef
    1111    ;
     12
     13DoCatalogs FontDemo :
     14    x-vnd.Haiku-FontDemo
     15    :
     16    FontDemo.cpp
     17    ControlView.cpp
     18    FontDemoView.cpp
     19;
     20
     21AddCatalogEntryAttribute FontDemo
     22    :
     23    x-vnd.Haiku-FontDemo:FontDemo:FontDemo
     24;
  • src/apps/fontdemo/ControlView.cpp

     
    1111#include "messages.h"
    1212
    1313#include <Button.h>
     14#include <Catalog.h>
    1415#include <CheckBox.h>
    1516#include <Menu.h>
    1617#include <MenuField.h>
     
    2425
    2526#include <stdio.h>
    2627
     28#undef B_TRANSLATE_CONTEXT
     29#define B_TRANSLATE_CONTEXT "ControlView"
    2730
    2831ControlView::ControlView(BRect rect)
    2932    : BView(rect, "ControlView", B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE_JUMP),
     
    6669    float offsetX = 0;
    6770    float offsetY = 0;
    6871
    69     fTextControl = new BTextControl(rect, "TextInput", "Text:", "Haiku, Inc.", NULL);
     72    fTextControl = new BTextControl(rect, "TextInput", B_TRANSLATE("Text:"),
     73        B_TRANSLATE("Haiku, Inc."), NULL);
    7074    fTextControl->SetDivider(29.0);
    7175    fTextControl->SetModificationMessage(new BMessage(TEXT_CHANGED_MSG));
    7276    AddChild(fTextControl);
     
    7579    _AddFontMenu(rect);
    7680
    7781    rect.OffsetBy(0.0, 29.0);
    78     fFontsizeSlider = new BSlider(rect, "Fontsize", "Size: 50", NULL, 4, 360);
     82    fFontsizeSlider = new BSlider(rect, "Fontsize", B_TRANSLATE("Size: 50"),
     83        NULL, 4, 360);
    7984    fFontsizeSlider->SetModificationMessage(new BMessage(FONTSIZE_MSG));
    8085    fFontsizeSlider->SetValue(50);
    8186    AddChild(fFontsizeSlider);
     
    8590    offsetX += 1;
    8691
    8792    rect.OffsetBy(0.0, offsetX);
    88     fShearSlider = new BSlider(rect, "Shear", "Shear: 90", NULL, 45, 135);
     93    fShearSlider = new BSlider(rect, "Shear", B_TRANSLATE("Shear: 90"), NULL,
     94        45, 135);
    8995    fShearSlider->SetModificationMessage(new BMessage(FONTSHEAR_MSG));
    9096    fShearSlider->SetValue(90);
    9197    AddChild(fShearSlider);
    9298
    9399    rect.OffsetBy(0.0, offsetX);
    94     fRotationSlider = new BSlider(rect, "Rotation", "Rotation: 0", NULL, 0, 360);
     100    fRotationSlider = new BSlider(rect, "Rotation", B_TRANSLATE("Rotation: 0"),
     101        NULL, 0, 360);
    95102    fRotationSlider->SetModificationMessage( new BMessage(ROTATION_MSG));
    96103    fRotationSlider->SetValue(0);
    97104    AddChild(fRotationSlider);
    98105
    99106    rect.OffsetBy(0.0, offsetX);
    100     fSpacingSlider = new BSlider(rect, "Spacing", "Spacing: 0", NULL, -5, 50);
     107    fSpacingSlider = new BSlider(rect, "Spacing", B_TRANSLATE("Spacing: 0"),
     108        NULL, -5, 50);
    101109    fSpacingSlider->SetModificationMessage(new BMessage(SPACING_MSG));
    102110    fSpacingSlider->SetValue(0);
    103111    AddChild(fSpacingSlider);
    104112
    105113    rect.OffsetBy(0.0, offsetX);
    106     fOutlineSlider = new BSlider(rect, "Outline", "Outline:", NULL, 0, 20);
     114    fOutlineSlider = new BSlider(rect, "Outline", B_TRANSLATE("Outline:"),
     115        NULL, 0, 20);
    107116    fOutlineSlider->SetModificationMessage(new BMessage(OUTLINE_MSG));
    108117    AddChild(fOutlineSlider);
    109118
    110119    rect.OffsetBy(0.0, offsetX);
    111     fAliasingCheckBox = new BCheckBox(rect, "Aliasing", "Antialiased text",
    112         new BMessage(ALIASING_MSG));
     120    fAliasingCheckBox = new BCheckBox(rect, "Aliasing",
     121        B_TRANSLATE("Antialiased text"), new BMessage(ALIASING_MSG));
    113122    fAliasingCheckBox->SetValue(B_CONTROL_ON);
    114123    AddChild(fAliasingCheckBox);
    115124
     
    154163
    155164    fDrawingModeMenu->SetLabelFromMarked(true);
    156165
    157     BMenuField *drawingModeMenuField = new BMenuField(rect, "FontMenuField", "Drawing mode:", fDrawingModeMenu, true);
    158     drawingModeMenuField->SetDivider(5+StringWidth("Drawing mode:"));
     166    BMenuField *drawingModeMenuField = new BMenuField(rect, "FontMenuField",
     167        B_TRANSLATE("Drawing mode:"), fDrawingModeMenu, true);
     168    drawingModeMenuField->SetDivider(5+StringWidth(
     169        B_TRANSLATE("Drawing mode:")));
    159170    AddChild(drawingModeMenuField);
    160171
    161172    rect.OffsetBy(0.0, 22);
    162     fBoundingboxesCheckBox = new BCheckBox(rect, "BoundingBoxes", "Bounding boxes",
    163         new BMessage(BOUNDING_BOX_MSG));
     173    fBoundingboxesCheckBox = new BCheckBox(rect, "BoundingBoxes",
     174        B_TRANSLATE("Bounding boxes"), new BMessage(BOUNDING_BOX_MSG));
    164175    AddChild(fBoundingboxesCheckBox);
    165176
    166177    rect.OffsetBy(0.0, 22.0);
    167     fCyclingFontButton = new BButton(rect, "Cyclefonts", "Cycle fonts",
    168         new BMessage(CYCLING_FONTS_MSG));
     178    fCyclingFontButton = new BButton(rect, "Cyclefonts",
     179        B_TRANSLATE("Cycle fonts"), new BMessage(CYCLING_FONTS_MSG));
    169180    AddChild(fCyclingFontButton);
    170181
    171182    fTextControl->SetTarget(this);
     
    222233        case FONTSIZE_MSG:
    223234        {
    224235            char buff[256];
    225             sprintf(buff, "Size: %d", static_cast<int>(fFontsizeSlider->Value()));
     236            sprintf(buff, B_TRANSLATE("Size: %d"),
     237                static_cast<int>(fFontsizeSlider->Value()));
    226238            fFontsizeSlider->SetLabel(buff);
    227239
    228240            BMessage msg(FONTSIZE_MSG);
     
    234246        case FONTSHEAR_MSG:
    235247        {
    236248            char buff[256];
    237             sprintf(buff, "Shear: %d", static_cast<int>(fShearSlider->Value()));
     249            sprintf(buff, B_TRANSLATE("Shear: %d"),
     250                static_cast<int>(fShearSlider->Value()));
    238251            fShearSlider->SetLabel(buff);
    239252
    240253            BMessage msg(FONTSHEAR_MSG);
     
    246259        case ROTATION_MSG:
    247260        {
    248261            char buff[256];
    249             sprintf(buff, "Rotation: %d", static_cast<int>(fRotationSlider->Value()));
     262            sprintf(buff, B_TRANSLATE("Rotation: %d"),
     263                static_cast<int>(fRotationSlider->Value()));
    250264            fRotationSlider->SetLabel(buff);
    251265
    252266            BMessage msg(ROTATION_MSG);
     
    258272        case SPACING_MSG:
    259273        {
    260274            char buff[256];
    261             sprintf(buff, "Spacing: %d", (int)fSpacingSlider->Value());
     275            sprintf(buff, B_TRANSLATE("Spacing: %d"),
     276                (int)fSpacingSlider->Value());
    262277            fSpacingSlider->SetLabel(buff);
    263278
    264279            BMessage msg(SPACING_MSG);
     
    296311            int8 outlineVal = (int8)fOutlineSlider->Value();
    297312
    298313            char buff[256];
    299             sprintf(buff, "Outline: %d", outlineVal);
     314            sprintf(buff, B_TRANSLATE("Outline: %d"), outlineVal);
    300315            fOutlineSlider->SetLabel(buff);
    301316
    302317            fAliasingCheckBox->SetEnabled(outlineVal < 1);
     
    310325
    311326        case CYCLING_FONTS_MSG:
    312327        {
    313             fCyclingFontButton->SetLabel(fCycleFonts ? "Cycle fonts" : "Stop cycling");
     328            fCyclingFontButton->SetLabel(fCycleFonts ? \
     329                B_TRANSLATE("Cycle fonts") : B_TRANSLATE("Stop cycling"));
    314330            fCycleFonts = !fCycleFonts;
    315331
    316332            if (fCycleFonts) {
     
    456472
    457473    _UpdateFontmenus(true);
    458474
    459     fFontMenuField = new BMenuField(rect, "FontMenuField", "Font:", fFontFamilyMenu, true);
     475    fFontMenuField = new BMenuField(rect, "FontMenuField",
     476        B_TRANSLATE("Font:"), fFontFamilyMenu, true);
    460477    fFontMenuField->SetDivider(30.0);
    461478    AddChild(fFontMenuField);
    462479}
  • src/apps/fontdemo/FontDemo.cpp

     
    1111#include "FontDemoView.h"
    1212#include "ControlView.h"
    1313
     14#include <Catalog.h>
    1415#include <Window.h>
    1516
     17#undef B_TRANSLATE_CONTEXT
     18#define B_TRANSLATE_CONTEXT "FontDemo"
    1619
     20const BString APP_NAME = B_TRANSLATE_MARK("FontDemo");
     21
    1722FontDemo::FontDemo()
    1823    : BApplication("application/x-vnd.Haiku-FontDemo")
    1924{
    2025    // Create the demo window where we draw the string
    21     BWindow* demoWindow = new BWindow(BRect(80, 30, 490, 300), "FontDemo",
     26    BWindow* demoWindow = new BWindow(BRect(80, 30, 490, 300), APP_NAME,
    2227        B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE);
    2328
    2429    FontDemoView* demoView = new FontDemoView(demoWindow->Bounds());
    2530    demoWindow->AddChild(demoView);
    2631
    27     BWindow* controlWindow = new BWindow(BRect(500, 30, 700, 402), "Controls",
     32    BWindow* controlWindow = new BWindow(BRect(500, 30, 700, 402), B_TRANSLATE("Controls"),
    2833        B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL,
    2934        B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS);
    3035