Ticket #7163: pnginfo-localization.patch

File pnginfo-localization.patch, 7.0 KB (added by Karvjorm, 13 years ago)

An updated pnginfo localization patch

  • src/tools/translation/pnginfo/pnginfo.rdef

     
     1/*
     2 * pnginfo.rdef
     3 */
     4
     5resource app_signature "application/x-vnd.Haiku-pnginfo";
     6
     7resource app_version {
     8    major  = 1,
     9    middle = 0,
     10    minor  = 0,
     11    variety = 0,
     12    internal = 0,
     13    short_info = "pnginfo displays text information about PNG images.",
     14    long_info = "Haiku pnginfo is a command line tool for displaying text information about PNG images. Written by Michael Wilber, OBOS Translation Kit Team, Copyright © 2004 OpenBeOS Project."
     15};
     16
     17resource app_flags B_SINGLE_LAUNCH;
  • src/tools/translation/pnginfo/pnginfo.cpp

     
    3636#include <string.h>
    3737#include <png.h>
    3838#include <ByteOrder.h>
     39#include <Catalog.h>
    3940#include <File.h>
    4041#include <TranslatorFormats.h>
    4142#include <StorageDefs.h>
    4243
     44#undef B_TRANSLATE_CONTEXT
     45#define B_TRANSLATE_CONTEXT "pnginfo"
     46
    4347 /* The png_jmpbuf() macro, used in error handling, became available in
    4448  * libpng version 1.0.6.  If you want to be able to run your code with older
    4549  * versions of libpng, you must define the macro yourself (but only if it
     
    8892    BFile *pfile;
    8993    pfile = new BFile(path, B_READ_ONLY);
    9094    if (!pfile || pfile->InitCheck() != B_OK) {
    91         printf("Error: unable to open the file\n");
     95        printf(B_TRANSLATE("Error: unable to open the file\n"));
    9296        return;
    9397    }
    9498    BPositionIO *pio = static_cast<BPositionIO *>(pfile);
     
    96100    const int32 kSigSize = 8;
    97101    uint8 buf[kSigSize];
    98102    if (pio->Read(buf, kSigSize) != kSigSize) {
    99         printf("Error: unable to read PNG signature\n");
     103        printf(B_TRANSLATE("Error: unable to read PNG signature\n"));
    100104        return;
    101105    }
    102106    if (!png_check_sig(buf, kSigSize)) {
    103107        // if first 8 bytes of stream don't match PNG signature bail
    104         printf("Error: file doesn't begin with PNG signature\n");
     108        printf(B_TRANSLATE("Error: file doesn't begin with PNG signature\n"));
    105109        return;
    106110    }
    107111
     
    122126            // When an error occurs in libpng, it uses
    123127            // the longjmp function to continue execution
    124128            // from this point
    125             printf("Error: error in libpng function\n");
     129            printf(B_TRANSLATE("Error: error in libpng function\n"));
    126130            break;
    127131        }
    128132       
     
    138142        png_get_IHDR(ppng, pinfo, &width, &height, &bit_depth, &color_type,
    139143            &interlace_type, &compression_type, &filter_type);
    140144
    141         printf("                   width: %lu\n", width);
    142         printf("                  height: %lu\n", height);
    143         printf("               row bytes: %lu\n", pinfo->rowbytes);
    144         printf("bit depth (bits/channel): %d\n", bit_depth);
    145         printf("                channels: %d\n", pinfo->channels);
    146         printf("pixel depth (bits/pixel): %d\n", pinfo->pixel_depth);
    147         printf("              color type: ");
     145        printf(B_TRANSLATE("                   width: %lu\n"), width);
     146        printf(B_TRANSLATE("                  height: %lu\n"), height);
     147        printf(B_TRANSLATE("               row bytes: %lu\n"),
     148            pinfo->rowbytes);
     149        printf(B_TRANSLATE("bit depth (bits/channel): %d\n"), bit_depth);
     150        printf(B_TRANSLATE("                channels: %d\n"), pinfo->channels);
     151        printf(B_TRANSLATE("pixel depth (bits/pixel): %d\n"),
     152            pinfo->pixel_depth);
    148153        const char *desc = NULL;
    149154        switch (color_type) {
    150155            case PNG_COLOR_TYPE_GRAY:
    151                 desc = "Grayscale";
     156                desc = B_TRANSLATE("              color type: Grayscale");
    152157                break;
    153158            case PNG_COLOR_TYPE_PALETTE:
    154                 desc = "Palette";
     159                desc = B_TRANSLATE("              color type: Palette");
    155160                break;
    156161            case PNG_COLOR_TYPE_RGB:
    157                 desc = "RGB";
     162                desc = B_TRANSLATE("              color type: RGB");
    158163                break;
    159164            case PNG_COLOR_TYPE_RGB_ALPHA:
    160                 desc = "RGB + Alpha";
     165                desc = B_TRANSLATE("              color type: RGB + Alpha");
    161166                break;
    162167            case PNG_COLOR_TYPE_GRAY_ALPHA:
    163                 desc = "Grayscale + Alpha";
     168                desc = B_TRANSLATE("              color type: Grayscale + "
     169                    "Alpha");
    164170                break;
    165171            default:
    166                 desc = "Unknown";
     172                desc = B_TRANSLATE("              color type: Unknown");
    167173                break;
    168174        }
    169175        printf("%s (%d)\n", desc, color_type);
    170176       
    171         printf("             interlacing: ");
    172177        switch (interlace_type) {
    173178            case PNG_INTERLACE_NONE:
    174                 desc = "None";
     179                desc = B_TRANSLATE("             interlacing: None");
    175180                break;
    176181            case PNG_INTERLACE_ADAM7:
    177                 desc = "Adam7";
     182                desc = B_TRANSLATE("             interlacing: Adam7");
    178183                break;
    179184            default:
    180                 desc = "Unknown";
     185                desc = B_TRANSLATE("             interlacing: Unknown");
    181186                break;
    182187        }
    183188        printf("%s (%d)\n", desc, interlace_type);
    184189       
    185         printf("        compression type: ");
    186190        switch (compression_type) {
    187191            case PNG_COMPRESSION_TYPE_DEFAULT:
    188                 desc = "Default: Deflate method 8, 32K window";
     192                desc = B_TRANSLATE("        compression type: Default: "
     193                    "Deflate method 8, 32K window");
    189194                break;
    190195            default:
    191                 desc = "Unknown";
     196                desc = B_TRANSLATE("        compression type: Unknown");
    192197                break;
    193198        }
    194199        printf("%s (%d)\n", desc, compression_type);
    195200       
    196         printf("             filter type: ");
    197201        switch (filter_type) {
    198202            case PNG_FILTER_TYPE_DEFAULT:
    199                 desc = "Single row per-byte";
     203                desc = B_TRANSLATE("             filter type: Single row "
     204                    "per-byte");
    200205                break;
    201206            case PNG_INTRAPIXEL_DIFFERENCING:
    202                 desc = "Intrapixel Differencing [for MNG files]";
     207                desc = B_TRANSLATE("             filter type: Intrapixel "
     208                    "Differencing [for MNG files]");
    203209                break;
    204210            default:
    205                 desc = "Unknown";
     211                desc = B_TRANSLATE("             filter type: Unknown");
    206212                break;
    207213        }
    208214        printf("%s (%d)\n", desc, filter_type);
    209215    }
     216#ifndef png_infopp_NULL
     217#define png_infopp_NULL           NULL
     218#endif
    210219    if (ppng) {
    211220        // free PNG handle / info structures
    212221        if (!pinfo)
     
    223232main(int argc, char **argv)
    224233{
    225234    if (argc == 1) {
    226         printf("\npnginfo - reports information about PNG images\n");
    227         printf("\nUsage:\n");
    228         printf("pnginfo [options] filename.png\n\n");
     235        printf(B_TRANSLATE("\npnginfo - reports information about PNG images\n"));
     236        printf(B_TRANSLATE("\nUsage:\n"));
     237        printf(B_TRANSLATE("pnginfo [options] filename.png\n\n"));
    229238    }
    230239    else {
    231240        int32 first = 1;
  • src/tools/translation/pnginfo/Jamfile

     
    33UseLibraryHeaders zlib ;
    44UseLibraryHeaders png ;
    55
    6 BinCommand pnginfo : pnginfo.cpp : be libpng.a libz.a $(TARGET_LIBSUPC++) ;
     6BinCommand pnginfo : pnginfo.cpp : be libbe.so $(HAIKU_LOCALE_LIBS) translation libpng.a libz.a $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ;
    77
     8AddResources pnginfo : pnginfo.rdef ;
     9
     10DoCatalogs pnginfo :
     11    x-vnd.Haiku-pnginfo
     12    :
     13    pnginfo.cpp
     14;
     15