Ticket #7168: tgainfo-localization.patch

File tgainfo-localization.patch, 14.2 KB (added by Karvjorm, 13 years ago)

A tgainfo localization patch

  • src/tools/translation/tgainfo/tgainfo.rdef

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

     
    11SubDir HAIKU_TOP src tools translation tgainfo ;
    22
    3 BinCommand tgainfo : tgainfo.cpp : be ;
     3SetSubDirSupportedPlatformsBeOSCompatible ;
    44
     5BinCommand tgainfo :
     6    tgainfo.cpp
     7    : be libbe.so $(HAIKU_LOCALE_LIBS) translation $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ;
     8
     9AddResources tgainfo : tgainfo.rdef ;
     10
     11DoCatalogs tgainfo :
     12    x-vnd.Haiku-tgainfo
     13    :
     14    tgainfo.cpp
     15;
  • src/tools/translation/tgainfo/tgainfo.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 "tgainfo"
     46
    4347#define max(x,y) ((x > y) ? x : y)
    4448#define DATA_BUFFER_SIZE 64
    4549
     
    99103colormaptype(uint8 n)
    100104{
    101105    switch (n) {
    102         case 0: return "No colormap";
    103         case 1: return "colormap";
     106        case 0: return B_TRANSLATE("No colormap");
     107        case 1: return B_TRANSLATE("colormap");
    104108    }
    105109    return "unknown";
    106110}
     
    109113imagetype(uint8 n)
    110114{
    111115    switch (n) {
    112         case 0:  return "No Image Data";
    113         case 1:  return "colormap";
    114         case 2:  return "true color";
    115         case 3:  return "grayscale";
    116         case 9:  return "RLE colormap";
    117         case 10: return "RLE true color";
    118         case 11: return "RLE grayscale";
     116        case 0:  return B_TRANSLATE("No Image Data");
     117        case 1:  return B_TRANSLATE("colormap");
     118        case 2:  return B_TRANSLATE("true color");
     119        case 3:  return B_TRANSLATE("grayscale");
     120        case 9:  return B_TRANSLATE("RLE colormap");
     121        case 10: return B_TRANSLATE("RLE true color");
     122        case 11: return B_TRANSLATE("RLE grayscale");
     123        default: break;
    119124    }
    120     return "unknown";
     125    return B_TRANSLATE("unknown");
    121126}
    122127
    123128uint16
     
    140145    // read in TGA headers
    141146    ssize_t size = TGA_HEADERS_SIZE;
    142147    if (size > 0 && file.Read(buf, size) != size) {
    143         printf("Error: unable to read all TGA headers\n");
     148        printf(B_TRANSLATE("Error: unable to read all TGA headers\n"));
    144149        return;
    145150    }
    146151   
     
    150155    fh.colormaptype = buf[1];
    151156    fh.imagetype = buf[2];
    152157   
    153     printf("\nFile Header:\n");
    154     printf("    id length: %d\n", fh.idlength);
     158    printf(B_TRANSLATE("\nFile Header:\n"));
     159    printf(B_TRANSLATE("    id length: %d\n"), static_cast<int>(fh.idlength));
    155160   
    156     printf("colormap type: %d (%s)\n", fh.colormaptype,
    157         colormaptype(fh.colormaptype));
    158     printf("   image type: %d (%s)\n", fh.imagetype, imagetype(fh.imagetype));
     161    printf(B_TRANSLATE("colormap type: %d (%s)\n"),
     162        static_cast<int>(fh.colormaptype),
     163        static_cast<const char *>(colormaptype(fh.colormaptype)));
     164    printf(B_TRANSLATE("   image type: %d (%s)\n"),
     165        static_cast<int>(fh.imagetype),
     166        static_cast<const char *>(imagetype(fh.imagetype)));
    159167   
    160168   
    161169    // TGA color map spec
     
    164172    mapspec.length = tga_uint16(reinterpret_cast<char *>(buf), 5);
    165173    mapspec.entrysize = buf[7];
    166174   
    167     printf("\nColormap Spec:\n");
    168     printf("first entry: %d\n", mapspec.firstentry);
    169     printf("     length: %d\n", mapspec.length);
    170     printf(" entry size: %d\n", mapspec.entrysize);
     175    printf(B_TRANSLATE("\nColormap Spec:\n"));
     176    printf(B_TRANSLATE("first entry: %d\n"),
     177        static_cast<int>(mapspec.firstentry));
     178    printf(B_TRANSLATE("     length: %d\n"),
     179        static_cast<int>(mapspec.length));
     180    printf(B_TRANSLATE(" entry size: %d\n"),
     181        static_cast<int>(mapspec.entrysize));
    171182   
    172183   
    173184    // TGA image spec
     
    179190    imagespec.depth = buf[16];
    180191    imagespec.descriptor = buf[17];
    181192   
    182     printf("\nImage Spec:\n");
    183     printf("  x origin: %d\n", imagespec.xorigin);
    184     printf("  y origin: %d\n", imagespec.yorigin);
    185     printf("     width: %d\n", imagespec.width);
    186     printf("    height: %d\n", imagespec.height);
    187     printf("     depth: %d\n", imagespec.depth);
    188     printf("descriptor: 0x%.2x\n", imagespec.descriptor);
    189         printf("\talpha (attr): %d\n",
    190             imagespec.descriptor & TGA_DESC_ALPHABITS);
    191         printf("\t      origin: %d (%s %s)\n",
    192             imagespec.descriptor & (TGA_ORIGIN_VERT_BIT | TGA_ORIGIN_HORZ_BIT),
    193             ((imagespec.descriptor & TGA_ORIGIN_VERT_BIT) ? "top" : "bottom"),
    194             ((imagespec.descriptor & TGA_ORIGIN_HORZ_BIT) ? "right" : "left"));
    195         printf("\t  bits 7 & 6: %d\n", imagespec.descriptor & TGA_DESC_BITS76);
     193    printf(B_TRANSLATE("\nImage Spec:\n"));
     194    printf(B_TRANSLATE("  x origin: %d\n"),
     195        static_cast<int>(imagespec.xorigin));
     196    printf(B_TRANSLATE("  y origin: %d\n"),
     197        static_cast<int>(imagespec.yorigin));
     198    printf(B_TRANSLATE("     width: %d\n"),
     199        static_cast<int>(imagespec.width));
     200    printf(B_TRANSLATE("    height: %d\n"),
     201        static_cast<int>(imagespec.height));
     202    printf(B_TRANSLATE("     depth: %d\n"),
     203        static_cast<int>(imagespec.depth));
     204    printf(B_TRANSLATE("descriptor: 0x%.2x\n"),
     205        static_cast<int>(imagespec.descriptor));
     206    printf(B_TRANSLATE("\talpha (attr): %d\n"),
     207        static_cast<int>(imagespec.descriptor & TGA_DESC_ALPHABITS));
     208    if (imagespec.descriptor & TGA_ORIGIN_VERT_BIT)
     209        if (imagespec.descriptor & TGA_ORIGIN_HORZ_BIT)
     210            printf(B_TRANSLATE("\t      origin: %d (%s %s)\n"),
     211                static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
     212                | TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("top"),
     213                static_cast<const char *>("right"));
     214        else
     215            printf(B_TRANSLATE("\t      origin: %d (%s %s)\n"),
     216            static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
     217                | TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("top"),
     218                static_cast<const char *>("left"));
     219    else
     220        if (imagespec.descriptor & TGA_ORIGIN_HORZ_BIT)
     221            printf(B_TRANSLATE("\t      origin: %d (%s %s)\n"),
     222                static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
     223                | TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("bottom"),
     224                static_cast<const char *>("right"));
     225        else
     226            printf(B_TRANSLATE("\t      origin: %d (%s %s)\n"),
     227            static_cast<int>(imagespec.descriptor & (TGA_ORIGIN_VERT_BIT
     228                | TGA_ORIGIN_HORZ_BIT)), static_cast<const char *>("bottom"),
     229                static_cast<const char *>("left"));
     230           
     231           
     232    printf(B_TRANSLATE("\t  bits 7 & 6: %d\n"),
     233        static_cast<int>(imagespec.descriptor & TGA_DESC_BITS76));
    196234       
    197235       
    198236    // Optional TGA Footer
     
    208246                extoffset = tga_uint32(tgafooter, 0);
    209247                devoffset = tga_uint32(tgafooter, 4);
    210248           
    211                 printf("\nTGA Footer:\n");
    212                 printf("extension offset: 0x%.8lx (%ld)\n", extoffset, extoffset);
    213                 printf("developer offset: 0x%.8lx (%ld)\n", devoffset, devoffset);
    214                 printf("signature: %s\n", tgafooter + 8);
     249                printf(B_TRANSLATE("\nTGA Footer:\n"));
     250                printf(B_TRANSLATE("extension offset: 0x%.8lx (%ld)\n"),
     251                    static_cast<long int>(extoffset),
     252                    static_cast<long int>(extoffset));
     253                printf(B_TRANSLATE("developer offset: 0x%.8lx (%ld)\n"),
     254                    static_cast<long int>(devoffset),
     255                    static_cast<long int>(devoffset));
     256                printf(B_TRANSLATE("signature: %s\n"), tgafooter + 8);
    215257               
    216258                if (extoffset) {
    217259                    char extbuf[TGA_EXT_LEN];
    218260                    if (file.ReadAt(extoffset, extbuf, TGA_EXT_LEN) == TGA_EXT_LEN) {
    219261                   
    220                         printf("\nExtension Area:\n");
     262                        printf(B_TRANSLATE("\nExtension Area:\n"));
    221263                       
    222264                        char strbuffer[LINE_LEN];
    223265                       
    224266                        uint16 extsize = tga_uint16(extbuf, 0);
    225267                        if (extsize < TGA_EXT_LEN) {
    226                             printf("\nError: extension area is too small (%d)\n", extsize);
     268                            printf(B_TRANSLATE("\nError: extension "
     269                                "area is too small (%d)\n"), extsize);
    227270                            return;
    228271                        }
    229                         printf("size: %d\n", extsize);
     272                        printf(B_TRANSLATE("size: %d\n"), extsize);
    230273                       
    231274                        memset(strbuffer, 0, LINE_LEN);
    232275                        strncpy(strbuffer, extbuf + 2, 41);
    233276                        printf("author: \"%s\"\n", strbuffer);
    234277                       
    235                         printf("comments:\n");
     278                        printf(B_TRANSLATE("comments:\n"));
    236279                        for (int32 i = 0; i < 4; i++) {
    237280                            memset(strbuffer, 0, LINE_LEN);
    238281                            strcpy(strbuffer, extbuf + 43 + (i * 81));
    239                             printf("\tline %ld: \"%s\"\n", i + 1, strbuffer);
     282                            printf(B_TRANSLATE("\tline %ld: \"%s\"\n"),
     283                                static_cast<long int>(i + 1),
     284                                static_cast<const char *>(strbuffer));
    240285                        }
    241286
    242                         printf("date/time (yyyy-mm-dd hh:mm:ss): %.4d-%.2d-%.2d %.2d:%.2d:%.2d\n",
     287                        printf(B_TRANSLATE("date/time (yyyy-mm-dd hh:mm:ss): "
     288                            "%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n"),
    243289                            tga_uint16(extbuf, 367), tga_uint16(extbuf, 369),
    244290                            tga_uint16(extbuf, 371), tga_uint16(extbuf, 373),
    245291                            tga_uint16(extbuf, 375), tga_uint16(extbuf, 377));
    246292                           
    247293                        memset(strbuffer, 0, LINE_LEN);
    248294                        strncpy(strbuffer, extbuf + 379, 41);
    249                         printf("job name: \"%s\"\n", strbuffer);
     295                        printf(B_TRANSLATE("job name: \"%s\"\n"), strbuffer);
    250296
    251                         printf("job time (hh:mm:ss): %.2d:%.2d:%.2d\n",
    252                             tga_uint16(extbuf, 420), tga_uint16(extbuf, 422),
    253                             tga_uint16(extbuf, 424));
     297                        printf(B_TRANSLATE("job time (hh:mm:ss): "
     298                            "%.2d:%.2d:%.2d\n"), tga_uint16(extbuf, 420),
     299                            tga_uint16(extbuf, 422), tga_uint16(extbuf, 424));
    254300                           
    255301                        memset(strbuffer, 0, LINE_LEN);
    256302                        strncpy(strbuffer, extbuf + 426, 41);
    257                         printf("software id: \"%s\"\n", strbuffer);
     303                        printf(B_TRANSLATE("software id: \"%s\"\n"),
     304                            strbuffer);
    258305                       
    259306                        char strver[] = "[null]";
    260307                        if (extbuf[469] != '\0') {
    261308                            strver[0] = extbuf[469];
    262309                            strver[1] = '\0';
    263310                        }
    264                         printf("software version, letter: %d, %s\n",
    265                             tga_uint16(extbuf, 467), strver);
     311                        printf(B_TRANSLATE("software version, letter: %d, "
     312                            "%s\n"), tga_uint16(extbuf, 467), strver);
    266313                       
    267                         printf("key color (A,R,G,B): %d, %d, %d, %d\n",
    268                             extbuf[470], extbuf[471], extbuf[472], extbuf[473]);
     314                        printf(B_TRANSLATE("key color (A,R,G,B): %d, %d, %d, "
     315                            "%d\n"), extbuf[470], extbuf[471], extbuf[472],
     316                            extbuf[473]);
    269317                       
    270                         printf("pixel aspect ratio: %d / %d\n",
     318                        printf(B_TRANSLATE("pixel aspect ratio: %d / %d\n"),
    271319                            tga_uint16(extbuf, 474), tga_uint16(extbuf, 476));
    272320
    273                         printf("gamma value: %d / %d\n",
     321                        printf(B_TRANSLATE("gamma value: %d / %d\n"),
    274322                            tga_uint16(extbuf, 478), tga_uint16(extbuf, 480));
    275323                       
    276                         printf("color correction offset: 0x%.8lx (%ld)\n",
    277                             tga_uint32(extbuf, 482), tga_uint32(extbuf, 482));
    278                         printf("postage stamp offset: 0x%.8lx (%ld)\n",
    279                             tga_uint32(extbuf, 486), tga_uint32(extbuf, 486));
    280                         printf("scan line offset: 0x%.8lx (%ld)\n",
    281                             tga_uint32(extbuf, 490), tga_uint32(extbuf, 490));
     324                        printf(B_TRANSLATE("color correction offset: 0x%.8lx "
     325                            "(%ld)\n"), tga_uint32(extbuf, 482),
     326                            tga_uint32(extbuf, 482));
     327                        printf(B_TRANSLATE("postage stamp offset: 0x%.8lx "
     328                            "(%ld)\n"), tga_uint32(extbuf, 486),
     329                            tga_uint32(extbuf, 486));
     330                        printf(B_TRANSLATE("scan line offset: 0x%.8lx "
     331                            "(%ld)\n"), tga_uint32(extbuf, 490),
     332                            tga_uint32(extbuf, 490));
    282333                       
    283334                        const char *strattrtype = NULL;
    284335                        uint8 attrtype = extbuf[494];
    285336                        switch (attrtype) {
    286                             case 0: strattrtype = "no alpha"; break;
    287                             case 1: strattrtype = "undefined, ignore"; break;
    288                             case 2: strattrtype = "undefined, retain"; break;
    289                             case 3: strattrtype = "alpha"; break;
    290                             case 4: strattrtype = "pre-multiplied alpha"; break;
     337                            case 0: strattrtype
     338                                = B_TRANSLATE("no alpha"); break;
     339                            case 1: strattrtype
     340                                = B_TRANSLATE("undefined, ignore"); break;
     341                            case 2: strattrtype
     342                                = B_TRANSLATE("undefined, retain"); break;
     343                            case 3: strattrtype
     344                                = B_TRANSLATE("alpha"); break;
     345                            case 4: strattrtype
     346                                = B_TRANSLATE("pre-multiplied alpha"); break;
    291347                            default:
    292348                                if (attrtype > 4 && attrtype < 128)
    293                                     strattrtype = "reserved";
     349                                    strattrtype = B_TRANSLATE("reserved");
    294350                                else
    295                                     strattrtype = "unassigned";
     351                                    strattrtype = B_TRANSLATE("unassigned");
    296352                                break;
    297353                        }
    298                         printf("attributes type: %d (%s)\n", attrtype, strattrtype);
     354                        printf(B_TRANSLATE("attributes type: %d (%s)\n"),
     355                            attrtype, strattrtype);
    299356                       
    300357                    } else
    301                         printf("\nError: Unable to read entire extension area\n");
     358                        printf(B_TRANSLATE("\nError: Unable to read entire "
     359                            "extension area\n"));
    302360                }
    303361               
    304362            } else
    305                 printf("\nTGA footer not found\n");
     363                printf(B_TRANSLATE("\nTGA footer not found\n"));
    306364
    307365        } else
    308             printf("\nError: Unable to read TGA footer section\n");
     366            printf(B_TRANSLATE("\nError: Unable to read TGA footer "
     367                "section\n"));
    309368           
    310369    } else
    311         printf("\nError: Unable to get file size\n");
     370        printf(B_TRANSLATE("\nError: Unable to get file size\n"));
    312371}
    313372
    314373int
     
    317376    printf("\n");
    318377   
    319378    if (argc == 1) {
    320         printf("tgainfo - reports information about a TGA image file\n");
    321         printf("\nUsage:\n");
    322         printf("tgainfo filename.tga\n");   
     379        printf(B_TRANSLATE("tgainfo - reports information about a TGA image file\n"));
     380        printf(B_TRANSLATE("\nUsage:\n"));
     381        printf(B_TRANSLATE("tgainfo filename.tga\n")); 
    323382    }
    324383    else {
    325384        BFile file;
    326385       
    327386        for (int32 i = 1; i < argc; i++) {
    328387            if (file.SetTo(argv[i], B_READ_ONLY) != B_OK)
    329                 printf("\nError opening %s\n", argv[i]);
     388                printf(B_TRANSLATE("\nError opening %s\n"), argv[i]);
    330389            else {
    331                 printf("\nTGA image information for: %s\n", argv[i]);
     390                printf(B_TRANSLATE("\nTGA image information for: %s\n"), argv[i]);
    332391                print_tga_info(file);
    333392            }
    334393        }