* improved the locale kit build rules and headers to use a different set of
B_TRANSLATE-macros when running collectcatkeys, simplifying the regex a lot * added B_TRANSLATE_NOCOLLECT...-macros for the case where a non-literal string shall be translated, but not picked up by collectcatkeys git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37746 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
# Extract catalog entries from the sourcefile and put the output textfile in
|
# Extract catalog entries from the sourcefile and put the output textfile in
|
||||||
# target. This output file is then used to create the binary catalog with
|
# target. This output file is then used to create the binary catalog with
|
||||||
# linkcatkeys.
|
# linkcatkeys.
|
||||||
rule ExtractCatalogEntries target : source : signature : regexp
|
rule ExtractCatalogEntries target : sources : signature : regexp
|
||||||
{
|
{
|
||||||
# get compiler and defines for the platform
|
# get compiler and defines for the platform
|
||||||
local headers ;
|
local headers ;
|
||||||
@@ -55,20 +55,21 @@ rule ExtractCatalogEntries target : source : signature : regexp
|
|||||||
HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ;
|
HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEARCH on $(source) += $(SEARCH_SOURCE) ;
|
SEARCH on $(sources) += $(SEARCH_SOURCE) ;
|
||||||
|
|
||||||
MakeLocatePlatform $(target) ;
|
MakeLocatePlatform $(target) ;
|
||||||
Depends $(target) : $(source) <build>collectcatkeys ;
|
Depends $(target) : $(sources) <build>collectcatkeys ;
|
||||||
LocalClean clean : $(target).pre ;
|
LocalClean clean : $(target).pre ;
|
||||||
ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(source) ;
|
ExtractCatalogEntries1 $(target) : <build>collectcatkeys $(sources) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
actions ExtractCatalogEntries1
|
actions ExtractCatalogEntries1
|
||||||
{
|
{
|
||||||
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
||||||
cat "$(2[2-])" | $(CC) -E $(CCDEFS) $(HDRS) - > "$(1)".pre
|
cat "$(2[2-])" \
|
||||||
$(2[1]) $(HAIKU_CATALOG_REGEXP) -s $(HAIKU_CATALOG_SIGNATURE) \
|
| $(CC) -E $(CCDEFS) -DB_COLLECTING_CATKEYS $(HDRS) - > "$(1)".pre
|
||||||
-w -o "$(1)" "$(1)".pre
|
$(2[1]) $(HAIKU_CATALOG_REGEXP) -s $(HAIKU_CATALOG_SIGNATURE) \
|
||||||
|
-w -o "$(1)" "$(1)".pre
|
||||||
}
|
}
|
||||||
|
|
||||||
rule LinkApplicationCatalog target : sources : signature : language
|
rule LinkApplicationCatalog target : sources : signature : language
|
||||||
|
|||||||
+100
-11
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009, Haiku, Inc.
|
* Copyright 2003-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef _CATALOG_H_
|
#ifndef _CATALOG_H_
|
||||||
@@ -27,6 +27,10 @@ class BCatalog {
|
|||||||
const char *comment = NULL);
|
const char *comment = NULL);
|
||||||
const char *GetString(uint32 id);
|
const char *GetString(uint32 id);
|
||||||
|
|
||||||
|
const char *GetNoAutoCollectString(const char *string,
|
||||||
|
const char *context = NULL, const char *comment = NULL);
|
||||||
|
const char *GetNoAutoCollectString(uint32 id);
|
||||||
|
|
||||||
status_t GetData(const char *name, BMessage *msg);
|
status_t GetData(const char *name, BMessage *msg);
|
||||||
status_t GetData(uint32 id, BMessage *msg);
|
status_t GetData(uint32 id, BMessage *msg);
|
||||||
|
|
||||||
@@ -54,9 +58,12 @@ class BCatalog {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef B_COLLECTING_CATKEYS
|
||||||
|
|
||||||
#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 (in which case you need to collect the catalog keys
|
||||||
|
// manually, as collectcatkeys won't do it for you):
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
// In a single application, several strings (e.g. 'Ok') will be used
|
// In a single application, several strings (e.g. 'Ok') will be used
|
||||||
@@ -76,7 +83,6 @@ class BCatalog {
|
|||||||
// Tip: Use a descriptive name of the class implemented in that
|
// Tip: Use a descriptive name of the class implemented in that
|
||||||
// source-file.
|
// source-file.
|
||||||
|
|
||||||
|
|
||||||
// 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) \
|
||||||
@@ -133,8 +139,82 @@ class BCatalog {
|
|||||||
#define B_TRANSLATE_MARK_ID(id) \
|
#define B_TRANSLATE_MARK_ID(id) \
|
||||||
BCatalogAddOn::MarkForTranslation((id))
|
BCatalogAddOn::MarkForTranslation((id))
|
||||||
|
|
||||||
|
// Translation macros which do not let collectcatkeys try to collect the key
|
||||||
|
// (useful in combination with the marking macros above):
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT
|
||||||
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
||||||
|
B_TRANSLATE(str)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
||||||
|
B_TRANSLATE_COMMENT(str, cmt)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
||||||
|
B_TRANSLATE_ALL(str, ctx, cmt)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
||||||
|
B_TRANSLATE_ID(id)
|
||||||
|
|
||||||
#endif /* B_AVOID_TRANSLATION_MACROS */
|
#endif /* B_AVOID_TRANSLATION_MACROS */
|
||||||
|
|
||||||
|
#else /* B_COLLECTING_CATKEYS */
|
||||||
|
|
||||||
|
// Translation macros used when executing collectcatkeys
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
|
||||||
|
#undef B_TRANSLATE
|
||||||
|
#define B_TRANSLATE(str) \
|
||||||
|
B_CATKEY((str), B_TRANSLATE_CONTEXT)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_COMMENT
|
||||||
|
#define B_TRANSLATE_COMMENT(str, cmt) \
|
||||||
|
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_ALL
|
||||||
|
#define B_TRANSLATE_ALL(str, ctx, cmt) \
|
||||||
|
B_CATKEY((str), (ctx), (cmt))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_ID
|
||||||
|
#define B_TRANSLATE_ID(id) \
|
||||||
|
B_CATKEY((id))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_MARK
|
||||||
|
#define B_TRANSLATE_MARK(str) \
|
||||||
|
B_CATKEY((str), B_TRANSLATE_CONTEXT)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_MARK_COMMENT
|
||||||
|
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \
|
||||||
|
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_MARK_ALL
|
||||||
|
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \
|
||||||
|
B_CATKEY((str), (ctx), (cmt))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_MARK_ID
|
||||||
|
#define B_TRANSLATE_MARK_ID(id) \
|
||||||
|
B_CATKEY((id))
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT
|
||||||
|
#define B_TRANSLATE_NOCOLLECT(str) \
|
||||||
|
(void)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_COMMENT
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \
|
||||||
|
(void)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_ALL
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \
|
||||||
|
(void)
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_NOCOLLECT_ID
|
||||||
|
#define B_TRANSLATE_NOCOLLECT_ID(id) \
|
||||||
|
(void)
|
||||||
|
|
||||||
|
#endif /* B_COLLECTING_CATKEYS */
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
// For BCatalog add-on implementations:
|
// For BCatalog add-on implementations:
|
||||||
@@ -254,6 +334,21 @@ BCatalog::GetFingerprint(uint32 *fp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const char *
|
||||||
|
BCatalog::GetNoAutoCollectString(const char *string, const char *context,
|
||||||
|
const char *comment)
|
||||||
|
{
|
||||||
|
return GetString(string, context, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const char *
|
||||||
|
BCatalog::GetNoAutoCollectString(uint32 id)
|
||||||
|
{
|
||||||
|
return GetString(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline status_t
|
inline status_t
|
||||||
BCatalog::InitCheck() const
|
BCatalog::InitCheck() const
|
||||||
{
|
{
|
||||||
@@ -288,22 +383,16 @@ BCatalogAddOn::Next()
|
|||||||
return fNext;
|
return fNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: newline before '::' to avoid this being a false positive for
|
|
||||||
// collectcatkeys
|
|
||||||
inline const char *
|
inline const char *
|
||||||
BCatalogAddOn
|
BCatalogAddOn::MarkForTranslation(const char *str, const char *ctx,
|
||||||
::MarkForTranslation(const char *str, const char *ctx,
|
|
||||||
const char *cmt)
|
const char *cmt)
|
||||||
{
|
{
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// HACK: newline before '::' to avoid this being a false positive for
|
|
||||||
// collectcatkeys
|
|
||||||
inline int32
|
inline int32
|
||||||
BCatalogAddOn
|
BCatalogAddOn::MarkForTranslation(int32 id)
|
||||||
::MarkForTranslation(int32 id)
|
|
||||||
{
|
{
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2010, Haiku.
|
* Copyright 2003-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -29,8 +29,8 @@ 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("(be_locale_roster->GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
BString rxString("B_CATKEY\\s*");
|
||||||
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
|
||||||
|
|
||||||
|
|
||||||
BString str, ctx, cmt;
|
BString str, ctx, cmt;
|
||||||
@@ -99,7 +99,6 @@ fetchStr(const char *&in, BString &str, bool lookForID)
|
|||||||
|
|
||||||
// Strip all whitespace until we find a closing parenthesis, or the
|
// Strip all whitespace until we find a closing parenthesis, or the
|
||||||
// beginning of another string
|
// beginning of another string
|
||||||
// TODO: ignore comments
|
|
||||||
while (isspace(*in) || *in == ')') {
|
while (isspace(*in) || *in == ')') {
|
||||||
if (*in == ')') {
|
if (*in == ')') {
|
||||||
if (parLevel == 0)
|
if (parLevel == 0)
|
||||||
@@ -185,10 +184,10 @@ collectAllCatalogKeys(BString& inputStr)
|
|||||||
if (fetchKey(in)) {
|
if (fetchKey(in)) {
|
||||||
if (haveID) {
|
if (haveID) {
|
||||||
if (showKeys)
|
if (showKeys)
|
||||||
printf("CatKey(%ld)\n", id);
|
printf("CatKey(%d)\n", id);
|
||||||
res = catalog->SetString(id, "");
|
res = catalog->SetString(id, "");
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
fprintf(stderr, "couldn't add key %ld - error: %s\n",
|
fprintf(stderr, "couldn't add key %d - error: %s\n",
|
||||||
id, strerror(res));
|
id, strerror(res));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
@@ -302,7 +301,7 @@ main(int argc, char **argv)
|
|||||||
if (showSummary) {
|
if (showSummary) {
|
||||||
int32 count = catalog->CountItems();
|
int32 count = catalog->CountItems();
|
||||||
if (count)
|
if (count)
|
||||||
fprintf(stderr, "%ld key%s found and written to %s\n",
|
fprintf(stderr, "%d key%s found and written to %s\n",
|
||||||
count, (count==1 ? "": "s"), outputFile.String());
|
count, (count==1 ? "": "s"), outputFile.String());
|
||||||
else
|
else
|
||||||
fprintf(stderr, "no keys found\n");
|
fprintf(stderr, "no keys found\n");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2009, Haiku.
|
* Copyright 2003-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -28,8 +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("(be_locale_roster->GetCatalog\\(\\)\\s*->\\s*GetString\\s*"
|
BString rxString("B_CATKEY\\s*");
|
||||||
"|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)");
|
|
||||||
|
|
||||||
|
|
||||||
BString str, ctx, cmt;
|
BString str, ctx, cmt;
|
||||||
@@ -96,7 +95,6 @@ fetchStr(const char *&in, BString &str, bool lookForID)
|
|||||||
|
|
||||||
// Strip all whitespace until we find a closing parenthesis, or the
|
// Strip all whitespace until we find a closing parenthesis, or the
|
||||||
// beginning of another string
|
// beginning of another string
|
||||||
// TODO: ignore comments
|
|
||||||
while (isspace(*in) || *in == ')') {
|
while (isspace(*in) || *in == ')') {
|
||||||
if (*in == ')') {
|
if (*in == ')') {
|
||||||
if (parLevel == 0)
|
if (parLevel == 0)
|
||||||
@@ -188,10 +186,10 @@ collectAllCatalogKeys(BString& inputStr)
|
|||||||
if (fetchKey(in)) {
|
if (fetchKey(in)) {
|
||||||
if (haveID) {
|
if (haveID) {
|
||||||
if (showKeys)
|
if (showKeys)
|
||||||
printf("CatKey(%ld)\n", id);
|
printf("CatKey(%d)\n", id);
|
||||||
res = catalog->SetString(id, "");
|
res = catalog->SetString(id, "");
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
fprintf(stderr, "Collectcatkeys: couldn't add key %ld - "
|
fprintf(stderr, "Collectcatkeys: couldn't add key %d - "
|
||||||
"error: %s\n", id, strerror(res));
|
"error: %s\n", id, strerror(res));
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
@@ -303,7 +301,7 @@ main(int argc, char **argv)
|
|||||||
if (showSummary) {
|
if (showSummary) {
|
||||||
int32 count = catalog->CountItems();
|
int32 count = catalog->CountItems();
|
||||||
if (count)
|
if (count)
|
||||||
fprintf(stderr, "%ld key%s found and written to %s\n",
|
fprintf(stderr, "%d key%s found and written to %s\n",
|
||||||
count, (count==1 ? "": "s"), outputFile.String());
|
count, (count==1 ? "": "s"), outputFile.String());
|
||||||
else
|
else
|
||||||
fprintf(stderr, "no keys found\n");
|
fprintf(stderr, "no keys found\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user