Ticket #7163: pnginfo-localization.patch
File pnginfo-localization.patch, 7.0 KB (added by , 13 years ago) |
---|
-
src/tools/translation/pnginfo/pnginfo.rdef
1 /* 2 * pnginfo.rdef 3 */ 4 5 resource app_signature "application/x-vnd.Haiku-pnginfo"; 6 7 resource 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 17 resource app_flags B_SINGLE_LAUNCH; -
src/tools/translation/pnginfo/pnginfo.cpp
36 36 #include <string.h> 37 37 #include <png.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 "pnginfo" 46 43 47 /* The png_jmpbuf() macro, used in error handling, became available in 44 48 * libpng version 1.0.6. If you want to be able to run your code with older 45 49 * versions of libpng, you must define the macro yourself (but only if it … … 88 92 BFile *pfile; 89 93 pfile = new BFile(path, B_READ_ONLY); 90 94 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")); 92 96 return; 93 97 } 94 98 BPositionIO *pio = static_cast<BPositionIO *>(pfile); … … 96 100 const int32 kSigSize = 8; 97 101 uint8 buf[kSigSize]; 98 102 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")); 100 104 return; 101 105 } 102 106 if (!png_check_sig(buf, kSigSize)) { 103 107 // 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")); 105 109 return; 106 110 } 107 111 … … 122 126 // When an error occurs in libpng, it uses 123 127 // the longjmp function to continue execution 124 128 // from this point 125 printf( "Error: error in libpng function\n");129 printf(B_TRANSLATE("Error: error in libpng function\n")); 126 130 break; 127 131 } 128 132 … … 138 142 png_get_IHDR(ppng, pinfo, &width, &height, &bit_depth, &color_type, 139 143 &interlace_type, &compression_type, &filter_type); 140 144 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); 148 153 const char *desc = NULL; 149 154 switch (color_type) { 150 155 case PNG_COLOR_TYPE_GRAY: 151 desc = "Grayscale";156 desc = B_TRANSLATE(" color type: Grayscale"); 152 157 break; 153 158 case PNG_COLOR_TYPE_PALETTE: 154 desc = "Palette";159 desc = B_TRANSLATE(" color type: Palette"); 155 160 break; 156 161 case PNG_COLOR_TYPE_RGB: 157 desc = "RGB";162 desc = B_TRANSLATE(" color type: RGB"); 158 163 break; 159 164 case PNG_COLOR_TYPE_RGB_ALPHA: 160 desc = "RGB + Alpha";165 desc = B_TRANSLATE(" color type: RGB + Alpha"); 161 166 break; 162 167 case PNG_COLOR_TYPE_GRAY_ALPHA: 163 desc = "Grayscale + Alpha"; 168 desc = B_TRANSLATE(" color type: Grayscale + " 169 "Alpha"); 164 170 break; 165 171 default: 166 desc = "Unknown";172 desc = B_TRANSLATE(" color type: Unknown"); 167 173 break; 168 174 } 169 175 printf("%s (%d)\n", desc, color_type); 170 176 171 printf(" interlacing: ");172 177 switch (interlace_type) { 173 178 case PNG_INTERLACE_NONE: 174 desc = "None";179 desc = B_TRANSLATE(" interlacing: None"); 175 180 break; 176 181 case PNG_INTERLACE_ADAM7: 177 desc = "Adam7";182 desc = B_TRANSLATE(" interlacing: Adam7"); 178 183 break; 179 184 default: 180 desc = "Unknown";185 desc = B_TRANSLATE(" interlacing: Unknown"); 181 186 break; 182 187 } 183 188 printf("%s (%d)\n", desc, interlace_type); 184 189 185 printf(" compression type: ");186 190 switch (compression_type) { 187 191 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"); 189 194 break; 190 195 default: 191 desc = "Unknown";196 desc = B_TRANSLATE(" compression type: Unknown"); 192 197 break; 193 198 } 194 199 printf("%s (%d)\n", desc, compression_type); 195 200 196 printf(" filter type: ");197 201 switch (filter_type) { 198 202 case PNG_FILTER_TYPE_DEFAULT: 199 desc = "Single row per-byte"; 203 desc = B_TRANSLATE(" filter type: Single row " 204 "per-byte"); 200 205 break; 201 206 case PNG_INTRAPIXEL_DIFFERENCING: 202 desc = "Intrapixel Differencing [for MNG files]"; 207 desc = B_TRANSLATE(" filter type: Intrapixel " 208 "Differencing [for MNG files]"); 203 209 break; 204 210 default: 205 desc = "Unknown";211 desc = B_TRANSLATE(" filter type: Unknown"); 206 212 break; 207 213 } 208 214 printf("%s (%d)\n", desc, filter_type); 209 215 } 216 #ifndef png_infopp_NULL 217 #define png_infopp_NULL NULL 218 #endif 210 219 if (ppng) { 211 220 // free PNG handle / info structures 212 221 if (!pinfo) … … 223 232 main(int argc, char **argv) 224 233 { 225 234 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")); 229 238 } 230 239 else { 231 240 int32 first = 1; -
src/tools/translation/pnginfo/Jamfile
3 3 UseLibraryHeaders zlib ; 4 4 UseLibraryHeaders png ; 5 5 6 BinCommand pnginfo : pnginfo.cpp : be lib png.a libz.a$(TARGET_LIBSUPC++) ;6 BinCommand pnginfo : pnginfo.cpp : be libbe.so $(HAIKU_LOCALE_LIBS) translation libpng.a libz.a $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; 7 7 8 AddResources pnginfo : pnginfo.rdef ; 9 10 DoCatalogs pnginfo : 11 x-vnd.Haiku-pnginfo 12 : 13 pnginfo.cpp 14 ; 15