Ticket #7164: bmpinfo-localization.patch

File bmpinfo-localization.patch, 8.1 KB (added by Karvjorm, 13 years ago)

A bmpinfo localization patch.

  • src/tools/translation/bmpinfo/Jamfile

     
    11SubDir HAIKU_TOP src tools translation bmpinfo ;
    22
    3 BinCommand bmpinfo : bmpinfo.cpp : be ;
     3BinCommand bmpinfo : bmpinfo.cpp : be libbe.so $(HAIKU_LOCALE_LIBS) translation $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ;
    44
     5AddResources bmpinfo : bmpinfo.rdef ;
     6
     7DoCatalogs bmpinfo :
     8    x-vnd.Haiku-bmpsinfo
     9    :
     10    bmpinfo.cpp
     11;
  • src/tools/translation/bmpinfo/bmpinfo.rdef

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

     
    3636#include <stdlib.h>
    3737#include <string.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 "bmpinfo"
     46
    4347#define BMP_NO_COMPRESS 0
    4448#define BMP_RLE8_COMPRESS 1
    4549#define BMP_RLE4_COMPRESS 2
     
    8286
    8387    ssize_t size = 14;
    8488    if (file.Read(buf, size) != size) {
    85         printf("Error: unable to read BMP file header\n");
     89        printf(B_TRANSLATE("Error: unable to read BMP file header\n"));
    8690        return;
    8791    }
    8892   
     
    96100    swap_data(B_UINT32_TYPE, (reinterpret_cast<uint8 *> (&fh)) + 2,
    97101        12, B_SWAP_LENDIAN_TO_HOST);
    98102       
    99     printf("\nFile Header:\n");
    100     printf("      magic: 0x%.4x (should be: 0x424d)\n", fh.magic);
    101     printf("  file size: 0x%.8lx (%lu)\n", fh.fileSize, fh.fileSize);
    102     printf("   reserved: 0x%.8lx (should be: 0x%.8x)\n", fh.reserved, 0);
    103     printf("data offset: 0x%.8lx (%lu) (should be: >= 54 for MS format "
    104         "and >= 26 for OS/2 format)\n", fh.dataOffset, fh.dataOffset);
     103    printf(B_TRANSLATE("\nFile Header:\n"));
     104    printf(B_TRANSLATE("      magic: 0x%.4x (should be: 0x424d)\n"), fh.magic);
     105    printf(B_TRANSLATE("  file size: 0x%.8lx (%lu)\n"), fh.fileSize,
     106        fh.fileSize);
     107    printf(B_TRANSLATE("   reserved: 0x%.8lx (should be: 0x%.8x)\n"),
     108        fh.reserved, 0);
     109    printf(B_TRANSLATE("data offset: 0x%.8lx (%lu) (should be: >= 54 for MS "
     110        "format and >= 26 for OS/2 format)\n"), fh.dataOffset, fh.dataOffset);
    105111       
    106112    uint32 headersize = 0;
    107113    if (file.Read(&headersize, 4) != 4) {
    108         printf("Error: unable to read info header size\n");
     114        printf(B_TRANSLATE("Error: unable to read info header size\n"));
    109115        return;
    110116    }
    111117    swap_data(B_UINT32_TYPE, &headersize, 4, B_SWAP_LENDIAN_TO_HOST);
     
    115121        MSInfoHeader msh;
    116122        msh.size = headersize;
    117123        if (file.Read(reinterpret_cast<uint8 *> (&msh) + 4, 36) != 36) {
    118             printf("Error: unable to read entire MS info header\n");
     124            printf(B_TRANSLATE("Error: unable to read entire MS info header\n"));
    119125            return;
    120126        }
    121127   
     
    123129        swap_data(B_UINT32_TYPE, reinterpret_cast<uint8 *> (&msh) + 4, 36,
    124130            B_SWAP_LENDIAN_TO_HOST);
    125131           
    126         printf("\nMS Info Header:\n");
    127         printf("     header size: 0x%.8lx (%lu) (should be: 40)\n", msh.size, msh.size);
    128         printf("           width: %lu\n", msh.width);
    129         printf("          height: %lu\n", msh.height);
    130         printf("          planes: %u (should be: 1)\n", msh.planes);
    131         printf("  bits per pixel: %u (should be: 1,4,8,16,24 or 32)\n", msh.bitsperpixel);
    132         printf("     compression: %s (%lu)\n",
    133             ((msh.compression == BMP_NO_COMPRESS) ? ("none") :
    134                 ((msh.compression == BMP_RLE8_COMPRESS) ? ("RLE 8") :
    135                 ((msh.compression == BMP_RLE4_COMPRESS) ? ("RLE 4") :
    136                 ("unknown")))), msh.compression);
    137         printf("      image size: 0x%.8lx (%lu)\n", msh.imagesize, msh.imagesize);
    138         printf("  x pixels/meter: %lu\n", msh.xpixperm);
    139         printf("  y pixels/meter: %lu\n", msh.ypixperm);
    140         printf("     colors used: %lu\n", msh.colorsused);
    141         printf("colors important: %lu\n", msh.colorsimportant);
     132        printf(B_TRANSLATE("\nMS Info Header:\n"));
     133        printf(B_TRANSLATE("     header size: 0x%.8lx (%lu) (should be: "
     134            "40)\n"), msh.size, msh.size);
     135        printf(B_TRANSLATE("           width: %lu\n"), msh.width);
     136        printf(B_TRANSLATE("          height: %lu\n"), msh.height);
     137        printf(B_TRANSLATE("          planes: %u (should be: 1)\n"),
     138            msh.planes);
     139        printf(B_TRANSLATE("  bits per pixel: %u (should be: 1,4,8,16,24 or "
     140            "32)\n"), msh.bitsperpixel);
     141        if (msh.compression == BMP_NO_COMPRESS)
     142            printf(B_TRANSLATE("     compression: none (%lu)\n"),
     143                msh.compression);
     144        else if (msh.compression == BMP_RLE8_COMPRESS)
     145            printf(B_TRANSLATE("     compression: RLE8 (%lu)\n"),
     146                msh.compression);
     147        else if (msh.compression == BMP_RLE4_COMPRESS)
     148            printf(B_TRANSLATE("     compression: RLE4 (%lu)\n"),
     149                msh.compression);
     150        else
     151            printf(B_TRANSLATE("     compression: unknown (%lu)\n"),
     152                msh.compression);
     153        printf(B_TRANSLATE("      image size: 0x%.8lx (%lu)\n"), msh.imagesize,
     154            msh.imagesize);
     155        printf(B_TRANSLATE("  x pixels/meter: %lu\n"), msh.xpixperm);
     156        printf(B_TRANSLATE("  y pixels/meter: %lu\n"), msh.ypixperm);
     157        printf(B_TRANSLATE("     colors used: %lu\n"), msh.colorsused);
     158        printf(B_TRANSLATE("colors important: %lu\n"), msh.colorsimportant);
    142159
    143160    } else if (headersize == sizeof(OS2InfoHeader)) {
    144161        // OS/2 format
     
    146163        OS2InfoHeader os2;
    147164        os2.size = headersize;
    148165        if (file.Read(reinterpret_cast<uint8 *> (&os2) + 4, 8) != 8) {
    149             printf("Error: unable to read entire OS/2 info header\n");
     166            printf(B_TRANSLATE("Error: unable to read entire OS/2 info "
     167                "header\n"));
    150168            return;
    151169        }
    152170   
     
    154172        swap_data(B_UINT32_TYPE, reinterpret_cast<uint8 *> (&os2) + 4, 8,
    155173            B_SWAP_LENDIAN_TO_HOST);
    156174           
    157         printf("\nOS/2 Info Header:\n");
    158         printf("   header size: 0x%.8lx (%lu) (should be: 12)\n", os2.size, os2.size);
    159         printf("         width: %u\n", os2.width);
    160         printf("        height: %u\n", os2.height);
    161         printf("        planes: %u (should be: 1)\n", os2.planes);
    162         printf("bits per pixel: %u (should be: 1,4,8 or 24)\n",
     175        printf(B_TRANSLATE("\nOS/2 Info Header:\n"));
     176        printf(B_TRANSLATE("   header size: 0x%.8lx (%lu) (should be: 12)\n"),
     177            os2.size, os2.size);
     178        printf(B_TRANSLATE("         width: %u\n"), os2.width);
     179        printf(B_TRANSLATE("        height: %u\n"), os2.height);
     180        printf(B_TRANSLATE("        planes: %u (should be: 1)\n"), os2.planes);
     181        printf(B_TRANSLATE("bits per pixel: %u (should be: 1,4,8 or 24)\n"),
    163182            os2.bitsperpixel);
    164183
    165184    } else
    166         printf("Error: info header size (%lu) does not match MS or OS/2 "
    167             "info header size\n", headersize);
     185        printf(B_TRANSLATE("Error: info header size (%lu) does not match MS "
     186            "or OS/2 info header size\n"), headersize);
    168187}
    169188
    170189int
     
    173192    printf("\n");
    174193   
    175194    if (argc == 1) {
    176         printf("bmpinfo - reports information about a BMP image file\n");
    177         printf("\nUsage:\n");
    178         printf("bmpinfo filename.bmp\n");   
     195        printf(B_TRANSLATE("bmpinfo - reports information about a BMP image "
     196            "file\n"));
     197        printf(B_TRANSLATE("\nUsage:\n"));
     198        printf(B_TRANSLATE("bmpinfo filename.bmp\n")); 
    179199    }
    180200    else {
    181201        BFile file;
    182202       
    183203        for (int32 i = 1; i < argc; i++) {
    184204            if (file.SetTo(argv[i], B_READ_ONLY) != B_OK)
    185                 printf("\nError opening %s\n", argv[i]);
     205                printf(B_TRANSLATE("\nError opening %s\n"), argv[i]);
    186206            else {
    187                 printf("\nBMP image information for: %s\n", argv[i]);
     207                printf(B_TRANSLATE("\nBMP image information for: %s\n"),
     208                    argv[i]);
    188209                print_bmp_info(file);
    189210            }
    190211        }