Patch by Jorma Karvonnen : localize BaseTranslator. Thanks !
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37462 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,8 +32,16 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
|
||||||
#include "BaseTranslator.h"
|
#include "BaseTranslator.h"
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "BaseTranslator"
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
//
|
//
|
||||||
@@ -53,17 +61,21 @@ BaseTranslator::BaseTranslator(const char *name, const char *info,
|
|||||||
int32 inCount, const translation_format *outFormats, int32 outCount,
|
int32 inCount, const translation_format *outFormats, int32 outCount,
|
||||||
const char *settingsFile, TranSetting *defaults, int32 defCount,
|
const char *settingsFile, TranSetting *defaults, int32 defCount,
|
||||||
uint32 tranGroup, uint32 tranType)
|
uint32 tranGroup, uint32 tranType)
|
||||||
: BTranslator()
|
:
|
||||||
|
BTranslator()
|
||||||
{
|
{
|
||||||
|
const char* _name = NULL;
|
||||||
|
const char* _info = NULL;
|
||||||
|
|
||||||
fSettings = new TranslatorSettings(settingsFile, defaults, defCount);
|
fSettings = new TranslatorSettings(settingsFile, defaults, defCount);
|
||||||
fSettings->LoadSettings();
|
fSettings->LoadSettings();
|
||||||
// load settings from the Base Translator settings file
|
// load settings from the Base Translator settings file
|
||||||
|
|
||||||
fVersion = version;
|
fVersion = version;
|
||||||
fName = new char[strlen(name) + 1];
|
fName = new char[strlen(_name) + 1];
|
||||||
strcpy(fName, name);
|
strcpy(fName, _name);
|
||||||
fInfo = new char[strlen(info) + 41];
|
fInfo = new char[strlen(_info) + 41];
|
||||||
sprintf(fInfo, "%s v%d.%d.%d %s", info,
|
sprintf(fInfo, "%s v%d.%d.%d %s", _info,
|
||||||
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(fVersion)),
|
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(fVersion)),
|
||||||
static_cast<int>(B_TRANSLATION_MINOR_VERSION(fVersion)),
|
static_cast<int>(B_TRANSLATION_MINOR_VERSION(fVersion)),
|
||||||
static_cast<int>(B_TRANSLATION_REVISION_VERSION(fVersion)),
|
static_cast<int>(B_TRANSLATION_REVISION_VERSION(fVersion)),
|
||||||
@@ -77,6 +89,7 @@ BaseTranslator::BaseTranslator(const char *name, const char *info,
|
|||||||
fTranType = tranType;
|
fTranType = tranType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
//
|
//
|
||||||
@@ -100,6 +113,7 @@ BaseTranslator::~BaseTranslator()
|
|||||||
delete[] fInfo;
|
delete[] fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// TranslatorName
|
// TranslatorName
|
||||||
//
|
//
|
||||||
@@ -119,6 +133,7 @@ BaseTranslator::TranslatorName() const
|
|||||||
return fName;
|
return fName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// TranslatorInfo
|
// TranslatorInfo
|
||||||
//
|
//
|
||||||
@@ -139,6 +154,7 @@ BaseTranslator::TranslatorInfo() const
|
|||||||
return fInfo;
|
return fInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// TranslatorVersion
|
// TranslatorVersion
|
||||||
//
|
//
|
||||||
@@ -159,6 +175,7 @@ BaseTranslator::TranslatorVersion() const
|
|||||||
return fVersion;
|
return fVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// InputFormats
|
// InputFormats
|
||||||
//
|
//
|
||||||
@@ -184,6 +201,7 @@ BaseTranslator::InputFormats(int32 *out_count) const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// OutputFormats
|
// OutputFormats
|
||||||
//
|
//
|
||||||
@@ -209,6 +227,7 @@ BaseTranslator::OutputFormats(int32 *out_count) const
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// identify_bits_header
|
// identify_bits_header
|
||||||
//
|
//
|
||||||
@@ -289,7 +308,7 @@ BaseTranslator::identify_bits_header(BPositionIO *inSource,
|
|||||||
outInfo->group = B_TRANSLATOR_BITMAP;
|
outInfo->group = B_TRANSLATOR_BITMAP;
|
||||||
outInfo->quality = 0.2;
|
outInfo->quality = 0.2;
|
||||||
outInfo->capability = 0.2;
|
outInfo->capability = 0.2;
|
||||||
strcpy(outInfo->name, "Be Bitmap Format");
|
strcpy(outInfo->name, B_TRANSLATE("Be Bitmap Format"));
|
||||||
strcpy(outInfo->MIME, "image/x-be-bitmap");
|
strcpy(outInfo->MIME, "image/x-be-bitmap");
|
||||||
|
|
||||||
// Look for quality / capability info in fInputFormats
|
// Look for quality / capability info in fInputFormats
|
||||||
@@ -315,6 +334,7 @@ BaseTranslator::identify_bits_header(BPositionIO *inSource,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// BitsCheck
|
// BitsCheck
|
||||||
//
|
//
|
||||||
@@ -386,6 +406,7 @@ BaseTranslator::BitsCheck(BPositionIO *inSource, BMessage *ioExtension,
|
|||||||
return B_OK + 1;
|
return B_OK + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BaseTranslator::BitsIdentify(BPositionIO *inSource,
|
BaseTranslator::BitsIdentify(BPositionIO *inSource,
|
||||||
const translation_format *inFormat, BMessage *ioExtension,
|
const translation_format *inFormat, BMessage *ioExtension,
|
||||||
@@ -407,6 +428,7 @@ BaseTranslator::BitsIdentify(BPositionIO *inSource,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Identify
|
// Identify
|
||||||
//
|
//
|
||||||
@@ -460,6 +482,7 @@ BaseTranslator::Identify(BPositionIO *inSource,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// translate_from_bits_to_bits
|
// translate_from_bits_to_bits
|
||||||
//
|
//
|
||||||
@@ -539,6 +562,7 @@ BaseTranslator::translate_from_bits_to_bits(BPositionIO *inSource,
|
|||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BaseTranslator::BitsTranslate(BPositionIO *inSource,
|
BaseTranslator::BitsTranslate(BPositionIO *inSource,
|
||||||
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
|
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
|
||||||
@@ -556,6 +580,7 @@ BaseTranslator::BitsTranslate(BPositionIO *inSource,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Translate
|
// Translate
|
||||||
//
|
//
|
||||||
@@ -603,6 +628,7 @@ BaseTranslator::Translate(BPositionIO *inSource,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns the current translator settings into ioExtension
|
// returns the current translator settings into ioExtension
|
||||||
status_t
|
status_t
|
||||||
BaseTranslator::GetConfigurationMessage(BMessage *ioExtension)
|
BaseTranslator::GetConfigurationMessage(BMessage *ioExtension)
|
||||||
@@ -610,6 +636,7 @@ BaseTranslator::GetConfigurationMessage(BMessage *ioExtension)
|
|||||||
return fSettings->GetConfigurationMessage(ioExtension);
|
return fSettings->GetConfigurationMessage(ioExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// MakeConfigurationView
|
// MakeConfigurationView
|
||||||
//
|
//
|
||||||
@@ -656,12 +683,14 @@ BaseTranslator::MakeConfigurationView(BMessage *ioExtension, BView **outView,
|
|||||||
outExtent);
|
outExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TranslatorSettings *
|
TranslatorSettings *
|
||||||
BaseTranslator::AcquireSettings()
|
BaseTranslator::AcquireSettings()
|
||||||
{
|
{
|
||||||
return fSettings->Acquire();
|
return fSettings->Acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// Functions to be implemented by derived classes
|
// Functions to be implemented by derived classes
|
||||||
|
|
||||||
@@ -673,6 +702,7 @@ BaseTranslator::DerivedIdentify(BPositionIO *inSource,
|
|||||||
return B_NO_TRANSLATOR;
|
return B_NO_TRANSLATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BaseTranslator::DerivedTranslate(BPositionIO *inSource,
|
BaseTranslator::DerivedTranslate(BPositionIO *inSource,
|
||||||
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
|
const translator_info *inInfo, BMessage *ioExtension, uint32 outType,
|
||||||
@@ -695,6 +725,7 @@ BaseTranslator::NewConfigView(TranslatorSettings *settings)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
translate_direct_copy(BPositionIO *inSource, BPositionIO *outDestination)
|
translate_direct_copy(BPositionIO *inSource, BPositionIO *outDestination)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,13 +33,13 @@
|
|||||||
#ifndef BASE_TRANSLATOR_H
|
#ifndef BASE_TRANSLATOR_H
|
||||||
#define BASE_TRANSLATOR_H
|
#define BASE_TRANSLATOR_H
|
||||||
|
|
||||||
|
#include <ByteOrder.h>
|
||||||
|
#include <DataIO.h>
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
#include <Translator.h>
|
#include <Translator.h>
|
||||||
#include <TranslatorFormats.h>
|
#include <TranslatorFormats.h>
|
||||||
#include <TranslationDefs.h>
|
#include <TranslationDefs.h>
|
||||||
#include <GraphicsDefs.h>
|
|
||||||
#include <InterfaceDefs.h>
|
|
||||||
#include <DataIO.h>
|
|
||||||
#include <ByteOrder.h>
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include "TranslatorSettings.h"
|
#include "TranslatorSettings.h"
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,11 @@ StaticLibrary libtranslatorsutils.a :
|
|||||||
StreamBuffer.cpp
|
StreamBuffer.cpp
|
||||||
TranslatorSettings.cpp
|
TranslatorSettings.cpp
|
||||||
TranslatorWindow.cpp
|
TranslatorWindow.cpp
|
||||||
;
|
: $(HAIKU_LOCALE_LIBS)
|
||||||
|
;
|
||||||
|
|
||||||
|
DoCatalogs libtranslatorsutils.a :
|
||||||
|
:
|
||||||
|
BaseTranslator.cpp
|
||||||
|
TranslatorWindow.cpp
|
||||||
|
;
|
||||||
|
|||||||
@@ -34,6 +34,11 @@
|
|||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include "TranslatorWindow.h"
|
#include "TranslatorWindow.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "TranslatorWindow"
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
//
|
//
|
||||||
@@ -56,6 +61,7 @@ TranslatorWindow::TranslatorWindow(BRect area, const char *title)
|
|||||||
// Do nothing for a non-layout window
|
// Do nothing for a non-layout window
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Destructor
|
// Destructor
|
||||||
//
|
//
|
||||||
@@ -74,13 +80,14 @@ TranslatorWindow::~TranslatorWindow()
|
|||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect)
|
LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect)
|
||||||
{
|
{
|
||||||
BView *view = NULL;
|
BView *view = NULL;
|
||||||
if (translator->MakeConfigurationView(NULL, &view, &rect)) {
|
if (translator->MakeConfigurationView(NULL, &view, &rect)) {
|
||||||
BAlert *err = new BAlert("Error",
|
BAlert *err = new BAlert(B_TRANSLATE("Error"),
|
||||||
"Unable to create the view.", "OK");
|
B_TRANSLATE("Unable to create the view."), B_TRANSLATE("OK"));
|
||||||
err->Go();
|
err->Go();
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,10 +33,13 @@
|
|||||||
#define TRANSLATORWINDOW_H
|
#define TRANSLATORWINDOW_H
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Window.h>
|
#include <Catalog.h>
|
||||||
#include <View.h>
|
#include <Locale.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#include <Translator.h>
|
#include <Translator.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class TranslatorWindow : public BWindow {
|
class TranslatorWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
@@ -47,6 +50,7 @@ public:
|
|||||||
// Posts a quit message so that the application closes properly
|
// Posts a quit message so that the application closes properly
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LaunchTranslatorWindow(BTranslator *translator, const char *title,
|
LaunchTranslatorWindow(BTranslator *translator, const char *title,
|
||||||
BRect rect = BRect(0, 0, 1, 1));
|
BRect rect = BRect(0, 0, 1, 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user