* 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_
|
#ifndef _CATALOG_H_
|
||||||
#define _CATALOG_H_
|
#define _CATALOG_H_
|
||||||
|
|
||||||
|
#include <LocaleRoster.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#include <String.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
|
#ifndef B_AVOID_TRANSLATION_MACROS
|
||||||
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
// macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if
|
||||||
// you don't want these:
|
// you don't want these:
|
||||||
@@ -97,19 +80,19 @@ class BCatalogStub
|
|||||||
// Translation macros which may be used to shorten translation requests:
|
// Translation macros which may be used to shorten translation requests:
|
||||||
#undef B_TRANSLATE
|
#undef B_TRANSLATE
|
||||||
#define B_TRANSLATE(str) \
|
#define B_TRANSLATE(str) \
|
||||||
BCatalogStub::GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT)
|
be_locale_roster->GetCatalog()->GetString((str), B_TRANSLATE_CONTEXT)
|
||||||
|
|
||||||
#undef B_TRANSLATE_COMMENT
|
#undef B_TRANSLATE_COMMENT
|
||||||
#define B_TRANSLATE_COMMENT(str, cmt) \
|
#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
|
#undef B_TRANSLATE_ALL
|
||||||
#define B_TRANSLATE_ALL(str, ctx, cmt) \
|
#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
|
#undef B_TRANSLATE_ID
|
||||||
#define B_TRANSLATE_ID(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
|
// 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):
|
// 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;
|
const char* langPattern = NULL, int32 fingerprint = 0) const;
|
||||||
// the message contains...
|
// 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 *kCatLangAttr;
|
||||||
static const char *kCatSigAttr;
|
static const char *kCatSigAttr;
|
||||||
static const char *kCatFingerprintAttr;
|
static const char *kCatFingerprintAttr;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ const char *inputFile = NULL;
|
|||||||
BString outputFile;
|
BString outputFile;
|
||||||
const char *catalogSig = NULL;
|
const char *catalogSig = NULL;
|
||||||
const char *catalogLang = "English";
|
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*)");
|
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
||||||
|
|
||||||
|
|
||||||
@@ -45,17 +45,22 @@ void
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
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"
|
" -s <catalogSig> <prepCppFile>\n"
|
||||||
"options:\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"
|
" -o <outfile>\t\texplicitly specifies the name of the output-file\n"
|
||||||
" -p\t\t\tprint keys as they are found\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"
|
" -r <regex>\t\tchanges the regex used by the key-scanner to the one "
|
||||||
" \t\t\tthe default is: BCatalogStub::GetCatalog\\(\\)\\s*->\\s*GetString\\s*\n"
|
"given,\n"
|
||||||
" -s <catalogSig>\tsignature of the target-catalog\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"
|
" -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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,37 +4,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef __CATALOG_STUB_H__
|
|
||||||
#define __CATALOG_STUB_H__
|
|
||||||
|
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Locale.h>
|
|
||||||
#include <LocaleRoster.h>
|
#include <LocaleRoster.h>
|
||||||
|
|
||||||
|
|
||||||
BCatalog BCatalogStub::sCatalog;
|
static BCatalog sCatalog;
|
||||||
vint32 BCatalogStub::sCatalogInitOnce = false;
|
static vint32 sCatalogInitOnce = false;
|
||||||
|
|
||||||
|
|
||||||
/* static */ BCatalog*
|
BCatalog*
|
||||||
BCatalogStub::GetCatalog()
|
BLocaleRoster::GetCatalog()
|
||||||
{
|
{
|
||||||
#if (__GNUC__ < 3)
|
#if (__GNUC__ < 3)
|
||||||
asm volatile(".hidden GetCatalog__12BCatalogStub");
|
asm volatile(".hidden GetCatalog__13BLocaleRoster");
|
||||||
#else
|
#else
|
||||||
asm volatile(".hidden _ZN12BCatalogStub10GetCatalogEv");
|
asm volatile(".hidden _ZN13BLocaleRoster10GetCatalogEv");
|
||||||
#endif
|
#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;
|
BString outputFile;
|
||||||
const char *catalogSig = NULL;
|
const char *catalogSig = NULL;
|
||||||
const char *catalogLang = "English";
|
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*)");
|
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
||||||
|
|
||||||
|
|
||||||
@@ -44,17 +44,22 @@ void
|
|||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
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"
|
" -s <catalogSig> <prepCppFile>\n"
|
||||||
"options:\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"
|
" -o <outfile>\t\texplicitly specifies the name of the output-file\n"
|
||||||
" -p\t\t\tprint keys as they are found\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"
|
" -r <regex>\t\tchanges the regex used by the key-scanner to the one "
|
||||||
" \t\t\tthe default is: be_catalog\\s*->\\s*GetString\\s*\n"
|
"given,\n"
|
||||||
" -s <catalogSig>\tsignature of the target-catalog\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"
|
" -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);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user