Ticket #7168: tgainfo-localization.patch
File tgainfo-localization.patch, 14.2 KB (added by , 13 years ago) |
---|
-
src/tools/translation/tgainfo/tgainfo.rdef
1 /* 2 * tgainfo.rdef 3 */ 4 5 resource app_signature "application/x-vnd.Haiku-tgainfo"; 6 7 resource 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 17 resource app_flags B_SINGLE_LAUNCH; -
src/tools/translation/tgainfo/Jamfile
1 1 SubDir HAIKU_TOP src tools translation tgainfo ; 2 2 3 BinCommand tgainfo : tgainfo.cpp : be ;3 SetSubDirSupportedPlatformsBeOSCompatible ; 4 4 5 BinCommand tgainfo : 6 tgainfo.cpp 7 : be libbe.so $(HAIKU_LOCALE_LIBS) translation $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; 8 9 AddResources tgainfo : tgainfo.rdef ; 10 11 DoCatalogs tgainfo : 12 x-vnd.Haiku-tgainfo 13 : 14 tgainfo.cpp 15 ; -
src/tools/translation/tgainfo/tgainfo.cpp
36 36 #include <stdlib.h> 37 37 #include <string.h> 38 38 #include <ByteOrder.h> 39 #include <Catalog.h> 39 40 #include <File.h> 40 41 #include <TranslatorFormats.h> 41 42 #include <StorageDefs.h> 42 43 44 #undef B_TRANSLATE_CONTEXT 45 #define B_TRANSLATE_CONTEXT "tgainfo" 46 43 47 #define max(x,y) ((x > y) ? x : y) 44 48 #define DATA_BUFFER_SIZE 64 45 49 … … 99 103 colormaptype(uint8 n) 100 104 { 101 105 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"); 104 108 } 105 109 return "unknown"; 106 110 } … … 109 113 imagetype(uint8 n) 110 114 { 111 115 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; 119 124 } 120 return "unknown";125 return B_TRANSLATE("unknown"); 121 126 } 122 127 123 128 uint16 … … 140 145 // read in TGA headers 141 146 ssize_t size = TGA_HEADERS_SIZE; 142 147 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")); 144 149 return; 145 150 } 146 151 … … 150 155 fh.colormaptype = buf[1]; 151 156 fh.imagetype = buf[2]; 152 157 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)); 155 160 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))); 159 167 160 168 161 169 // TGA color map spec … … 164 172 mapspec.length = tga_uint16(reinterpret_cast<char *>(buf), 5); 165 173 mapspec.entrysize = buf[7]; 166 174 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)); 171 182 172 183 173 184 // TGA image spec … … 179 190 imagespec.depth = buf[16]; 180 191 imagespec.descriptor = buf[17]; 181 192 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)); 196 234 197 235 198 236 // Optional TGA Footer … … 208 246 extoffset = tga_uint32(tgafooter, 0); 209 247 devoffset = tga_uint32(tgafooter, 4); 210 248 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); 215 257 216 258 if (extoffset) { 217 259 char extbuf[TGA_EXT_LEN]; 218 260 if (file.ReadAt(extoffset, extbuf, TGA_EXT_LEN) == TGA_EXT_LEN) { 219 261 220 printf( "\nExtension Area:\n");262 printf(B_TRANSLATE("\nExtension Area:\n")); 221 263 222 264 char strbuffer[LINE_LEN]; 223 265 224 266 uint16 extsize = tga_uint16(extbuf, 0); 225 267 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); 227 270 return; 228 271 } 229 printf( "size: %d\n", extsize);272 printf(B_TRANSLATE("size: %d\n"), extsize); 230 273 231 274 memset(strbuffer, 0, LINE_LEN); 232 275 strncpy(strbuffer, extbuf + 2, 41); 233 276 printf("author: \"%s\"\n", strbuffer); 234 277 235 printf( "comments:\n");278 printf(B_TRANSLATE("comments:\n")); 236 279 for (int32 i = 0; i < 4; i++) { 237 280 memset(strbuffer, 0, LINE_LEN); 238 281 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)); 240 285 } 241 286 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"), 243 289 tga_uint16(extbuf, 367), tga_uint16(extbuf, 369), 244 290 tga_uint16(extbuf, 371), tga_uint16(extbuf, 373), 245 291 tga_uint16(extbuf, 375), tga_uint16(extbuf, 377)); 246 292 247 293 memset(strbuffer, 0, LINE_LEN); 248 294 strncpy(strbuffer, extbuf + 379, 41); 249 printf( "job name: \"%s\"\n", strbuffer);295 printf(B_TRANSLATE("job name: \"%s\"\n"), strbuffer); 250 296 251 printf( "job time (hh:mm:ss): %.2d:%.2d:%.2d\n",252 tga_uint16(extbuf, 420), tga_uint16(extbuf, 422),253 tga_uint16(extbuf, 42 4));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)); 254 300 255 301 memset(strbuffer, 0, LINE_LEN); 256 302 strncpy(strbuffer, extbuf + 426, 41); 257 printf("software id: \"%s\"\n", strbuffer); 303 printf(B_TRANSLATE("software id: \"%s\"\n"), 304 strbuffer); 258 305 259 306 char strver[] = "[null]"; 260 307 if (extbuf[469] != '\0') { 261 308 strver[0] = extbuf[469]; 262 309 strver[1] = '\0'; 263 310 } 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); 266 313 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]); 269 317 270 printf( "pixel aspect ratio: %d / %d\n",318 printf(B_TRANSLATE("pixel aspect ratio: %d / %d\n"), 271 319 tga_uint16(extbuf, 474), tga_uint16(extbuf, 476)); 272 320 273 printf( "gamma value: %d / %d\n",321 printf(B_TRANSLATE("gamma value: %d / %d\n"), 274 322 tga_uint16(extbuf, 478), tga_uint16(extbuf, 480)); 275 323 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)); 282 333 283 334 const char *strattrtype = NULL; 284 335 uint8 attrtype = extbuf[494]; 285 336 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; 291 347 default: 292 348 if (attrtype > 4 && attrtype < 128) 293 strattrtype = "reserved";349 strattrtype = B_TRANSLATE("reserved"); 294 350 else 295 strattrtype = "unassigned";351 strattrtype = B_TRANSLATE("unassigned"); 296 352 break; 297 353 } 298 printf("attributes type: %d (%s)\n", attrtype, strattrtype); 354 printf(B_TRANSLATE("attributes type: %d (%s)\n"), 355 attrtype, strattrtype); 299 356 300 357 } else 301 printf("\nError: Unable to read entire extension area\n"); 358 printf(B_TRANSLATE("\nError: Unable to read entire " 359 "extension area\n")); 302 360 } 303 361 304 362 } else 305 printf( "\nTGA footer not found\n");363 printf(B_TRANSLATE("\nTGA footer not found\n")); 306 364 307 365 } else 308 printf("\nError: Unable to read TGA footer section\n"); 366 printf(B_TRANSLATE("\nError: Unable to read TGA footer " 367 "section\n")); 309 368 310 369 } else 311 printf( "\nError: Unable to get file size\n");370 printf(B_TRANSLATE("\nError: Unable to get file size\n")); 312 371 } 313 372 314 373 int … … 317 376 printf("\n"); 318 377 319 378 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")); 323 382 } 324 383 else { 325 384 BFile file; 326 385 327 386 for (int32 i = 1; i < argc; i++) { 328 387 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]); 330 389 else { 331 printf( "\nTGA image information for: %s\n", argv[i]);390 printf(B_TRANSLATE("\nTGA image information for: %s\n"), argv[i]); 332 391 print_tga_info(file); 333 392 } 334 393 }