Applied patchs from Karvjorm (tickets #7118, #7128, #7137) with fixes by myself: Localizations for JPEG, BMP, ICO translators.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40298 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2011-01-26 22:58:47 +00:00
parent a0ad88e002
commit 03901b6cae
13 changed files with 134 additions and 47 deletions

View File

@ -32,9 +32,15 @@
/*****************************************************************************/
#include <Application.h>
#include <Catalog.h>
#include "BMPTranslator.h"
#include "TranslatorWindow.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BMPMain"
// ---------------------------------------------------------------
// main
//
@ -53,8 +59,9 @@ main()
{
BApplication app("application/x-vnd.Haiku-BMPTranslator");
status_t result;
result = LaunchTranslatorWindow(new BMPTranslator,
"BMP Settings", BRect(0, 0, 225, 175));
B_TRANSLATE("BMP Settings"), BRect(0, 0, 225, 175));
if (result == B_OK) {
app.Run();
return 0;

View File

@ -7,7 +7,6 @@
*/
#include "BMPTranslator.h"
#include "BMPView.h"
#include <algorithm>
#include <new>
@ -15,15 +14,24 @@
#include <stdlib.h>
#include <string.h>
#include <Catalog.h>
#include "BMPView.h"
using std::nothrow;
using std::min;
//#define INFO(x) printf(x);
#define INFO(x)
//#define ERROR(x) printf(x);
#define ERROR(x)
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BMPTranslator"
// The input formats that this translator supports.
static const translation_format sInputFormats[] = {
{
@ -121,7 +129,8 @@ make_nth_translator(int32 n, image_id you, uint32 flags, ...)
// Returns:
// ---------------------------------------------------------------
BMPTranslator::BMPTranslator()
: BaseTranslator("BMP images", "BMP image translator",
: BaseTranslator(B_TRANSLATE("BMP images"),
B_TRANSLATE("BMP image translator"),
BMP_TRANSLATOR_VERSION,
sInputFormats, kNumInputFormats,
sOutputFormats, kNumOutputFormats,
@ -362,7 +371,9 @@ identify_bmp_header(BPositionIO *inSource, translator_info *outInfo,
outInfo->group = B_TRANSLATOR_BITMAP;
outInfo->quality = BMP_IN_QUALITY;
outInfo->capability = BMP_IN_CAPABILITY;
sprintf(outInfo->name, "BMP image (MS format, %d bits",
sprintf(outInfo->name,
B_TRANSLATE_COMMENT("BMP image (MS format, %d bits",
"Ignore missing closing round bracket"),
msheader.bitsperpixel);
if (msheader.compression)
strcat(outInfo->name, ", RLE)");
@ -431,8 +442,8 @@ identify_bmp_header(BPositionIO *inSource, translator_info *outInfo,
outInfo->group = B_TRANSLATOR_BITMAP;
outInfo->quality = BMP_IN_QUALITY;
outInfo->capability = BMP_IN_CAPABILITY;
sprintf(outInfo->name, "BMP image (OS/2 format, %d bits)",
os2header.bitsperpixel);
sprintf(outInfo->name, B_TRANSLATE("BMP image (OS/2 format, "
"%d bits)"), os2header.bitsperpixel);
strcpy(outInfo->MIME, "image/x-bmp");
}
if (pfileheader && pmsheader) {
@ -1889,6 +1900,7 @@ BMPTranslator::DerivedTranslate(BPositionIO *inSource,
BView *
BMPTranslator::NewConfigView(TranslatorSettings *settings)
{
return new BMPView(BRect(0, 0, 225, 175), "BMPTranslator Settings",
B_FOLLOW_ALL, B_WILL_DRAW, settings);
return new BMPView(BRect(0, 0, 225, 175),
B_TRANSLATE("BMPTranslator Settings"), B_FOLLOW_ALL, B_WILL_DRAW,
settings);
}

View File

@ -29,13 +29,16 @@
#ifndef BMP_TRANSLATOR_H
#define BMP_TRANSLATOR_H
#include <ByteOrder.h>
#include <Catalog.h>
#include <DataIO.h>
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <Locale.h>
#include <Translator.h>
#include <TranslatorFormats.h>
#include <TranslationDefs.h>
#include <GraphicsDefs.h>
#include <InterfaceDefs.h>
#include <DataIO.h>
#include <ByteOrder.h>
#include "BaseTranslator.h"
#define BMP_NO_COMPRESS 0

View File

@ -13,10 +13,14 @@
#include "BMPView.h"
#include "BMPTranslator.h"
#include <Catalog.h>
#include <StringView.h>
#include <stdio.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "BMPView"
BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode,
uint32 flags, TranslatorSettings *settings)
@ -30,7 +34,8 @@ BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode,
float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
BRect rect(10, 10, 200, 10 + height);
BStringView *stringView = new BStringView(rect, "title", "BMP image translator");
BStringView *stringView = new BStringView(rect, "title",
B_TRANSLATE("BMP image translator"));
stringView->SetFont(be_bold_font);
stringView->ResizeToPreferred();
AddChild(stringView);
@ -39,7 +44,7 @@ BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode,
rect.OffsetBy(0, height + 10);
char version[256];
snprintf(version, sizeof(version), "Version %d.%d.%d, %s",
snprintf(version, sizeof(version), B_TRANSLATE("Version %d.%d.%d, %s"),
int(B_TRANSLATION_MAJOR_VERSION(BMP_TRANSLATOR_VERSION)),
int(B_TRANSLATION_MINOR_VERSION(BMP_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(BMP_TRANSLATOR_VERSION)),
@ -55,7 +60,7 @@ BMPView::BMPView(const BRect &frame, const char *name, uint32 resizeMode,
height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;
rect.OffsetBy(0, height + 5);
stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2002-2006 Haiku Inc.");
stringView = new BStringView(rect, "Copyright", B_UTF8_COPYRIGHT "2002-2010 Haiku Inc.");
stringView->ResizeToPreferred();
AddChild(stringView);

View File

@ -14,8 +14,15 @@ Translator BMPTranslator :
: true
;
DoCatalogs BMPTranslator :
x-vnd.Haiku-BMPTranslator
:
BMPMain.cpp
BMPTranslator.cpp
BMPView.cpp
;
Package haiku-translationkit-cvs :
BMPTranslator :
boot home config add-ons Translators ;

View File

@ -7,6 +7,7 @@
#include "ConfigView.h"
#include "ICOTranslator.h"
#include <Catalog.h>
#include <CheckBox.h>
#include <ControlLook.h>
#include <SpaceLayoutItem.h>
@ -15,14 +16,18 @@
#include <stdio.h>
#include <string.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ConfigView"
ConfigView::ConfigView()
:
BGroupView("ICOTranslator Settings", B_VERTICAL, 0)
BGroupView(B_TRANSLATE("ICOTranslator Settings"), B_VERTICAL, 0)
{
BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);
BStringView* stringView = new BStringView("title", "Windows icon images");
BStringView* stringView = new BStringView("title",
B_TRANSLATE("Windows icon images"));
stringView->SetFont(be_bold_font);
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
@ -31,7 +36,7 @@ ConfigView::ConfigView()
AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
char version[256];
sprintf(version, "Version %d.%d.%d, %s",
sprintf(version, B_TRANSLATE("Version %d.%d.%d, %s"),
int(B_TRANSLATION_MAJOR_VERSION(ICO_TRANSLATOR_VERSION)),
int(B_TRANSLATION_MINOR_VERSION(ICO_TRANSLATOR_VERSION)),
int(B_TRANSLATION_REVISION_VERSION(ICO_TRANSLATOR_VERSION)),
@ -47,24 +52,26 @@ ConfigView::ConfigView()
AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
BCheckBox *checkBox = new BCheckBox("color", "Write 32 bit images on"
" true color input", NULL);
BCheckBox *checkBox = new BCheckBox("color",
B_TRANSLATE("Write 32 bit images on true color input"), NULL);
checkBox->SetExplicitAlignment(leftAlignment);
AddChild(checkBox);
checkBox = new BCheckBox("size", "Enforce valid icon sizes", NULL);
checkBox = new BCheckBox("size", B_TRANSLATE("Enforce valid icon sizes"),
NULL);
checkBox->SetValue(1);
checkBox->SetExplicitAlignment(leftAlignment);
AddChild(checkBox);
AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
stringView = new BStringView("valid1", "Valid icon sizes are"
" 16, 32, or 48");
stringView = new BStringView("valid1",
B_TRANSLATE("Valid icon sizes are 16, 32, or 48"));
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);
stringView = new BStringView("valid2", "pixel in either direction.");
stringView = new BStringView("valid2",
B_TRANSLATE("pixel in either direction."));
stringView->SetExplicitAlignment(leftAlignment);
AddChild(stringView);

View File

@ -5,13 +5,20 @@
#include "ICOTranslator.h"
#include "ConfigView.h"
#include "ICO.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <Catalog.h>
#include "ConfigView.h"
#include "ICO.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ICOTranslator"
const char *kDocumentCount = "/documentCount";
const char *kDocumentIndex = "/documentIndex";
@ -72,7 +79,8 @@ const uint32 kNumDefaultSettings = sizeof(sDefaultSettings) / sizeof(TranSetting
ICOTranslator::ICOTranslator()
: BaseTranslator("Windows icon images", "Windows icon translator",
: BaseTranslator(B_TRANSLATE("Windows icon images"),
B_TRANSLATE("Windows icon translator"),
ICO_TRANSLATOR_VERSION,
sInputFormats, kNumInputFormats,
sOutputFormats, kNumOutputFormats,
@ -107,8 +115,10 @@ ICOTranslator::DerivedIdentify(BPositionIO *stream,
info->group = B_TRANSLATOR_BITMAP;
info->quality = ICO_IN_QUALITY;
info->capability = ICO_IN_CAPABILITY;
snprintf(info->name, sizeof(info->name), "Windows %s %ld bit image",
type == ICO::kTypeIcon ? "Icon" : "Cursor", bitsPerPixel);
snprintf(info->name, sizeof(info->name),
B_TRANSLATE("Windows %s %ld bit image"),
type == ICO::kTypeIcon ? B_TRANSLATE("Icon") : B_TRANSLATE("Cursor"),
bitsPerPixel);
strcpy(info->MIME, kICOMimeType);
return B_OK;

View File

@ -15,6 +15,13 @@ Translator ICOTranslator :
: true
;
DoCatalogs ICOTranslator :
x-vnd.Haiku-ICOTranslator
:
ConfigView.cpp
ICOTranslator.cpp
;
Package haiku-translationkit-cvs :
ICOTranslator
: boot home config add-ons Translators

View File

@ -4,11 +4,16 @@
*/
#include <Application.h>
#include <Catalog.h>
#include "ICOTranslator.h"
#include "ICO.h"
#include "TranslatorWindow.h"
#include <Application.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "main"
int
@ -17,7 +22,8 @@ main(int /*argc*/, char **/*argv*/)
BApplication app("application/x-vnd.Haiku-ICOTranslator");
status_t result;
result = LaunchTranslatorWindow(new ICOTranslator, "ICO Settings", BRect(0, 0, 225, 175));
result = LaunchTranslatorWindow(new ICOTranslator,
B_TRANSLATE("ICO Settings"), BRect(0, 0, 225, 175));
if (result != B_OK)
return 1;

View File

@ -35,11 +35,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "exif_parser.h"
#include <Alignment.h>
#include <Catalog.h>
#include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <TabView.h>
#include <TextView.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "JPEGTranslator"
#define MARKER_EXIF 0xe1
@ -514,14 +517,14 @@ TranslatorWriteView::TranslatorWriteView(const char* name,
new BMessage(VIEW_MSG_SET_QUALITY), 0, 100);
fQualitySlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fQualitySlider->SetHashMarkCount(10);
fQualitySlider->SetLimitLabels("Low", "High");
fQualitySlider->SetLimitLabels(B_TRANSLATE("Low"), B_TRANSLATE("High"));
fQualitySlider->SetValue(fSettings->SetGetInt32(JPEG_SET_QUALITY, NULL));
fSmoothingSlider = new SSlider("smoothing", VIEW_LABEL_SMOOTHING,
new BMessage(VIEW_MSG_SET_SMOOTHING), 0, 100);
fSmoothingSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fSmoothingSlider->SetHashMarkCount(10);
fSmoothingSlider->SetLimitLabels("None", "High");
fSmoothingSlider->SetLimitLabels(B_TRANSLATE("None"), B_TRANSLATE("High"));
fSmoothingSlider->SetValue(
fSettings->SetGetInt32(JPEG_SET_SMOOTHING, NULL));
@ -785,8 +788,8 @@ JPEGTranslator::DerivedTranslate(BPositionIO* inSource,
&longJumpBuffer);
}
} catch (...) {
fprintf(stderr, "libjpeg encoutered a critical error "
"(caught C++ exception).\n");
fprintf(stderr, B_TRANSLATE("libjpeg encountered a critical error "
"(caught C++ exception).\n"));
return B_ERROR;
}
@ -939,7 +942,8 @@ JPEGTranslator::Compress(BPositionIO* in, BPositionIO* out,
break;
default:
fprintf(stderr, "Wrong type: Color space not implemented.\n");
fprintf(stderr,
B_TRANSLATE("Wrong type: Color space not implemented.\n"));
return B_ERROR;
}
out_row_bytes = jpg_input_components * width;
@ -1093,7 +1097,8 @@ JPEGTranslator::Decompress(BPositionIO* in, BPositionIO* out,
if (cinfo.out_color_space != JCS_RGB) {
switch (cinfo.out_color_space) {
case JCS_UNKNOWN: /* error/unspecified */
fprintf(stderr, "From Type: Jpeg uses unknown color type\n");
fprintf(stderr,
B_TRANSLATE("From Type: Jpeg uses unknown color type\n"));
break;
case JCS_GRAYSCALE: /* monochrome */
// Check if user wants to read only as RGB32 or not
@ -1125,7 +1130,9 @@ JPEGTranslator::Decompress(BPositionIO* in, BPositionIO* out,
converter = convert_from_CMYK_to_32;
break;
default:
fprintf(stderr, "From Type: Jpeg uses hmm... i don't know really :(\n");
fprintf(stderr,
B_TRANSLATE("From Type: Jpeg uses hmm... i don't know "
"really :(\n"));
break;
}
}

View File

@ -21,6 +21,14 @@ Translator JPEGTranslator :
: true
;
DoCatalogs JPEGTranslator :
x-vnd.Haiku-JPEGTranslator
:
JPEGTranslator.cpp
exif_parser.cpp
be_jerror.cpp
;
Package haiku-translationkit-cvs :
JPEGTranslator :
boot home config add-ons Translators ;

View File

@ -39,6 +39,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Be headers
#include <Alert.h>
#include <Catalog.h>
#include <stdio.h>
// JPEG headers
@ -50,6 +51,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "JPEGTranslator.h"
#include "TranslatorSettings.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "be_jerror"
// Since Translator doesn't use it's own error table, we can use error_mgr's
// variables to store some usefull data.
@ -68,7 +71,7 @@ be_error_exit (j_common_ptr cinfo)
/* Create the message */
(*cinfo->err->format_message) (cinfo, buffer);
fprintf(stderr, "JPEG Library Error: %s\n", buffer);
fprintf(stderr, B_TRANSLATE("JPEG Library Error: %s\n"), buffer);
jmp_buf longJumpBuffer;
memcpy(&longJumpBuffer, &(cinfo->err->long_jump_buffer), sizeof(jmp_buf));
@ -97,7 +100,7 @@ be_output_message (j_common_ptr cinfo)
/* If it's compressing or decompressing and user turned messages on */
if (!cinfo->is_decompressor || cinfo->err->ShowReadWarnings) {
/* show warning message */
fprintf(stderr, "JPEG Library Warning: %s\n", buffer);
fprintf(stderr, B_TRANSLATE("JPEG Library Warning: %s\n"), buffer);
}
}

View File

@ -11,10 +11,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <Catalog.h>
#include <Message.h>
#include <ReadHelper.h>
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "exit_parser"
using std::set;
enum {
@ -29,11 +34,11 @@ enum {
};
static const convert_tag kDefaultTags[] = {
{TAG_MAKER, B_ANY_TYPE, "Maker"},
{TAG_MODEL, B_ANY_TYPE, "Model"},
{TAG_ORIENTATION, B_INT32_TYPE, "Orientation"},
{TAG_EXPOSURE_TIME, B_DOUBLE_TYPE, "ExposureTime"},
{TAG_ISO, B_INT32_TYPE, "ISO"},
{TAG_MAKER, B_ANY_TYPE, B_TRANSLATE_MARK("Maker")},
{TAG_MODEL, B_ANY_TYPE, B_TRANSLATE_MARK("Model")},
{TAG_ORIENTATION, B_INT32_TYPE, B_TRANSLATE_MARK("Orientation")},
{TAG_EXPOSURE_TIME, B_DOUBLE_TYPE, B_TRANSLATE_MARK("ExposureTime")},
{TAG_ISO, B_INT32_TYPE, B_TRANSLATE_MARK("ISO")},
};
static const size_t kNumDefaultTags = sizeof(kDefaultTags)
/ sizeof(kDefaultTags[0]);