Ticket #7135: ppmtranslator-localization.patch

File ppmtranslator-localization.patch, 13.1 KB (added by Karvjorm, 13 years ago)

A PPMTranslator localization patch

  • src/add-ons/translators/ppm/PPMMain.cpp

     
    33    This file may be used under the terms of the Be Sample Code License.
    44*/
    55
     6#include <Alert.h>
     7#include <Application.h>
     8#include <Catalog.h>
     9#include <GroupLayout.h>
     10#include <Screen.h>
    611#include <TranslatorAddOn.h>
    712#include <View.h>
    813#include <Window.h>
    9 #include <Application.h>
    10 #include <Alert.h>
    11 #include <Screen.h>
    12 #include <GroupLayout.h>
    1314
     15
    1416#include <stdio.h>
    1517
     18#undef B_TRANSLATE_CONTEXT
     19#define B_TRANSLATE_CONTEXT "PPMMain"
    1620
     21
    1722BPoint get_window_origin();
    1823void set_window_origin(BPoint pt);
    1924
     
    2227{
    2328public:
    2429    PPMWindow(BRect area) :
    25         BWindow(area, "PPM Settings", B_TITLED_WINDOW,
     30        BWindow(area, B_TRANSLATE("PPM Settings"), B_TITLED_WINDOW,
    2631            B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
    2732        {
    2833            SetLayout(new BGroupLayout(B_HORIZONTAL));
     
    4348    BView * v = NULL;
    4449    BRect r(0, 0, 1, 1);
    4550    if (MakeConfig(NULL, &v, &r)) {
    46         BAlert * err = new BAlert("Error", "Something is wrong with the PPMTranslator!", "OK");
     51        BAlert * err = new BAlert("Error",
     52            B_TRANSLATE("Something is wrong with the PPMTranslator!"),
     53            B_TRANSLATE("OK"));
    4754        err->Go();
    4855        return 1;
    4956    }
  • src/add-ons/translators/ppm/Jamfile

     
    44
    55Translator PPMTranslator
    66    : PPMMain.cpp PPMTranslator.cpp colorspace.cpp
    7     : be translation $(TARGET_LIBSUPC++)
     7    : be translation $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
    88    : true
    99;
    1010
     11DoCatalogs PPMTranslator :
     12    x-vnd.Haiku-PPMTranslator
     13    :
     14    PPMMain.cpp
     15    PPMTranslator.cpp
     16;
     17
    1118Package haiku-translationkit-cvs :
    1219    PPMTranslator :
    1320    boot home config add-ons Translators ;
  • src/add-ons/translators/ppm/PPMTranslator.cpp

     
    88/*  does not buffer data. We should wrap a buffering thing around   */
    99/*  the input or output when they are in ASCII mode.                */
    1010
    11 #include <TranslatorAddOn.h>
    12 #include <TranslationKit.h>
     11#include <Bitmap.h>
    1312#include <ByteOrder.h>
    14 #include <Message.h>
    15 #include <Screen.h>
    16 #include <Locker.h>
     13#include <Catalog.h>
     14#include <CheckBox.h>
    1715#include <FindDirectory.h>
    18 #include <Path.h>
    19 #include <PopUpMenu.h>
    20 #include <MenuField.h>
    21 #include <MenuItem.h>
    22 #include <CheckBox.h>
    23 #include <Bitmap.h>
    24 #include <StringView.h>
    2516#include <GridLayoutBuilder.h>
    2617#include <GroupLayout.h>
    2718#include <GroupLayoutBuilder.h>
     19#include <Locker.h>
     20#include <MenuField.h>
     21#include <MenuItem.h>
     22#include <Message.h>
     23#include <Path.h>
     24#include <PopUpMenu.h>
     25#include <Screen.h>
    2826#include <SpaceLayoutItem.h>
     27#include <StringView.h>
     28#include <TranslatorAddOn.h>
     29#include <TranslationKit.h>
    2930
    3031#include <ctype.h>
    3132#include <string.h>
     
    3435
    3536#include "colorspace.h"
    3637
     38#undef B_TRANSLATE_CONTEXT
     39#define B_TRANSLATE_CONTEXT "PPMTranslator"
    3740
    3841#if DEBUG
    3942 #define dprintf(x) printf x
     
    4346
    4447
    4548#if !defined(_PR3_COMPATIBLE_)  /* R4 headers? Else we need to define these constants. */
    46  #define B_CMY24 ((color_space)0xC001) /* C[7:0]  M[7:0]  Y[7:0]                       No gray removal done            */
    47  #define B_CMY32 ((color_space)0xC002) /* C[7:0]  M[7:0]  Y[7:0]  X[7:0]       No gray removal done            */
    48  #define B_CMYA32 ((color_space)0xE002) /* C[7:0]  M[7:0]  Y[7:0]  A[7:0]       No gray removal done            */
    49  #define B_CMYK32 ((color_space)0xC003) /* C[7:0]  M[7:0]  Y[7:0]  K[7:0]                                       */
     49 #define B_CMY24 ((color_space)0xC001) /* C[7:0]  M[7:0]  Y[7:0]          No gray removal done */
     50 #define B_CMY32 ((color_space)0xC002) /* C[7:0]  M[7:0]  Y[7:0]  X[7:0]  No gray removal done */
     51 #define B_CMYA32 ((color_space)0xE002) /* C[7:0]  M[7:0]  Y[7:0]  A[7:0] No gray removal done */
     52 #define B_CMYK32 ((color_space)0xC003) /* C[7:0]  M[7:0]  Y[7:0]  K[7:0]                      */
    5053#endif
    5154
    5255#define PPM_TRANSLATOR_VERSION 0x100
     
    5962    // Minor: next 4 bits
    6063    // Major: highest 24 bits
    6164
    62 /*  Be reserves all codes with non-lowecase letters in them.    */
     65/*  Be reserves all codes with non-lowercase letters in them.   */
    6366/*  Luckily, there is already a reserved code for PPM. If you   */
    6467/*  make up your own for a new type, use lower-case letters.    */
    6568#define PPM_TYPE 'PPM '
     
    150153                            continue;
    151154                        }
    152155                        if (sscanf(ptr, "%31[a-zA-Z_0-9] =", name) != 1) {
    153                             fprintf(stderr, "unknown PPMTranslator settings line: %s", line);
     156                            fprintf(stderr,
     157                                B_TRANSLATE("unknown PPMTranslator settings "
     158                                    "line: %s"), line);
    154159                        }
    155160                        else {
    156161                            if (!strcmp(name, "color_space")) {
     
    158163                                    ptr++;
    159164                                }
    160165                                ptr++;
    161                                 if (sscanf(ptr, "%d", (int*)&g_settings.out_space) != 1) {
    162                                     fprintf(stderr, "illegal color space in PPMTranslator settings: %s", ptr);
     166                                if (sscanf(ptr, "%d",
     167                                    (int*)&g_settings.out_space) != 1) {
     168                                    fprintf(stderr,
     169                                        B_TRANSLATE("illegal color space in "
     170                                            "PPMTranslator settings: %s"),
     171                                            ptr);
    163172                                }
    164173                            }
    165174                            else if (!strcmp(name, "window_pos")) {
     
    167176                                    ptr++;
    168177                                }
    169178                                ptr++;
    170                                 if (sscanf(ptr, "%f,%f", &g_settings.window_pos.x, &g_settings.window_pos.y) != 2) {
    171                                     fprintf(stderr, "illegal window position in PPMTranslator settings: %s", ptr);
     179                                if (sscanf(ptr, "%f,%f",
     180                                    &g_settings.window_pos.x,
     181                                    &g_settings.window_pos.y) != 2) {
     182                                    fprintf(stderr,
     183                                        B_TRANSLATE("illegal window position "
     184                                            "in PPMTranslator settings: %s"),
     185                                            ptr);
    172186                                }
    173187                            }
    174188                            else if (!strcmp(name, "write_ascii")) {
     
    178192                                ptr++;
    179193                                int ascii = g_settings.write_ascii;
    180194                                if (sscanf(ptr, "%d", &ascii) != 1) {
    181                                     fprintf(stderr, "illegal write_ascii value in PPMTranslator settings: %s", ptr);
     195                                    fprintf(stderr,
     196                                        B_TRANSLATE("illegal write_ascii "
     197                                            "value in PPMTranslator "
     198                                            "settings: %s"), ptr);
    182199                                }
    183200                                else {
    184201                                    g_settings.write_ascii = ascii;
    185202                                }
    186203                            }
    187204                            else {
    188                                 fprintf(stderr, "unknown PPMTranslator setting: %s", line);
     205                                fprintf(stderr,
     206                                    B_TRANSLATE("unknown PPMTranslator "
     207                                        "setting: %s"), line);
    189208                            }
    190209                        }
    191210                    }
     
    203222                    path.Append("PPMTranslator_Settings");
    204223                    FILE * f = fopen(path.Path(), "w");
    205224                    if (f) {
    206                         fprintf(f, "# PPMTranslator settings version %d.%d.%d\n",
     225                        fprintf(f, B_TRANSLATE("# PPMTranslator settings "
     226                            "version %d.%d.%d\n"),
    207227                            static_cast<int>(translatorVersion >> 8),
    208228                            static_cast<int>((translatorVersion >> 4) & 0xf),
    209229                            static_cast<int>(translatorVersion & 0xf));
     
    267287        outInfo->type = PPM_TYPE;
    268288        outInfo->quality = 0.3;     /* no alpha, etc */
    269289        outInfo->capability = 0.8;  /* we're pretty good at PPM reading, though */
    270         strcpy(outInfo->name, "PPM image");
     290        strcpy(outInfo->name, B_TRANSLATE("PPM image"));
    271291        strcpy(outInfo->MIME, "image/x-portable-pixmap");
    272292    }
    273293    else {
    274294        outInfo->type = B_TRANSLATOR_BITMAP;
    275295        outInfo->quality = 0.4;     /* B_TRANSLATOR_BITMAP can do alpha, at least */
    276296        outInfo->capability = 0.8;  /* and we might not know many variations thereof */
    277         strcpy(outInfo->name, "Be Bitmap Format (PPMTranslator)");
     297        strcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (PPMTranslator)"));
    278298        strcpy(outInfo->MIME, "image/x-be-bitmap"); /* this is the MIME type of B_TRANSLATOR_BITMAP */
    279299    }
    280300    return B_OK;
     
    442462                SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    443463                SetLowColor(ViewColor());
    444464
    445                 mTitle = new BStringView("title", "PPM Image Translator");
     465                mTitle = new BStringView("title",
     466                    B_TRANSLATE("PPM Image Translator"));
    446467                mTitle->SetFont(be_bold_font);
    447468
    448469                char detail[100];
    449470                int ver = static_cast<int>(translatorVersion);
    450                 sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf),
     471                sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), ver >> 8,
     472                    ((ver >> 4) & 0xf),
    451473                    (ver & 0xf), __DATE__);
    452474                mDetail = new BStringView("detail", detail);
    453475
    454476                mBasedOn = new BStringView("basedOn",
    455                     "Based on PPMTranslator sample code");
     477                    B_TRANSLATE("Based on PPMTranslator sample code"));
    456478
    457479                mCopyright = new BStringView("copyright",
    458                     "Sample code copyright 1999, Be Incorporated");
     480                    B_TRANSLATE("Sample code copyright 1999, Be Incorporated"));
    459481
    460482                mMenu = new BPopUpMenu("Color Space");
    461                 mMenu->AddItem(new BMenuItem("None", CSMessage(B_NO_COLOR_SPACE)));
    462                 mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits", CSMessage(B_RGB32)));
    463                 mMenu->AddItem(new BMenuItem("RGBA 8:8:8:8 32 bits", CSMessage(B_RGBA32)));
    464                 mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits", CSMessage(B_RGB15)));
    465                 mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits", CSMessage(B_RGBA15)));
    466                 mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits", CSMessage(B_RGB16)));
    467                 mMenu->AddItem(new BMenuItem("System palette 8 bits", CSMessage(B_CMAP8)));
     483                mMenu->AddItem(new BMenuItem(B_TRANSLATE("None"),
     484                    CSMessage(B_NO_COLOR_SPACE)));
     485                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 8:8:8 32 bits"),
     486                    CSMessage(B_RGB32)));
     487                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 8:8:8:8 32 "
     488                    "bits"), CSMessage(B_RGBA32)));
     489                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:5:5 16 bits"),
     490                    CSMessage(B_RGB15)));
     491                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 5:5:5:1 16 "
     492                    "bits"), CSMessage(B_RGBA15)));
     493                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:6:5 16 bits"),
     494                    CSMessage(B_RGB16)));
     495                mMenu->AddItem(new BMenuItem(B_TRANSLATE("System palette 8 "
     496                    "bits"), CSMessage(B_CMAP8)));
    468497                mMenu->AddSeparatorItem();
    469                 mMenu->AddItem(new BMenuItem("Grayscale 8 bits", CSMessage(B_GRAY8)));
    470                 mMenu->AddItem(new BMenuItem("Bitmap 1 bit", CSMessage(B_GRAY1)));
    471                 mMenu->AddItem(new BMenuItem("CMY 8:8:8 32 bits", CSMessage(B_CMY32)));
    472                 mMenu->AddItem(new BMenuItem("CMYA 8:8:8:8 32 bits", CSMessage(B_CMYA32)));
    473                 mMenu->AddItem(new BMenuItem("CMYK 8:8:8:8 32 bits", CSMessage(B_CMYK32)));
     498                mMenu->AddItem(new BMenuItem(B_TRANSLATE("Grayscale 8 bits"),
     499                    CSMessage(B_GRAY8)));
     500                mMenu->AddItem(new BMenuItem(B_TRANSLATE("Bitmap 1 bit"),
     501                    CSMessage(B_GRAY1)));
     502                mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMY 8:8:8 32 bits"),
     503                    CSMessage(B_CMY32)));
     504                mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMYA 8:8:8:8 32 "
     505                    "bits"), CSMessage(B_CMYA32)));
     506                mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMYK 8:8:8:8 32 "
     507                    "bits"), CSMessage(B_CMYK32)));
    474508                mMenu->AddSeparatorItem();
    475                 mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits big-endian", CSMessage(B_RGB32_BIG)));
    476                 mMenu->AddItem(new BMenuItem("RGBA 8:8:8:8 32 bits big-endian", CSMessage(B_RGBA32_BIG)));
    477                 mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits big-endian", CSMessage(B_RGB15_BIG)));
    478                 mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits big-endian", CSMessage(B_RGBA15_BIG)));
    479                 mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits big-endian", CSMessage(B_RGB16)));
    480                 mField = new BMenuField("Input Color Space", mMenu, NULL);
     509                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 8:8:8 32 bits "
     510                    "big-endian"), CSMessage(B_RGB32_BIG)));
     511                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 8:8:8:8 32 "
     512                    "bits big-endian"), CSMessage(B_RGBA32_BIG)));
     513                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:5:5 16 bits "
     514                    "big-endian"), CSMessage(B_RGB15_BIG)));
     515                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 5:5:5:1 16 "
     516                    "bits big-endian"), CSMessage(B_RGBA15_BIG)));
     517                mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:6:5 16 bits "
     518                    "big-endian"), CSMessage(B_RGB16)));
     519                mField = new BMenuField(B_TRANSLATE("Input Color Space"),
     520                    mMenu, NULL);
    481521                mField->SetViewColor(ViewColor());
    482522                SelectColorSpace(g_settings.out_space);
    483523                BMessage * msg = new BMessage(CHANGE_ASCII);
    484                 mAscii = new BCheckBox("Write ASCII", msg);
     524                mAscii = new BCheckBox(B_TRANSLATE("Write ASCII"), msg);
    485525                if (g_settings.write_ascii)
    486526                    mAscii->SetValue(1);
    487527                mAscii->SetViewColor(ViewColor());
     
    616656    BView * * outView,
    617657    BRect * outExtent)
    618658{
    619     PPMView * v = new PPMView("PPMTranslator Settings", B_WILL_DRAW);
     659    PPMView * v = new PPMView(B_TRANSLATE("PPMTranslator Settings"),
     660        B_WILL_DRAW);
    620661    *outView = v;
    621662    v->ResizeTo(v->ExplicitPreferredSize());;
    622663    *outExtent = v->Bounds();
     
    639680#if defined(_PR3_COMPATIBLE_)
    640681    const char * name = B_TRANSLATOR_EXT_BITMAP_COLOR_SPACE;
    641682#else
    642     const char * name = "bits/space";
     683    const char * name = B_TRANSLATE_MARK("bits/space");
    643684#endif
    644685    g_settings_lock.Lock();
    645686    (void)ioExtension->RemoveName(name);