* Remove the CatalogStub class and put the Gatcatalog function directly in BLocaleRoster,
* Adjust the B_TRANSLATE macros to take this into account * Adjust collectkatkeys to take it into account too Thanks to Ingo for explaining me all the technical details about hiding things in shared objects. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37616 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#ifndef _CATALOG_H_
|
||||
#define _CATALOG_H_
|
||||
|
||||
#include <LocaleRoster.h>
|
||||
#include <SupportDefs.h>
|
||||
#include <String.h>
|
||||
|
||||
@@ -53,24 +54,6 @@ class BCatalog {
|
||||
};
|
||||
|
||||
|
||||
// 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
|
||||
// must also have a mimetype so that the catalog can be identified.
|
||||
class BCatalogStub
|
||||
{
|
||||
private:
|
||||
static BCatalog sCatalog;
|
||||
static vint32 sCatalogInitOnce;
|
||||
|
||||
public:
|
||||
static BCatalog* GetCatalog();
|
||||
static void ForceReload();
|
||||
// Use this to force re-initialisation of the catalog (when there
|
||||
// is a locale change for example)
|
||||
};
|
||||
|
||||
|
||||
#ifndef B_AVOID_TRANSLATION_MACROS
|
||||
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
||||
// you don't want these:
|
||||
@@ -97,19 +80,19 @@ class BCatalogStub
|
||||
// Translation macros which may be used to shorten translation requests:
|
||||
#undef B_TRANSLATE
|
||||
#define B_TRANSLATE(str) \
|
||||
BCatalogStub::GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT)
|
||||
be_locale_roster->GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT)
|
||||
|
||||
#undef B_TRANSLATE_COMMENT
|
||||
#define B_TRANSLATE_COMMENT(str, cmt) \
|
||||
BCatalogStub::GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT, (cmt))
|
||||
be_locale_roster->GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT, (cmt))
|
||||
|
||||
#undef B_TRANSLATE_ALL
|
||||
#define B_TRANSLATE_ALL(str, ctx, cmt) \
|
||||
BCatalogStub::GetCatalog()->GetString((str), (ctx), (cmt))
|
||||
be_locale_roster->GetCatalog()->GetString((str), (ctx), (cmt))
|
||||
|
||||
#undef B_TRANSLATE_ID
|
||||
#define B_TRANSLATE_ID(id) \
|
||||
BCatalogStub::GetCatalog()->GetString((id))
|
||||
be_locale_roster->GetCatalog()->GetString((id))
|
||||
|
||||
// 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):
|
||||
|
||||
@@ -57,6 +57,10 @@ class BLocaleRoster {
|
||||
const char* langPattern = NULL, int32 fingerprint = 0) const;
|
||||
// the message contains...
|
||||
|
||||
BCatalog* GetCatalog();
|
||||
// Get the catalog for the calling image (that needs to link with
|
||||
// liblocalestub.a)
|
||||
|
||||
static const char *kCatLangAttr;
|
||||
static const char *kCatSigAttr;
|
||||
static const char *kCatFingerprintAttr;
|
||||
|
||||
@@ -29,7 +29,7 @@ const char *inputFile = NULL;
|
||||
BString outputFile;
|
||||
const char *catalogSig = NULL;
|
||||
const char *catalogLang = "English";
|
||||
BString rxString("(BCatalogStub::GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
||||
BString rxString("(be_locale_roster->GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
||||
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
||||
|
||||
|
||||
@@ -45,17 +45,22 @@ void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: collectcatkeys [-pvw] [-r <regex>] [-o <outfile>] [-l <catalogLanguage>]\n"
|
||||
"usage: collectcatkeys [-pvw] [-r <regex>] [-o <outfile>] "
|
||||
"[-l <catalogLanguage>]\n"
|
||||
" -s <catalogSig> <prepCppFile>\n"
|
||||
"options:\n"
|
||||
" -l <catalogLang>\tlanguage of the target-catalog (default is English)\n"
|
||||
" -l <catalogLang>\tlanguage of the target-catalog (default is "
|
||||
"English)\n"
|
||||
" -o <outfile>\t\texplicitly specifies the name of the output-file\n"
|
||||
" -p\t\t\tprint keys as they are found\n"
|
||||
" -r <regex>\t\tchanges the regex used by the key-scanner to the one given,\n"
|
||||
" \t\t\tthe default is: BCatalogStub::GetCatalog\\(\\)\\s*->\\s*GetString\\s*\n"
|
||||
" -s <catalogSig>\tsignature of the target-catalog\n"
|
||||
" -r <regex>\t\tchanges the regex used by the key-scanner to the one "
|
||||
"given,\n"
|
||||
" \t\t\tthe default is: ");
|
||||
fprintf(stderr, rxString.String());
|
||||
fprintf(stderr,"\n -s <catalogSig>\tsignature of the target-catalog\n"
|
||||
" -v\t\t\tbe verbose, show summary\n"
|
||||
" -w\t\t\tshow warnings about catalog-accesses that couldn't be resolved completely\n");
|
||||
" -w\t\t\tshow warnings about catalog-accesses that couldn't be "
|
||||
" resolved completely\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,37 +4,23 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __CATALOG_STUB_H__
|
||||
#define __CATALOG_STUB_H__
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <LocaleRoster.h>
|
||||
|
||||
|
||||
BCatalog BCatalogStub::sCatalog;
|
||||
vint32 BCatalogStub::sCatalogInitOnce = false;
|
||||
static BCatalog sCatalog;
|
||||
static vint32 sCatalogInitOnce = false;
|
||||
|
||||
|
||||
/* static */ BCatalog*
|
||||
BCatalogStub::GetCatalog()
|
||||
BCatalog*
|
||||
BLocaleRoster::GetCatalog()
|
||||
{
|
||||
#if (__GNUC__ < 3)
|
||||
asm volatile(".hidden GetCatalog__12BCatalogStub");
|
||||
asm volatile(".hidden GetCatalog__13BLocaleRoster");
|
||||
#else
|
||||
asm volatile(".hidden _ZN12BCatalogStub10GetCatalogEv");
|
||||
asm volatile(".hidden _ZN13BLocaleRoster10GetCatalogEv");
|
||||
#endif
|
||||
|
||||
return be_locale_roster->GetCatalog(&sCatalog, &sCatalogInitOnce);
|
||||
return GetCatalog(&sCatalog, &sCatalogInitOnce);
|
||||
}
|
||||
|
||||
|
||||
/* static */ void
|
||||
BCatalogStub::ForceReload()
|
||||
{
|
||||
sCatalogInitOnce = false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,7 @@ const char *inputFile = NULL;
|
||||
BString outputFile;
|
||||
const char *catalogSig = NULL;
|
||||
const char *catalogLang = "English";
|
||||
BString rxString("(BCatalogStub::GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
||||
BString rxString("(be_locale_roster->GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
||||
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
||||
|
||||
|
||||
@@ -44,17 +44,22 @@ void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: collectcatkeys [-pvw] [-r <regex>] [-o <outfile>] [-l <catalogLanguage>]\n"
|
||||
"usage: collectcatkeys [-pvw] [-r <regex>] [-o <outfile>] "
|
||||
"[-l <catalogLanguage>]\n"
|
||||
" -s <catalogSig> <prepCppFile>\n"
|
||||
"options:\n"
|
||||
" -l <catalogLang>\tlanguage of the target-catalog (default is English)\n"
|
||||
" -l <catalogLang>\tlanguage of the target-catalog (default is "
|
||||
"English)\n"
|
||||
" -o <outfile>\t\texplicitly specifies the name of the output-file\n"
|
||||
" -p\t\t\tprint keys as they are found\n"
|
||||
" -r <regex>\t\tchanges the regex used by the key-scanner to the one given,\n"
|
||||
" \t\t\tthe default is: be_catalog\\s*->\\s*GetString\\s*\n"
|
||||
" -s <catalogSig>\tsignature of the target-catalog\n"
|
||||
" -r <regex>\t\tchanges the regex used by the key-scanner to the one "
|
||||
"given,\n"
|
||||
" \t\t\tthe default is: ");
|
||||
fprintf(stderr, rxString.String());
|
||||
fprintf(stderr,"\n -s <catalogSig>\tsignature of the target-catalog\n"
|
||||
" -v\t\t\tbe verbose, show summary\n"
|
||||
" -w\t\t\tshow warnings about catalog-accesses that couldn't be resolved completely\n");
|
||||
" -w\t\t\tshow warnings about catalog-accesses that couldn't be "
|
||||
" resolved completely\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user