Cleanup BCatalogAddOn.
* rename BCatalogAddOn to BCatalogData, since it doesn't represent an
add-on, but rather the catalog data provided by an add-on
* move BCatalogData out of Catalog.{h,cpp} into its own header and
implementation file
* drop BCatalogData::MarkForTranslation() methods, they're not needed
* drop BCatalog::GetNoAutoCollectString() methods, they're not being
used anywhere
* cleanup the B_TRANSLATE_... macros somewhat
* add versions of the B_TRANSLATE_MARK_... macros that are meant to be
used in void context (when the string isn't being used by the program,
just meant to be picked up by collectcatkeys).
* adjust several apps to use B_TRANSLATE_MARK_..._VOID where needed
* adjust users of BCatalogAddOn accordingly
This commit is contained in:
+25
-173
@@ -1,61 +1,52 @@
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
** Copyright 2003-2004. All rights reserved.
|
||||
** Copyright 2003-2004,2012. All rights reserved.
|
||||
**
|
||||
** Authors: Axel Dörfler, [email protected]
|
||||
** Oliver Tappe, [email protected]
|
||||
*/
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
#include <Node.h>
|
||||
#include <Roster.h>
|
||||
#include <CatalogData.h>
|
||||
|
||||
|
||||
BCatalog* be_catalog = NULL;
|
||||
// catalog used by translation macros
|
||||
BCatalog* be_app_catalog = NULL;
|
||||
// app-catalog (useful for accessing app's catalog from inside an add-on,
|
||||
// since in an add-on, be_catalog will hold the add-on's catalog.
|
||||
// Provides an implementation of BCatalog for the build host, in effect only
|
||||
// supporting setting and getting of catalog entries.
|
||||
|
||||
|
||||
//#pragma mark - BCatalog
|
||||
BCatalog::BCatalog()
|
||||
:
|
||||
fCatalog(NULL)
|
||||
fCatalogData(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BCatalog::BCatalog(const entry_ref& catalogOwner, const char *language,
|
||||
uint32 fingerprint)
|
||||
:
|
||||
fCatalogData(NULL)
|
||||
{
|
||||
// Unsupported - the build tools can't (and don't need to) load anything
|
||||
// this way.
|
||||
}
|
||||
|
||||
|
||||
BCatalog::~BCatalog()
|
||||
{
|
||||
if (be_catalog == this)
|
||||
be_app_catalog = be_catalog = NULL;
|
||||
//be_locale_roster->UnloadCatalog(fCatalog);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
BCatalog::GetString(const char *string, const char *context, const char *comment)
|
||||
{
|
||||
if (fCatalogData == 0)
|
||||
return string;
|
||||
|
||||
const char *translated;
|
||||
for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) {
|
||||
for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) {
|
||||
translated = cat->GetString(string, context, comment);
|
||||
if (translated)
|
||||
return translated;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
@@ -63,12 +54,16 @@ BCatalog::GetString(const char *string, const char *context, const char *comment
|
||||
const char *
|
||||
BCatalog::GetString(uint32 id)
|
||||
{
|
||||
if (fCatalogData == 0)
|
||||
return "";
|
||||
|
||||
const char *translated;
|
||||
for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) {
|
||||
for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) {
|
||||
translated = cat->GetString(id);
|
||||
if (translated)
|
||||
return translated;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -76,15 +71,17 @@ BCatalog::GetString(uint32 id)
|
||||
status_t
|
||||
BCatalog::GetData(const char *name, BMessage *msg)
|
||||
{
|
||||
if (!fCatalog)
|
||||
if (fCatalogData == 0)
|
||||
return B_NO_INIT;
|
||||
|
||||
status_t res;
|
||||
for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) {
|
||||
for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) {
|
||||
res = cat->GetData(name, msg);
|
||||
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
|
||||
return res;
|
||||
// return B_OK if found, or specific error-code
|
||||
}
|
||||
|
||||
return B_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
@@ -92,161 +89,16 @@ BCatalog::GetData(const char *name, BMessage *msg)
|
||||
status_t
|
||||
BCatalog::GetData(uint32 id, BMessage *msg)
|
||||
{
|
||||
if (!fCatalog)
|
||||
if (fCatalogData == 0)
|
||||
return B_NO_INIT;
|
||||
|
||||
status_t res;
|
||||
for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) {
|
||||
for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) {
|
||||
res = cat->GetData(id, msg);
|
||||
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
|
||||
return res;
|
||||
// return B_OK if found, or specific error-code
|
||||
}
|
||||
|
||||
return B_NAME_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
//#pragma mark - BCatalogAddOn
|
||||
BCatalogAddOn::BCatalogAddOn(const char *signature, const char *language,
|
||||
uint32 fingerprint)
|
||||
:
|
||||
fInitCheck(B_NO_INIT),
|
||||
fSignature(signature),
|
||||
fLanguageName(language),
|
||||
fFingerprint(fingerprint),
|
||||
fNext(NULL)
|
||||
{
|
||||
fLanguageName.ToLower();
|
||||
// canonicalize language-name to lowercase
|
||||
}
|
||||
|
||||
|
||||
BCatalogAddOn::~BCatalogAddOn()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCatalogAddOn::UpdateFingerprint()
|
||||
{
|
||||
fFingerprint = 0;
|
||||
// base implementation always yields the same fingerprint,
|
||||
// which means that no version-mismatch detection is possible.
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::InitCheck() const
|
||||
{
|
||||
return fInitCheck;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BCatalogAddOn::CanHaveData() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::GetData(const char *name, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::GetData(uint32 id, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::SetString(const char *string, const char *translated,
|
||||
const char *context, const char *comment)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::SetString(int32 id, const char *translated)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BCatalogAddOn::CanWriteData() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::SetData(const char *name, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::SetData(uint32 id, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::ReadFromFile(const char *path)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::ReadFromAttribute(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::ReadFromResource(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::WriteToFile(const char *path)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::WriteToAttribute(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogAddOn::WriteToResource(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
void BCatalogAddOn::MakeEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BCatalogAddOn::CountItems() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
** Copyright 2003-2004,2012. All rights reserved.
|
||||
**
|
||||
** Authors: Axel Dörfler, [email protected]
|
||||
** Oliver Tappe, [email protected]
|
||||
*/
|
||||
|
||||
#include <CatalogData.h>
|
||||
|
||||
|
||||
// Provides an empty implementation of BCatalogData for the build host.
|
||||
|
||||
|
||||
BCatalogData::BCatalogData(const char *signature, const char *language,
|
||||
uint32 fingerprint)
|
||||
:
|
||||
fInitCheck(B_NO_INIT),
|
||||
fSignature(signature),
|
||||
fLanguageName(language),
|
||||
fFingerprint(fingerprint),
|
||||
fNext(NULL)
|
||||
{
|
||||
fLanguageName.ToLower();
|
||||
// canonicalize language-name to lowercase
|
||||
}
|
||||
|
||||
|
||||
BCatalogData::~BCatalogData()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCatalogData::UpdateFingerprint()
|
||||
{
|
||||
fFingerprint = 0;
|
||||
// base implementation always yields the same fingerprint,
|
||||
// which means that no version-mismatch detection is possible.
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::InitCheck() const
|
||||
{
|
||||
return fInitCheck;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BCatalogData::CanHaveData() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::GetData(const char *name, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::GetData(uint32 id, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::SetString(const char *string, const char *translated,
|
||||
const char *context, const char *comment)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::SetString(int32 id, const char *translated)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BCatalogData::CanWriteData() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::SetData(const char *name, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::SetData(uint32 id, BMessage *msg)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::ReadFromFile(const char *path)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::ReadFromAttribute(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::ReadFromResource(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::WriteToFile(const char *path)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::WriteToAttribute(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BCatalogData::WriteToResource(const entry_ref &appOrAddOnRef)
|
||||
{
|
||||
return EOPNOTSUPP;
|
||||
}
|
||||
|
||||
|
||||
void BCatalogData::MakeEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BCatalogData::CountItems() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -401,7 +401,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
|
||||
}
|
||||
|
||||
|
||||
BCatalogAddOn *
|
||||
BCatalogData *
|
||||
DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language,
|
||||
uint32 fingerprint)
|
||||
{
|
||||
@@ -415,7 +415,7 @@ DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language,
|
||||
}
|
||||
|
||||
|
||||
BCatalogAddOn *
|
||||
BCatalogData *
|
||||
DefaultCatalog::Create(const char *signature, const char *language)
|
||||
{
|
||||
DefaultCatalog *catalog
|
||||
|
||||
@@ -35,6 +35,7 @@ BuildPlatformMain <build>collectcatkeys :
|
||||
PlainTextCatalog.cpp
|
||||
HashMapCatalog.cpp
|
||||
Catalog.cpp
|
||||
CatalogData.cpp
|
||||
RegExp.cpp
|
||||
: $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
|
||||
|
||||
@@ -44,4 +45,5 @@ BuildPlatformMain <build>linkcatkeys :
|
||||
HashMapCatalog.cpp
|
||||
DefaultCatalog.cpp
|
||||
Catalog.cpp
|
||||
CatalogData.cpp
|
||||
: $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
|
||||
|
||||
@@ -329,7 +329,7 @@ PlainTextCatalog::UpdateAttributes(const char* path)
|
||||
}
|
||||
|
||||
|
||||
BCatalogAddOn *
|
||||
BCatalogData *
|
||||
PlainTextCatalog::Instantiate(const char *signature, const char *language,
|
||||
uint32 fingerprint)
|
||||
{
|
||||
@@ -346,7 +346,7 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language,
|
||||
} // namespace BPrivate
|
||||
|
||||
|
||||
extern "C" BCatalogAddOn *
|
||||
extern "C" BCatalogData *
|
||||
instantiate_catalog(const char *signature, const char *language,
|
||||
uint32 fingerprint)
|
||||
{
|
||||
@@ -360,9 +360,8 @@ instantiate_catalog(const char *signature, const char *language,
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
BCatalogAddOn *create_catalog(const char *signature,
|
||||
const char *language)
|
||||
extern "C" BCatalogData *
|
||||
create_catalog(const char *signature, const char *language)
|
||||
{
|
||||
PlainTextCatalog *catalog
|
||||
= new(std::nothrow) PlainTextCatalog("emptycat", signature, language);
|
||||
|
||||
Reference in New Issue
Block a user