Ticket #7136: giftranslator-localization.patch

File giftranslator-localization.patch, 14.1 KB (added by Karvjorm, 14 years ago)

A GIFTranslator localization patch.

  • src/add-ons/translators/gif/GIFView.cpp

     
    1919#include <stdio.h>
    2020#include <stdlib.h>
    2121
     22#include <Catalog.h>
    2223#include <GridLayoutBuilder.h>
    2324#include <GroupLayout.h>
    2425#include <GroupLayoutBuilder.h>
     
    3031
    3132#include "GIFView.h"
    3233
     34#undef B_TRANSLATE_CONTEXT
     35#define B_TRANSLATE_CONTEXT "GIFView"
     36
     37
    3338extern int32 translatorVersion;
    3439extern char translatorName[];
    3540
     
    4348    title->SetFont(be_bold_font);
    4449
    4550    char version_string[100];
    46     sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8), (int)((translatorVersion >> 4) & 0xf),
    47         (int)(translatorVersion & 0xf), __DATE__);
     51    sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8),
     52        (int)((translatorVersion >> 4) & 0xf), (int)(translatorVersion & 0xf),
     53        __DATE__);
    4854    BStringView *version = new BStringView("Version", version_string);
    4955
    5056    const char *copyrightString = "©2003 Daniel Switkin, software@switkin.com";
    5157    BStringView *copyright = new BStringView("Copyright", copyrightString);
    5258
    5359    // menu fields (Palette & Colors)
    54     fWebSafeMI = new BMenuItem("Websafe", new BMessage(GV_WEB_SAFE), 0, 0);
    55     fBeOSSystemMI = new BMenuItem("BeOS system", new BMessage(GV_BEOS_SYSTEM), 0, 0);
    56     fGreyScaleMI = new BMenuItem("Greyscale", new BMessage(GV_GREYSCALE), 0, 0);
    57     fOptimalMI = new BMenuItem("Optimal", new BMessage(GV_OPTIMAL), 0, 0);
     60    fWebSafeMI = new BMenuItem(B_TRANSLATE("Websafe"),
     61        new BMessage(GV_WEB_SAFE), 0, 0);
     62    fBeOSSystemMI = new BMenuItem(B_TRANSLATE("BeOS system"),
     63        new BMessage(GV_BEOS_SYSTEM), 0, 0);
     64    fGreyScaleMI = new BMenuItem(B_TRANSLATE("Greyscale"),
     65        new BMessage(GV_GREYSCALE), 0, 0);
     66    fOptimalMI = new BMenuItem(B_TRANSLATE("Optimal"),
     67        new BMessage(GV_OPTIMAL), 0, 0);
    5868    fPaletteM = new BPopUpMenu("PalettePopUpMenu", true, true, B_ITEMS_IN_COLUMN);
    5969    fPaletteM->AddItem(fWebSafeMI);
    6070    fPaletteM->AddItem(fBeOSSystemMI);
    6171    fPaletteM->AddItem(fGreyScaleMI);
    6272    fPaletteM->AddItem(fOptimalMI);
    6373
    64     fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true, B_ITEMS_IN_COLUMN);
     74    fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true,
     75        B_ITEMS_IN_COLUMN);
    6576    int32 count = 2;
    6677    for (int32 i = 0; i < 8; i++) {
    6778        BMessage* message = new BMessage(GV_SET_COLOR_COUNT);
     
    7485    }
    7586    fColorCount256MI = fColorCountMI[7];
    7687
    77     fPaletteMF = new BMenuField("Palette", fPaletteM, NULL);
     88    fPaletteMF = new BMenuField(B_TRANSLATE("Palette"), fPaletteM, NULL);
    7889 
    79     fColorCountMF = new BMenuField("Colors", fColorCountM, NULL);
     90    fColorCountMF = new BMenuField(B_TRANSLATE("Colors"), fColorCountM, NULL);
    8091 
    8192    // check boxes
    82     fUseDitheringCB = new BCheckBox("Use dithering",
     93    fUseDitheringCB = new BCheckBox(B_TRANSLATE("Use dithering"),
    8394        new BMessage(GV_USE_DITHERING));
    8495 
    85     fInterlacedCB = new BCheckBox("Write interlaced images",
     96    fInterlacedCB = new BCheckBox(B_TRANSLATE("Write interlaced images"),
    8697        new BMessage(GV_INTERLACED));
    8798 
    88     fUseTransparentCB = new BCheckBox("Write transparent images",
     99    fUseTransparentCB = new BCheckBox(B_TRANSLATE("Write transparent images"),
    89100        new BMessage(GV_USE_TRANSPARENT));
    90101 
    91102    // radio buttons
    92     fUseTransparentAutoRB = new BRadioButton("Automatic (from alpha channel)",
     103    fUseTransparentAutoRB = new BRadioButton(
     104        B_TRANSLATE("Automatic (from alpha channel)"),
    93105        new BMessage(GV_USE_TRANSPARENT_AUTO));
    94106 
    95     fUseTransparentColorRB = new BRadioButton("Use RGB color",
     107    fUseTransparentColorRB = new BRadioButton(B_TRANSLATE("Use RGB color"),
    96108        new BMessage(GV_USE_TRANSPARENT_COLOR));
    97109 
    98110    fTransparentRedTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_RED));
  • src/add-ons/translators/gif/GIFLoad.cpp

     
    4040    }
    4141   
    4242    if (debug)
    43         printf("GIFLoad::GIFLoad() - Image dimensions are %d x %d\n", fWidth, fHeight);
     43        printf("GIFLoad::GIFLoad() - Image dimensions are %d x %d\n", fWidth,
     44            fHeight);
    4445   
    4546    unsigned char c;
    4647    if (fInput->Read(&c, 1) < 1) {
     
    5556                fatalerror = true;
    5657            } else {
    5758                if (debug)
    58                     printf("GIFLoad::GIFLoad() - Found a single image and leaving\n");
     59                    printf("GIFLoad::GIFLoad() - Found a single image and "
     60                        "leaving\n");
    5961            }
    6062            free(fScanLine);
    6163            fScanLine = NULL;
     
    117119    if (header[10] & GIF_LOCALCOLORMAP) {
    118120        fPalette->size_in_bits = (header[10] & 0x07) + 1;
    119121        if (debug)
    120             printf("GIFLoad::ReadGIFHeader() - Found %d bit global palette\n", fPalette->size_in_bits);
     122            printf("GIFLoad::ReadGIFHeader() - Found %d bit global palette\n",
     123                fPalette->size_in_bits);
    121124        int s = 1 << fPalette->size_in_bits;
    122125        fPalette->size = s;
    123126
     
    131134    } else { // Install BeOS system palette in case local palette isn't present
    132135        color_map *map = (color_map *)system_colors();
    133136        for (int x = 0; x < 256; x++) {
    134             fPalette->SetColor(x, map->color_list[x].red, map->color_list[x].green,
    135                 map->color_list[x].blue);
     137            fPalette->SetColor(x, map->color_list[x].red,
     138                map->color_list[x].green, map->color_list[x].blue);
    136139        }
    137140        fPalette->size = 256;
    138141        fPalette->size_in_bits = 8;
     
    169172        fPalette->usetransparent = true;
    170173        fPalette->transparentindex = data[4];
    171174        if (debug)
    172             printf("GIFLoad::ReadGIFControlBlock() - Transparency active, using palette index %d\n", data[4]);
     175            printf("GIFLoad::ReadGIFControlBlock() - Transparency active, "
     176                "using palette index %d\n", data[4]);
    173177    }
    174178    return true;
    175179}
     
    222226    int localHeight = data[6] + (data[7] << 8);
    223227    if (fWidth != localWidth || fHeight != localHeight) {
    224228        if (debug)
    225             printf("GIFLoad::ReadGIFImageHeader() - Local dimensions do not match global, setting to %d x %d\n",
    226             localWidth, localHeight);
     229            printf("GIFLoad::ReadGIFImageHeader() - Local dimensions do not "
     230                "match global, setting to %d x %d\n", localWidth, localHeight);
    227231        fWidth = localWidth;
    228232        fHeight = localHeight;
    229233    }
    230234   
    231235    fScanLine = (uint32 *)malloc(fWidth * 4);
    232236    if (fScanLine == NULL) {
    233         if (debug) printf("GIFLoad::ReadGIFImageHeader() - Could not allocate scanline\n");
     237        if (debug)
     238            printf("GIFLoad::ReadGIFImageHeader() - Could not allocate "
     239                "scanline\n");
    234240        return false;
    235241    }
    236242       
     
    253259        int s = 1 << fPalette->size_in_bits;
    254260        fPalette->size = s;
    255261        if (debug)
    256             printf("GIFLoad::ReadGIFImageHeader() - Found %d bit local palette\n",
    257                 fPalette->size_in_bits);
     262            printf("GIFLoad::ReadGIFImageHeader() - Found %d bit local "
     263                "palette\n", fPalette->size_in_bits);
    258264       
    259265        unsigned char lp[256 * 3];
    260266        if (fInput->Read(lp, s * 3) < s * 3)
     
    269275        if (fInterlaced)
    270276            printf("GIFLoad::ReadGIFImageHeader() - Image is interlaced\n");
    271277        else
    272             printf("GIFLoad::ReadGIFImageHeader() - Image is not interlaced\n");
     278            printf("GIFLoad::ReadGIFImageHeader() - Image is not "
     279                "interlaced\n");
    273280    }
    274281    return true;
    275282}
     
    287294            return false;
    288295    } else if (cs > fPalette->size_in_bits) {
    289296        if (debug)
    290             printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not %d, allowing it\n", fCodeSize, cs);
     297            printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
     298                "%d, allowing it\n", fCodeSize, cs);
    291299        if (!InitFrame(cs))
    292300            return false;
    293301    } else if (cs < fPalette->size_in_bits) {
    294302        if (debug)
    295             printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not %d\n", fCodeSize, cs);
     303            printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not "
     304                "%d\n", fCodeSize, cs);
    296305        return false;
    297306    }
    298307   
     
    308317            if (!OutputColor(fOldCode, 1)) goto bad_end;
    309318            if (fNewCode == -1 || fNewCode == fEndCode) {
    310319                if (debug)
    311                     printf("GIFLoad::ReadGIFImageData() - Premature fEndCode or error\n");
     320                    printf("GIFLoad::ReadGIFImageData() - Premature fEndCode "
     321                        "or error\n");
    312322                goto bad_end;
    313323            }
    314324            continue;
     
    391401        if (fByteCount == 0) {
    392402            if (fInput->Read(&fByteCount, 1) < 1) return -1;
    393403            if (fByteCount == 0) return fEndCode;
    394             if (fInput->Read(fByteBuffer + (255 - fByteCount), fByteCount) < fByteCount) return -1;
     404            if (fInput->Read(fByteBuffer + (255 - fByteCount),
     405                fByteCount) < fByteCount) return -1;
    395406        }
    396407        fBitBuffer |= (unsigned int)fByteBuffer[255 - fByteCount] << fBitCount;
    397408        fByteCount--;
  • src/add-ons/translators/gif/GIFTranslator.cpp

     
    1818#include "GIFView.h"
    1919#include "GIFSave.h"
    2020#include "GIFLoad.h"
     21
     22
    2123#include <ByteOrder.h>
     24#include <Catalog.h>
     25#include <DataIO.h>
     26#include <InterfaceDefs.h>
    2227#include <TypeConstants.h>
    23 #include <DataIO.h>
    2428#include <TranslatorAddOn.h>
    2529#include <TranslatorFormats.h>
    26 #include <InterfaceDefs.h>
     30
    2731#include <stdio.h>
    2832#include <stdlib.h>
    2933#include <string.h>
     
    3236#define GIF_TYPE 'GIF '
    3337#endif
    3438
     39#undef B_TRANSLATE_CONTEXT
     40#define B_TRANSLATE_CONTEXT "GIFTranslator"
     41
     42
    3543// This global will be externed in other files - set once here
    3644// for the entire translator
    3745bool debug = false;
     
    4553int32 translatorVersion = 0x140;
    4654
    4755translation_format inputFormats[] = {
    48     { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", "GIF image" },
    49     { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" },
     56    { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif",
     57        "GIF image" },
     58    { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap",
     59        "Be Bitmap Format (GIFTranslator)" },
    5060    { 0 }
    5161};
    5262
    5363translation_format outputFormats[] = {
    54     { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", "GIF image" },
    55     { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" },
     64    { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif",
     65        "GIF image" },
     66    { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap",
     67        "Be Bitmap Format (GIFTranslator)" },
    5668    { 0 }
    5769};
    5870
     
    7991    if (source->Read(header, 6) != 6) return false;
    8092    header[6] = 0x00;
    8193
    82     if (strcmp((char *)header, "GIF87a") != 0 && strcmp((char *)header, "GIF89a") != 0) {
     94    if (strcmp((char *)header, "GIF87a") != 0 && strcmp((char *)header,
     95        "GIF89a") != 0) {
    8396        *is_gif = false;
    84         int32 magic = (header[0] << 24) + (header[1] << 16) + (header[2] << 8) + header[3];
     97        int32 magic = (header[0] << 24) + (header[1] << 16) + (header[2] << 8)
     98            + header[3];
    8599        if (magic != B_TRANSLATOR_BITMAP) return false;
    86100        source->Seek(5 * 4 - 2, SEEK_CUR);
    87101        color_space cs;
    88102        if (source->Read(&cs, 4) != 4) return false;
    89103        cs = (color_space)B_BENDIAN_TO_HOST_INT32(cs);
    90         if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs != B_RGBA32_BIG) return false;
     104        if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs
     105            != B_RGBA32_BIG) return false;
    91106    }
    92107
    93108    source->Seek(0, SEEK_SET);
     
    141156    if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true;
    142157
    143158    if (outType == 0) outType = B_TRANSLATOR_BITMAP;
    144     if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR;
     159    if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP)
     160        return B_NO_TRANSLATOR;
    145161
    146162    bool is_gif;
    147163    if (!DetermineType(inSource, &is_gif)) return B_NO_TRANSLATOR;
     
    153169        outInfo->type = GIF_TYPE;
    154170        outInfo->quality = 0.8;
    155171        outInfo->capability = 0.8;
    156         strcpy(outInfo->name, "GIF image");
     172        strcpy(outInfo->name, B_TRANSLATE("GIF image"));
    157173        strcpy(outInfo->MIME, "image/gif");
    158174    }
    159175    else {
    160176        outInfo->type = B_TRANSLATOR_BITMAP;
    161177        outInfo->quality = 0.3;
    162178        outInfo->capability = 0.3;
    163         strcpy(outInfo->name, "Be Bitmap Format (GIFTranslator)");
     179        strcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (GIFTranslator)"));
    164180        strcpy(outInfo->MIME, "image/x-be-bitmap");
    165181    }
    166182    return B_OK;
     
    213229
    214230    if (debug) {
    215231        now = system_time() - now;
    216         printf("Translate() - Translation took %Ld microseconds\n", now);
     232        printf(
     233            B_TRANSLATE("Translate() - Translation took %Ld microseconds\n"),
     234            now);
    217235    }
    218236    return B_OK;
    219237}
     
    223241    : BApplication("application/x-vnd.Haiku-GIFTranslator")
    224242{
    225243    BRect rect(100, 100, 339, 339);
    226     gifwindow = new GIFWindow(rect, "GIF Settings");
     244    gifwindow = new GIFWindow(rect, B_TRANSLATE("GIF Settings"));
    227245    gifwindow->Show();
    228246}
    229247
  • src/add-ons/translators/gif/GIFSave.cpp

     
    101101        if (prefs->usetransparentauto) {
    102102            palette->PrepareForAutoTransparency();
    103103            if (debug)
    104                 printf("GIFSave::GIFSave() - Using transparent index %d\n", palette->TransparentIndex());
     104                printf("GIFSave::GIFSave() - Using transparent index %d\n",
     105                    palette->TransparentIndex());
    105106        } else {
    106107            palette->SetTransparentColor((uint8)prefs->transparentred,
    107108                                         (uint8)prefs->transparentgreen,
    108109                                         (uint8)prefs->transparentblue);
    109110            if (debug) {
    110                 printf("GIFSave::GIFSave() - Found transparent color %d,%d,%d at index %d\n",
    111                        prefs->transparentred, prefs->transparentgreen, prefs->transparentblue,
    112                        palette->TransparentIndex());
     111                printf("GIFSave::GIFSave() - Found transparent color %d,%d,%d "
     112                    "at index %d\n", prefs->transparentred,
     113                    prefs->transparentgreen, prefs->transparentblue,
     114                    palette->TransparentIndex());
    113115            }
    114116        }
    115117    } else {
  • src/add-ons/translators/gif/Jamfile

     
    2020    : true
    2121;
    2222
     23DoCatalogs GIFTranslator :
     24    x-vnd.Haiku-GIFTranslator
     25    :
     26    GIFTranslator.cpp
     27    GIFView.cpp
     28;
     29
     30
    2331Package haiku-translationkit-cvs :
    2432    GIFTranslator :
    2533    boot home config add-ons Translators ;