Ticket #7135: ppmtranslator-localization.patch
File ppmtranslator-localization.patch, 13.1 KB (added by , 13 years ago) |
---|
-
src/add-ons/translators/ppm/PPMMain.cpp
3 3 This file may be used under the terms of the Be Sample Code License. 4 4 */ 5 5 6 #include <Alert.h> 7 #include <Application.h> 8 #include <Catalog.h> 9 #include <GroupLayout.h> 10 #include <Screen.h> 6 11 #include <TranslatorAddOn.h> 7 12 #include <View.h> 8 13 #include <Window.h> 9 #include <Application.h>10 #include <Alert.h>11 #include <Screen.h>12 #include <GroupLayout.h>13 14 15 14 16 #include <stdio.h> 15 17 18 #undef B_TRANSLATE_CONTEXT 19 #define B_TRANSLATE_CONTEXT "PPMMain" 16 20 21 17 22 BPoint get_window_origin(); 18 23 void set_window_origin(BPoint pt); 19 24 … … 22 27 { 23 28 public: 24 29 PPMWindow(BRect area) : 25 BWindow(area, "PPM Settings", B_TITLED_WINDOW,30 BWindow(area, B_TRANSLATE("PPM Settings"), B_TITLED_WINDOW, 26 31 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) 27 32 { 28 33 SetLayout(new BGroupLayout(B_HORIZONTAL)); … … 43 48 BView * v = NULL; 44 49 BRect r(0, 0, 1, 1); 45 50 if (MakeConfig(NULL, &v, &r)) { 46 BAlert * err = new BAlert("Error", "Something is wrong with the PPMTranslator!", "OK"); 51 BAlert * err = new BAlert("Error", 52 B_TRANSLATE("Something is wrong with the PPMTranslator!"), 53 B_TRANSLATE("OK")); 47 54 err->Go(); 48 55 return 1; 49 56 } -
src/add-ons/translators/ppm/Jamfile
4 4 5 5 Translator PPMTranslator 6 6 : PPMMain.cpp PPMTranslator.cpp colorspace.cpp 7 : be translation $(TARGET_LIBSUPC++) 7 : be translation $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) 8 8 : true 9 9 ; 10 10 11 DoCatalogs PPMTranslator : 12 x-vnd.Haiku-PPMTranslator 13 : 14 PPMMain.cpp 15 PPMTranslator.cpp 16 ; 17 11 18 Package haiku-translationkit-cvs : 12 19 PPMTranslator : 13 20 boot home config add-ons Translators ; -
src/add-ons/translators/ppm/PPMTranslator.cpp
8 8 /* does not buffer data. We should wrap a buffering thing around */ 9 9 /* the input or output when they are in ASCII mode. */ 10 10 11 #include <TranslatorAddOn.h> 12 #include <TranslationKit.h> 11 #include <Bitmap.h> 13 12 #include <ByteOrder.h> 14 #include <Message.h> 15 #include <Screen.h> 16 #include <Locker.h> 13 #include <Catalog.h> 14 #include <CheckBox.h> 17 15 #include <FindDirectory.h> 18 #include <Path.h>19 #include <PopUpMenu.h>20 #include <MenuField.h>21 #include <MenuItem.h>22 #include <CheckBox.h>23 #include <Bitmap.h>24 #include <StringView.h>25 16 #include <GridLayoutBuilder.h> 26 17 #include <GroupLayout.h> 27 18 #include <GroupLayoutBuilder.h> 19 #include <Locker.h> 20 #include <MenuField.h> 21 #include <MenuItem.h> 22 #include <Message.h> 23 #include <Path.h> 24 #include <PopUpMenu.h> 25 #include <Screen.h> 28 26 #include <SpaceLayoutItem.h> 27 #include <StringView.h> 28 #include <TranslatorAddOn.h> 29 #include <TranslationKit.h> 29 30 30 31 #include <ctype.h> 31 32 #include <string.h> … … 34 35 35 36 #include "colorspace.h" 36 37 38 #undef B_TRANSLATE_CONTEXT 39 #define B_TRANSLATE_CONTEXT "PPMTranslator" 37 40 38 41 #if DEBUG 39 42 #define dprintf(x) printf x … … 43 46 44 47 45 48 #if !defined(_PR3_COMPATIBLE_) /* R4 headers? Else we need to define these constants. */ 46 #define B_CMY24 ((color_space)0xC001) /* C[7:0] M[7:0] Y[7:0] No gray removal done*/47 #define B_CMY32 ((color_space)0xC002) /* C[7:0] M[7:0] Y[7:0] X[7:0] No gray removal done*/48 #define B_CMYA32 ((color_space)0xE002) /* C[7:0] M[7:0] Y[7:0] A[7:0] No gray removal done*/49 #define B_CMYK32 ((color_space)0xC003) /* C[7:0] M[7:0] Y[7:0] K[7:0] 49 #define B_CMY24 ((color_space)0xC001) /* C[7:0] M[7:0] Y[7:0] No gray removal done */ 50 #define B_CMY32 ((color_space)0xC002) /* C[7:0] M[7:0] Y[7:0] X[7:0] No gray removal done */ 51 #define B_CMYA32 ((color_space)0xE002) /* C[7:0] M[7:0] Y[7:0] A[7:0] No gray removal done */ 52 #define B_CMYK32 ((color_space)0xC003) /* C[7:0] M[7:0] Y[7:0] K[7:0] */ 50 53 #endif 51 54 52 55 #define PPM_TRANSLATOR_VERSION 0x100 … … 59 62 // Minor: next 4 bits 60 63 // Major: highest 24 bits 61 64 62 /* Be reserves all codes with non-lowe case letters in them. */65 /* Be reserves all codes with non-lowercase letters in them. */ 63 66 /* Luckily, there is already a reserved code for PPM. If you */ 64 67 /* make up your own for a new type, use lower-case letters. */ 65 68 #define PPM_TYPE 'PPM ' … … 150 153 continue; 151 154 } 152 155 if (sscanf(ptr, "%31[a-zA-Z_0-9] =", name) != 1) { 153 fprintf(stderr, "unknown PPMTranslator settings line: %s", line); 156 fprintf(stderr, 157 B_TRANSLATE("unknown PPMTranslator settings " 158 "line: %s"), line); 154 159 } 155 160 else { 156 161 if (!strcmp(name, "color_space")) { … … 158 163 ptr++; 159 164 } 160 165 ptr++; 161 if (sscanf(ptr, "%d", (int*)&g_settings.out_space) != 1) { 162 fprintf(stderr, "illegal color space in PPMTranslator settings: %s", ptr); 166 if (sscanf(ptr, "%d", 167 (int*)&g_settings.out_space) != 1) { 168 fprintf(stderr, 169 B_TRANSLATE("illegal color space in " 170 "PPMTranslator settings: %s"), 171 ptr); 163 172 } 164 173 } 165 174 else if (!strcmp(name, "window_pos")) { … … 167 176 ptr++; 168 177 } 169 178 ptr++; 170 if (sscanf(ptr, "%f,%f", &g_settings.window_pos.x, &g_settings.window_pos.y) != 2) { 171 fprintf(stderr, "illegal window position in PPMTranslator settings: %s", ptr); 179 if (sscanf(ptr, "%f,%f", 180 &g_settings.window_pos.x, 181 &g_settings.window_pos.y) != 2) { 182 fprintf(stderr, 183 B_TRANSLATE("illegal window position " 184 "in PPMTranslator settings: %s"), 185 ptr); 172 186 } 173 187 } 174 188 else if (!strcmp(name, "write_ascii")) { … … 178 192 ptr++; 179 193 int ascii = g_settings.write_ascii; 180 194 if (sscanf(ptr, "%d", &ascii) != 1) { 181 fprintf(stderr, "illegal write_ascii value in PPMTranslator settings: %s", ptr); 195 fprintf(stderr, 196 B_TRANSLATE("illegal write_ascii " 197 "value in PPMTranslator " 198 "settings: %s"), ptr); 182 199 } 183 200 else { 184 201 g_settings.write_ascii = ascii; 185 202 } 186 203 } 187 204 else { 188 fprintf(stderr, "unknown PPMTranslator setting: %s", line); 205 fprintf(stderr, 206 B_TRANSLATE("unknown PPMTranslator " 207 "setting: %s"), line); 189 208 } 190 209 } 191 210 } … … 203 222 path.Append("PPMTranslator_Settings"); 204 223 FILE * f = fopen(path.Path(), "w"); 205 224 if (f) { 206 fprintf(f, "# PPMTranslator settings version %d.%d.%d\n", 225 fprintf(f, B_TRANSLATE("# PPMTranslator settings " 226 "version %d.%d.%d\n"), 207 227 static_cast<int>(translatorVersion >> 8), 208 228 static_cast<int>((translatorVersion >> 4) & 0xf), 209 229 static_cast<int>(translatorVersion & 0xf)); … … 267 287 outInfo->type = PPM_TYPE; 268 288 outInfo->quality = 0.3; /* no alpha, etc */ 269 289 outInfo->capability = 0.8; /* we're pretty good at PPM reading, though */ 270 strcpy(outInfo->name, "PPM image");290 strcpy(outInfo->name, B_TRANSLATE("PPM image")); 271 291 strcpy(outInfo->MIME, "image/x-portable-pixmap"); 272 292 } 273 293 else { 274 294 outInfo->type = B_TRANSLATOR_BITMAP; 275 295 outInfo->quality = 0.4; /* B_TRANSLATOR_BITMAP can do alpha, at least */ 276 296 outInfo->capability = 0.8; /* and we might not know many variations thereof */ 277 strcpy(outInfo->name, "Be Bitmap Format (PPMTranslator)");297 strcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format (PPMTranslator)")); 278 298 strcpy(outInfo->MIME, "image/x-be-bitmap"); /* this is the MIME type of B_TRANSLATOR_BITMAP */ 279 299 } 280 300 return B_OK; … … 442 462 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 443 463 SetLowColor(ViewColor()); 444 464 445 mTitle = new BStringView("title", "PPM Image Translator"); 465 mTitle = new BStringView("title", 466 B_TRANSLATE("PPM Image Translator")); 446 467 mTitle->SetFont(be_bold_font); 447 468 448 469 char detail[100]; 449 470 int ver = static_cast<int>(translatorVersion); 450 sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf), 471 sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), ver >> 8, 472 ((ver >> 4) & 0xf), 451 473 (ver & 0xf), __DATE__); 452 474 mDetail = new BStringView("detail", detail); 453 475 454 476 mBasedOn = new BStringView("basedOn", 455 "Based on PPMTranslator sample code");477 B_TRANSLATE("Based on PPMTranslator sample code")); 456 478 457 479 mCopyright = new BStringView("copyright", 458 "Sample code copyright 1999, Be Incorporated");480 B_TRANSLATE("Sample code copyright 1999, Be Incorporated")); 459 481 460 482 mMenu = new BPopUpMenu("Color Space"); 461 mMenu->AddItem(new BMenuItem("None", CSMessage(B_NO_COLOR_SPACE))); 462 mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits", CSMessage(B_RGB32))); 463 mMenu->AddItem(new BMenuItem("RGBA 8:8:8:8 32 bits", CSMessage(B_RGBA32))); 464 mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits", CSMessage(B_RGB15))); 465 mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits", CSMessage(B_RGBA15))); 466 mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits", CSMessage(B_RGB16))); 467 mMenu->AddItem(new BMenuItem("System palette 8 bits", CSMessage(B_CMAP8))); 483 mMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), 484 CSMessage(B_NO_COLOR_SPACE))); 485 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 8:8:8 32 bits"), 486 CSMessage(B_RGB32))); 487 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 8:8:8:8 32 " 488 "bits"), CSMessage(B_RGBA32))); 489 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:5:5 16 bits"), 490 CSMessage(B_RGB15))); 491 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 5:5:5:1 16 " 492 "bits"), CSMessage(B_RGBA15))); 493 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:6:5 16 bits"), 494 CSMessage(B_RGB16))); 495 mMenu->AddItem(new BMenuItem(B_TRANSLATE("System palette 8 " 496 "bits"), CSMessage(B_CMAP8))); 468 497 mMenu->AddSeparatorItem(); 469 mMenu->AddItem(new BMenuItem("Grayscale 8 bits", CSMessage(B_GRAY8))); 470 mMenu->AddItem(new BMenuItem("Bitmap 1 bit", CSMessage(B_GRAY1))); 471 mMenu->AddItem(new BMenuItem("CMY 8:8:8 32 bits", CSMessage(B_CMY32))); 472 mMenu->AddItem(new BMenuItem("CMYA 8:8:8:8 32 bits", CSMessage(B_CMYA32))); 473 mMenu->AddItem(new BMenuItem("CMYK 8:8:8:8 32 bits", CSMessage(B_CMYK32))); 498 mMenu->AddItem(new BMenuItem(B_TRANSLATE("Grayscale 8 bits"), 499 CSMessage(B_GRAY8))); 500 mMenu->AddItem(new BMenuItem(B_TRANSLATE("Bitmap 1 bit"), 501 CSMessage(B_GRAY1))); 502 mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMY 8:8:8 32 bits"), 503 CSMessage(B_CMY32))); 504 mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMYA 8:8:8:8 32 " 505 "bits"), CSMessage(B_CMYA32))); 506 mMenu->AddItem(new BMenuItem(B_TRANSLATE("CMYK 8:8:8:8 32 " 507 "bits"), CSMessage(B_CMYK32))); 474 508 mMenu->AddSeparatorItem(); 475 mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits big-endian", CSMessage(B_RGB32_BIG))); 476 mMenu->AddItem(new BMenuItem("RGBA 8:8:8:8 32 bits big-endian", CSMessage(B_RGBA32_BIG))); 477 mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits big-endian", CSMessage(B_RGB15_BIG))); 478 mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits big-endian", CSMessage(B_RGBA15_BIG))); 479 mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits big-endian", CSMessage(B_RGB16))); 480 mField = new BMenuField("Input Color Space", mMenu, NULL); 509 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 8:8:8 32 bits " 510 "big-endian"), CSMessage(B_RGB32_BIG))); 511 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 8:8:8:8 32 " 512 "bits big-endian"), CSMessage(B_RGBA32_BIG))); 513 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:5:5 16 bits " 514 "big-endian"), CSMessage(B_RGB15_BIG))); 515 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGBA 5:5:5:1 16 " 516 "bits big-endian"), CSMessage(B_RGBA15_BIG))); 517 mMenu->AddItem(new BMenuItem(B_TRANSLATE("RGB 5:6:5 16 bits " 518 "big-endian"), CSMessage(B_RGB16))); 519 mField = new BMenuField(B_TRANSLATE("Input Color Space"), 520 mMenu, NULL); 481 521 mField->SetViewColor(ViewColor()); 482 522 SelectColorSpace(g_settings.out_space); 483 523 BMessage * msg = new BMessage(CHANGE_ASCII); 484 mAscii = new BCheckBox( "Write ASCII", msg);524 mAscii = new BCheckBox(B_TRANSLATE("Write ASCII"), msg); 485 525 if (g_settings.write_ascii) 486 526 mAscii->SetValue(1); 487 527 mAscii->SetViewColor(ViewColor()); … … 616 656 BView * * outView, 617 657 BRect * outExtent) 618 658 { 619 PPMView * v = new PPMView("PPMTranslator Settings", B_WILL_DRAW); 659 PPMView * v = new PPMView(B_TRANSLATE("PPMTranslator Settings"), 660 B_WILL_DRAW); 620 661 *outView = v; 621 662 v->ResizeTo(v->ExplicitPreferredSize());; 622 663 *outExtent = v->Bounds(); … … 639 680 #if defined(_PR3_COMPATIBLE_) 640 681 const char * name = B_TRANSLATOR_EXT_BITMAP_COLOR_SPACE; 641 682 #else 642 const char * name = "bits/space";683 const char * name = B_TRANSLATE_MARK("bits/space"); 643 684 #endif 644 685 g_settings_lock.Lock(); 645 686 (void)ioExtension->RemoveName(name);