* Update all applications in tree to use the new localizing system

* Remove the old one from the locale librairy, with some cleanup
Known regressions :
 * readonlybootprompt will no longer update the locale settings : the 
method used messed with internal undocumented things
 * external localized apps (webpositive for example) will not run 
anymore.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37336 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-07-02 11:36:13 +00:00
parent ba7d3b37f9
commit be8fa2fb30
135 changed files with 87 additions and 446 deletions
+3 -23
View File
@@ -45,8 +45,6 @@ class BCatalog {
const BCatalog& operator= (const BCatalog&);
// hide assignment and copy-constructor
static status_t GetAppCatalog(BCatalog*);
BCatalogAddOn *fCatalog;
private:
@@ -55,10 +53,6 @@ class BCatalog {
};
extern BCatalog* be_catalog;
extern BCatalog* be_app_catalog;
// Proxy class for handling a "shared object local" catalog.
// This must be included (statically linked) into each shared object needing
// a catalog on its own (application, add-on, library, ...). The shared object
@@ -70,6 +64,9 @@ class BCatalogStub {
public:
static BCatalog* GetCatalog();
static void ForceReload();
// Use this to force re-initialisation of the catalog (when there
// is a locale change for example)
};
@@ -96,7 +93,6 @@ class BCatalogStub {
// source-file.
#ifdef B_TRANSLATE_USE_NEW_MACROS
// Translation macros which may be used to shorten translation requests:
#undef B_TRANSLATE
#define B_TRANSLATE(str) \
@@ -113,22 +109,6 @@ class BCatalogStub {
#undef B_TRANSLATE_ID
#define B_TRANSLATE_ID(id) \
BCatalogStub::GetCatalog()->GetString((id))
#else
#define B_TRANSLATE(str) \
be_catalog->GetString((str), B_TRANSLATE_CONTEXT)
#undef B_TRANSLATE_COMMENT
#define B_TRANSLATE_COMMENT(str, cmt) \
be_catalog->GetString((str), B_TRANSLATE_CONTEXT, (cmt))
#undef B_TRANSLATE_ALL
#define B_TRANSLATE_ALL(str, ctx, cmt) \
be_catalog->GetString((str), (ctx), (cmt))
#undef B_TRANSLATE_ID
#define B_TRANSLATE_ID(id) \
be_catalog->GetString((id))
#endif
// Translation markers which can be used to mark static strings/IDs which
// are used as key for translation requests (at other places in the code):
-120
View File
@@ -1,120 +0,0 @@
#ifndef _CATALOG_IN_ADD_ON_H_
#define _CATALOG_IN_ADD_ON_H_
#include <Catalog.h>
#include <Entry.h>
#include <Locale.h>
#include <LocaleRoster.h>
#include <Node.h>
#include <TypeConstants.h>
/*
* This header file is somewhat special...
*
* Since the TR-macros are referencing be_catalog, we want each add-on
* to have its own be_catalog (instead of sharing the one from the lib).
* In order to do so, we define another be_catalog in this file, which
* will override the one from liblocale.so.
* This way we implement something like add-on-local storage. It would
* be desirable to find a better way, so please tell us if you know one!
*
* Every add-on that wants to use the Locale Kit needs to include this
* file once (no more, exactly once!).
* You have to include it in the source-file that loads the add-on's
* catalog (by use of get_add_on_catalog().
*
*/
BCatalog *be_catalog = NULL;
// global that points to this add-on's catalog
/*
* utility function which determines the entry-ref for "this" add-on:
*/
static status_t
get_add_on_ref(entry_ref *ref)
{
if (!ref)
return B_BAD_VALUE;
image_info imageInfo;
int32 cookie = 0;
status_t res = B_ERROR;
void *dataPtr = static_cast<void*>(&be_catalog);
while ((res = get_next_image_info(0, &cookie, &imageInfo)) == B_OK) {
char *dataStart = static_cast<char*>(imageInfo.data);
if (imageInfo.type == B_ADD_ON_IMAGE && dataStart <= dataPtr
&& dataStart+imageInfo.data_size > dataPtr) {
get_ref_for_path(imageInfo.name, ref);
break;
}
}
return res;
}
/*
* Every add-on should load its catalog through this function, since
* it does not only load the add-on's catalog, but it does several
* other useful things:
* - be_catalog (the one belonging to this add-on) is initialized
* such that the TR-macros use the add-on's catalog.
* - if givenSig is empty (NULL or "") the add-on's signature is
* used to determine the catalog-sig.
* - if the add-on's executable contains an embedded catalog, that
* one is loaded, too.
*/
status_t
get_add_on_catalog(BCatalog* cat, const char *givenSig)
{
if (!cat)
return B_BAD_VALUE;
// determine entry-ref of the add-on this code lives in:
entry_ref ref;
status_t res = get_add_on_ref(&ref);
if (res == B_OK) {
// ok, we have found the entry-ref for our add-on,
// so we try to fetch the fingerprint from our add-on-file:
int32 fp = 0;
BNode addOnNode(&ref);
addOnNode.ReadAttr(BLocaleRoster::kCatFingerprintAttr,
B_INT32_TYPE, 0, &fp, sizeof(int32));
BString sig(givenSig);
if (sig.Length() == 0) {
res = addOnNode.ReadAttrString("BEOS:MIME", &sig);
if (res == B_OK) {
// drop supertype from mimetype (should be "application/"):
int32 pos = sig.FindFirst('/');
if (pos >= 0)
sig.Remove(0, pos+1);
}
}
if (res == B_OK) {
// try to load it's catalog...
cat->fCatalog
= be_locale_roster->LoadCatalog(sig.String(), NULL, fp);
// ...and try to load an embedded catalog, too (if that exists):
BCatalogAddOn *embeddedCatalog
= be_locale_roster->LoadEmbeddedCatalog(&ref);
if (embeddedCatalog) {
if (!cat->fCatalog)
// embedded catalog is the only catalog that was found:
cat->fCatalog = embeddedCatalog;
else {
// append embedded catalog to list of loaded catalogs:
BCatalogAddOn *currCat = cat->fCatalog;
while (currCat->fNext)
currCat = currCat->fNext;
currCat->fNext = embeddedCatalog;
}
}
be_catalog = cat;
}
}
return cat->InitCheck();
}
#endif /* _CATALOG_IN_ADD_ON_H_ */
-2
View File
@@ -45,8 +45,6 @@ class BLocale {
void GetSortKey(const char *string, BString *key);
status_t GetAppCatalog(BCatalog *);
protected:
BCollator *fCollator;
BLanguage *fLanguage;
+2 -5
View File
@@ -33,11 +33,6 @@ class BLocaleRoster {
BLocaleRoster();
~BLocaleRoster();
// status_t GetCatalog(BLocale *,const char *mimeType, BCatalog *catalog);
// status_t GetCatalog(const char *mimeType, BCatalog *catalog);
// status_t SetCatalog(BLocale *,const char *mimeType, BCatalog *catalog);
BCatalog* GetCatalog(BCatalog* catalog, vint32* catalogInitStatus);
// status_t GetLocaleFor(const char *langCode, const char *countryCode);
status_t GetSystemCatalog(BCatalogAddOn **) const;
@@ -73,6 +68,7 @@ class BLocaleRoster {
static int32 kEmbeddedCatResId;
private:
BCatalog* GetCatalog(BCatalog* catalog, vint32* catalogInitStatus);
BCatalogAddOn* LoadCatalog(const char *signature,
const char *language = NULL, int32 fingerprint = 0);
@@ -83,6 +79,7 @@ class BLocaleRoster {
const char *signature, const char *language);
friend class BCatalog;
friend class BCatalogStub;
friend class BPrivate::EditableCatalog;
friend status_t get_add_on_catalog(BCatalog*, const char *);
};