Ticket #7136: giftranslator-localization.patch
File giftranslator-localization.patch, 14.1 KB (added by , 14 years ago) |
---|
-
src/add-ons/translators/gif/GIFView.cpp
19 19 #include <stdio.h> 20 20 #include <stdlib.h> 21 21 22 #include <Catalog.h> 22 23 #include <GridLayoutBuilder.h> 23 24 #include <GroupLayout.h> 24 25 #include <GroupLayoutBuilder.h> … … 30 31 31 32 #include "GIFView.h" 32 33 34 #undef B_TRANSLATE_CONTEXT 35 #define B_TRANSLATE_CONTEXT "GIFView" 36 37 33 38 extern int32 translatorVersion; 34 39 extern char translatorName[]; 35 40 … … 43 48 title->SetFont(be_bold_font); 44 49 45 50 char version_string[100]; 46 sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8), (int)((translatorVersion >> 4) & 0xf), 47 (int)(translatorVersion & 0xf), __DATE__); 51 sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8), 52 (int)((translatorVersion >> 4) & 0xf), (int)(translatorVersion & 0xf), 53 __DATE__); 48 54 BStringView *version = new BStringView("Version", version_string); 49 55 50 56 const char *copyrightString = "©2003 Daniel Switkin, software@switkin.com"; 51 57 BStringView *copyright = new BStringView("Copyright", copyrightString); 52 58 53 59 // menu fields (Palette & Colors) 54 fWebSafeMI = new BMenuItem("Websafe", new BMessage(GV_WEB_SAFE), 0, 0); 55 fBeOSSystemMI = new BMenuItem("BeOS system", new BMessage(GV_BEOS_SYSTEM), 0, 0); 56 fGreyScaleMI = new BMenuItem("Greyscale", new BMessage(GV_GREYSCALE), 0, 0); 57 fOptimalMI = new BMenuItem("Optimal", new BMessage(GV_OPTIMAL), 0, 0); 60 fWebSafeMI = new BMenuItem(B_TRANSLATE("Websafe"), 61 new BMessage(GV_WEB_SAFE), 0, 0); 62 fBeOSSystemMI = new BMenuItem(B_TRANSLATE("BeOS system"), 63 new BMessage(GV_BEOS_SYSTEM), 0, 0); 64 fGreyScaleMI = new BMenuItem(B_TRANSLATE("Greyscale"), 65 new BMessage(GV_GREYSCALE), 0, 0); 66 fOptimalMI = new BMenuItem(B_TRANSLATE("Optimal"), 67 new BMessage(GV_OPTIMAL), 0, 0); 58 68 fPaletteM = new BPopUpMenu("PalettePopUpMenu", true, true, B_ITEMS_IN_COLUMN); 59 69 fPaletteM->AddItem(fWebSafeMI); 60 70 fPaletteM->AddItem(fBeOSSystemMI); 61 71 fPaletteM->AddItem(fGreyScaleMI); 62 72 fPaletteM->AddItem(fOptimalMI); 63 73 64 fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true, B_ITEMS_IN_COLUMN); 74 fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true, 75 B_ITEMS_IN_COLUMN); 65 76 int32 count = 2; 66 77 for (int32 i = 0; i < 8; i++) { 67 78 BMessage* message = new BMessage(GV_SET_COLOR_COUNT); … … 74 85 } 75 86 fColorCount256MI = fColorCountMI[7]; 76 87 77 fPaletteMF = new BMenuField( "Palette", fPaletteM, NULL);88 fPaletteMF = new BMenuField(B_TRANSLATE("Palette"), fPaletteM, NULL); 78 89 79 fColorCountMF = new BMenuField( "Colors", fColorCountM, NULL);90 fColorCountMF = new BMenuField(B_TRANSLATE("Colors"), fColorCountM, NULL); 80 91 81 92 // check boxes 82 fUseDitheringCB = new BCheckBox( "Use dithering",93 fUseDitheringCB = new BCheckBox(B_TRANSLATE("Use dithering"), 83 94 new BMessage(GV_USE_DITHERING)); 84 95 85 fInterlacedCB = new BCheckBox( "Write interlaced images",96 fInterlacedCB = new BCheckBox(B_TRANSLATE("Write interlaced images"), 86 97 new BMessage(GV_INTERLACED)); 87 98 88 fUseTransparentCB = new BCheckBox( "Write transparent images",99 fUseTransparentCB = new BCheckBox(B_TRANSLATE("Write transparent images"), 89 100 new BMessage(GV_USE_TRANSPARENT)); 90 101 91 102 // radio buttons 92 fUseTransparentAutoRB = new BRadioButton("Automatic (from alpha channel)", 103 fUseTransparentAutoRB = new BRadioButton( 104 B_TRANSLATE("Automatic (from alpha channel)"), 93 105 new BMessage(GV_USE_TRANSPARENT_AUTO)); 94 106 95 fUseTransparentColorRB = new BRadioButton( "Use RGB color",107 fUseTransparentColorRB = new BRadioButton(B_TRANSLATE("Use RGB color"), 96 108 new BMessage(GV_USE_TRANSPARENT_COLOR)); 97 109 98 110 fTransparentRedTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_RED)); -
src/add-ons/translators/gif/GIFLoad.cpp
40 40 } 41 41 42 42 if (debug) 43 printf("GIFLoad::GIFLoad() - Image dimensions are %d x %d\n", fWidth, fHeight); 43 printf("GIFLoad::GIFLoad() - Image dimensions are %d x %d\n", fWidth, 44 fHeight); 44 45 45 46 unsigned char c; 46 47 if (fInput->Read(&c, 1) < 1) { … … 55 56 fatalerror = true; 56 57 } else { 57 58 if (debug) 58 printf("GIFLoad::GIFLoad() - Found a single image and leaving\n"); 59 printf("GIFLoad::GIFLoad() - Found a single image and " 60 "leaving\n"); 59 61 } 60 62 free(fScanLine); 61 63 fScanLine = NULL; … … 117 119 if (header[10] & GIF_LOCALCOLORMAP) { 118 120 fPalette->size_in_bits = (header[10] & 0x07) + 1; 119 121 if (debug) 120 printf("GIFLoad::ReadGIFHeader() - Found %d bit global palette\n", fPalette->size_in_bits); 122 printf("GIFLoad::ReadGIFHeader() - Found %d bit global palette\n", 123 fPalette->size_in_bits); 121 124 int s = 1 << fPalette->size_in_bits; 122 125 fPalette->size = s; 123 126 … … 131 134 } else { // Install BeOS system palette in case local palette isn't present 132 135 color_map *map = (color_map *)system_colors(); 133 136 for (int x = 0; x < 256; x++) { 134 fPalette->SetColor(x, map->color_list[x].red, map->color_list[x].green,135 map->color_list[x]. blue);137 fPalette->SetColor(x, map->color_list[x].red, 138 map->color_list[x].green, map->color_list[x].blue); 136 139 } 137 140 fPalette->size = 256; 138 141 fPalette->size_in_bits = 8; … … 169 172 fPalette->usetransparent = true; 170 173 fPalette->transparentindex = data[4]; 171 174 if (debug) 172 printf("GIFLoad::ReadGIFControlBlock() - Transparency active, using palette index %d\n", data[4]); 175 printf("GIFLoad::ReadGIFControlBlock() - Transparency active, " 176 "using palette index %d\n", data[4]); 173 177 } 174 178 return true; 175 179 } … … 222 226 int localHeight = data[6] + (data[7] << 8); 223 227 if (fWidth != localWidth || fHeight != localHeight) { 224 228 if (debug) 225 printf("GIFLoad::ReadGIFImageHeader() - Local dimensions do not match global, setting to %d x %d\n",226 localWidth, localHeight);229 printf("GIFLoad::ReadGIFImageHeader() - Local dimensions do not " 230 "match global, setting to %d x %d\n", localWidth, localHeight); 227 231 fWidth = localWidth; 228 232 fHeight = localHeight; 229 233 } 230 234 231 235 fScanLine = (uint32 *)malloc(fWidth * 4); 232 236 if (fScanLine == NULL) { 233 if (debug) printf("GIFLoad::ReadGIFImageHeader() - Could not allocate scanline\n"); 237 if (debug) 238 printf("GIFLoad::ReadGIFImageHeader() - Could not allocate " 239 "scanline\n"); 234 240 return false; 235 241 } 236 242 … … 253 259 int s = 1 << fPalette->size_in_bits; 254 260 fPalette->size = s; 255 261 if (debug) 256 printf("GIFLoad::ReadGIFImageHeader() - Found %d bit local palette\n",257 fPalette->size_in_bits);262 printf("GIFLoad::ReadGIFImageHeader() - Found %d bit local " 263 "palette\n", fPalette->size_in_bits); 258 264 259 265 unsigned char lp[256 * 3]; 260 266 if (fInput->Read(lp, s * 3) < s * 3) … … 269 275 if (fInterlaced) 270 276 printf("GIFLoad::ReadGIFImageHeader() - Image is interlaced\n"); 271 277 else 272 printf("GIFLoad::ReadGIFImageHeader() - Image is not interlaced\n"); 278 printf("GIFLoad::ReadGIFImageHeader() - Image is not " 279 "interlaced\n"); 273 280 } 274 281 return true; 275 282 } … … 287 294 return false; 288 295 } else if (cs > fPalette->size_in_bits) { 289 296 if (debug) 290 printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not %d, allowing it\n", fCodeSize, cs); 297 printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not " 298 "%d, allowing it\n", fCodeSize, cs); 291 299 if (!InitFrame(cs)) 292 300 return false; 293 301 } else if (cs < fPalette->size_in_bits) { 294 302 if (debug) 295 printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not %d\n", fCodeSize, cs); 303 printf("GIFLoad::ReadGIFImageData() - Code_size should be %d, not " 304 "%d\n", fCodeSize, cs); 296 305 return false; 297 306 } 298 307 … … 308 317 if (!OutputColor(fOldCode, 1)) goto bad_end; 309 318 if (fNewCode == -1 || fNewCode == fEndCode) { 310 319 if (debug) 311 printf("GIFLoad::ReadGIFImageData() - Premature fEndCode or error\n"); 320 printf("GIFLoad::ReadGIFImageData() - Premature fEndCode " 321 "or error\n"); 312 322 goto bad_end; 313 323 } 314 324 continue; … … 391 401 if (fByteCount == 0) { 392 402 if (fInput->Read(&fByteCount, 1) < 1) return -1; 393 403 if (fByteCount == 0) return fEndCode; 394 if (fInput->Read(fByteBuffer + (255 - fByteCount), fByteCount) < fByteCount) return -1; 404 if (fInput->Read(fByteBuffer + (255 - fByteCount), 405 fByteCount) < fByteCount) return -1; 395 406 } 396 407 fBitBuffer |= (unsigned int)fByteBuffer[255 - fByteCount] << fBitCount; 397 408 fByteCount--; -
src/add-ons/translators/gif/GIFTranslator.cpp
18 18 #include "GIFView.h" 19 19 #include "GIFSave.h" 20 20 #include "GIFLoad.h" 21 22 21 23 #include <ByteOrder.h> 24 #include <Catalog.h> 25 #include <DataIO.h> 26 #include <InterfaceDefs.h> 22 27 #include <TypeConstants.h> 23 #include <DataIO.h>24 28 #include <TranslatorAddOn.h> 25 29 #include <TranslatorFormats.h> 26 #include <InterfaceDefs.h> 30 27 31 #include <stdio.h> 28 32 #include <stdlib.h> 29 33 #include <string.h> … … 32 36 #define GIF_TYPE 'GIF ' 33 37 #endif 34 38 39 #undef B_TRANSLATE_CONTEXT 40 #define B_TRANSLATE_CONTEXT "GIFTranslator" 41 42 35 43 // This global will be externed in other files - set once here 36 44 // for the entire translator 37 45 bool debug = false; … … 45 53 int32 translatorVersion = 0x140; 46 54 47 55 translation_format inputFormats[] = { 48 { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", "GIF image" }, 49 { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" }, 56 { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", 57 "GIF image" }, 58 { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", 59 "Be Bitmap Format (GIFTranslator)" }, 50 60 { 0 } 51 61 }; 52 62 53 63 translation_format outputFormats[] = { 54 { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", "GIF image" }, 55 { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", "Be Bitmap Format (GIFTranslator)" }, 64 { GIF_TYPE, B_TRANSLATOR_BITMAP, 0.8, 0.8, "image/gif", 65 "GIF image" }, 66 { B_TRANSLATOR_BITMAP, B_TRANSLATOR_BITMAP, 0.3, 0.3, "image/x-be-bitmap", 67 "Be Bitmap Format (GIFTranslator)" }, 56 68 { 0 } 57 69 }; 58 70 … … 79 91 if (source->Read(header, 6) != 6) return false; 80 92 header[6] = 0x00; 81 93 82 if (strcmp((char *)header, "GIF87a") != 0 && strcmp((char *)header, "GIF89a") != 0) { 94 if (strcmp((char *)header, "GIF87a") != 0 && strcmp((char *)header, 95 "GIF89a") != 0) { 83 96 *is_gif = false; 84 int32 magic = (header[0] << 24) + (header[1] << 16) + (header[2] << 8) + header[3]; 97 int32 magic = (header[0] << 24) + (header[1] << 16) + (header[2] << 8) 98 + header[3]; 85 99 if (magic != B_TRANSLATOR_BITMAP) return false; 86 100 source->Seek(5 * 4 - 2, SEEK_CUR); 87 101 color_space cs; 88 102 if (source->Read(&cs, 4) != 4) return false; 89 103 cs = (color_space)B_BENDIAN_TO_HOST_INT32(cs); 90 if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs != B_RGBA32_BIG) return false; 104 if (cs != B_RGB32 && cs != B_RGBA32 && cs != B_RGB32_BIG && cs 105 != B_RGBA32_BIG) return false; 91 106 } 92 107 93 108 source->Seek(0, SEEK_SET); … … 141 156 if ((debug_text != NULL) && (atoi(debug_text) != 0)) debug = true; 142 157 143 158 if (outType == 0) outType = B_TRANSLATOR_BITMAP; 144 if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) return B_NO_TRANSLATOR; 159 if (outType != GIF_TYPE && outType != B_TRANSLATOR_BITMAP) 160 return B_NO_TRANSLATOR; 145 161 146 162 bool is_gif; 147 163 if (!DetermineType(inSource, &is_gif)) return B_NO_TRANSLATOR; … … 153 169 outInfo->type = GIF_TYPE; 154 170 outInfo->quality = 0.8; 155 171 outInfo->capability = 0.8; 156 strcpy(outInfo->name, "GIF image");172 strcpy(outInfo->name, B_TRANSLATE("GIF image")); 157 173 strcpy(outInfo->MIME, "image/gif"); 158 174 } 159 175 else { 160 176 outInfo->type = B_TRANSLATOR_BITMAP; 161 177 outInfo->quality = 0.3; 162 178 outInfo->capability = 0.3; 163 strcpy(outInfo->name, "Be Bitmap Format (GIFTranslator)");179 strcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (GIFTranslator)")); 164 180 strcpy(outInfo->MIME, "image/x-be-bitmap"); 165 181 } 166 182 return B_OK; … … 213 229 214 230 if (debug) { 215 231 now = system_time() - now; 216 printf("Translate() - Translation took %Ld microseconds\n", now); 232 printf( 233 B_TRANSLATE("Translate() - Translation took %Ld microseconds\n"), 234 now); 217 235 } 218 236 return B_OK; 219 237 } … … 223 241 : BApplication("application/x-vnd.Haiku-GIFTranslator") 224 242 { 225 243 BRect rect(100, 100, 339, 339); 226 gifwindow = new GIFWindow(rect, "GIF Settings");244 gifwindow = new GIFWindow(rect, B_TRANSLATE("GIF Settings")); 227 245 gifwindow->Show(); 228 246 } 229 247 -
src/add-ons/translators/gif/GIFSave.cpp
101 101 if (prefs->usetransparentauto) { 102 102 palette->PrepareForAutoTransparency(); 103 103 if (debug) 104 printf("GIFSave::GIFSave() - Using transparent index %d\n", palette->TransparentIndex()); 104 printf("GIFSave::GIFSave() - Using transparent index %d\n", 105 palette->TransparentIndex()); 105 106 } else { 106 107 palette->SetTransparentColor((uint8)prefs->transparentred, 107 108 (uint8)prefs->transparentgreen, 108 109 (uint8)prefs->transparentblue); 109 110 if (debug) { 110 printf("GIFSave::GIFSave() - Found transparent color %d,%d,%d at index %d\n", 111 prefs->transparentred, prefs->transparentgreen, prefs->transparentblue, 112 palette->TransparentIndex()); 111 printf("GIFSave::GIFSave() - Found transparent color %d,%d,%d " 112 "at index %d\n", prefs->transparentred, 113 prefs->transparentgreen, prefs->transparentblue, 114 palette->TransparentIndex()); 113 115 } 114 116 } 115 117 } else { -
src/add-ons/translators/gif/Jamfile
20 20 : true 21 21 ; 22 22 23 DoCatalogs GIFTranslator : 24 x-vnd.Haiku-GIFTranslator 25 : 26 GIFTranslator.cpp 27 GIFView.cpp 28 ; 29 30 23 31 Package haiku-translationkit-cvs : 24 32 GIFTranslator : 25 33 boot home config add-ons Translators ;