* Build tools : allow to run DoCatalogs with a custom regexp for special cases
* Introduce a system-wide localization catalog used for strings hidden deep in some libraries. Add special API to get it. * string_for_size is the first to make use of this system wide catalog. This allows to have a fully localized DriveSetup. * As a side effect, tracker also uses it. It now requires liblocale.so. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36175 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+12
-4
@@ -274,7 +274,7 @@ actions ResAttr1
|
|||||||
# 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
|
rule ExtractCatalogEntries target : source : signature : regexp
|
||||||
{
|
{
|
||||||
# get compiler and defines for the platform
|
# get compiler and defines for the platform
|
||||||
local headers ;
|
local headers ;
|
||||||
@@ -320,6 +320,11 @@ rule ExtractCatalogEntries target : source : signature
|
|||||||
CC on $(target) = $(cc) ;
|
CC on $(target) = $(cc) ;
|
||||||
|
|
||||||
HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
|
HAIKU_CATALOG_SIGNATURE on $(target) = $(signature) ;
|
||||||
|
if $(regexp) = "" {
|
||||||
|
HAIKU_CATALOG_REGEXP on $(target) = ;
|
||||||
|
} else {
|
||||||
|
HAIKU_CATALOG_REGEXP on $(target) = -r $(regexp) ;
|
||||||
|
}
|
||||||
|
|
||||||
SEARCH on $(source) += $(SEARCH_SOURCE) ;
|
SEARCH on $(source) += $(SEARCH_SOURCE) ;
|
||||||
|
|
||||||
@@ -333,7 +338,7 @@ 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-])" | $(CC) -E $(CCDEFS) $(HDRS) - > "$(1)".pre
|
||||||
$(2[1]) -s $(HAIKU_CATALOG_SIGNATURE) -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
|
||||||
@@ -359,9 +364,10 @@ actions LinkApplicationCatalog1
|
|||||||
-s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)"
|
-s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
rule DoCatalogs target : signature : sources : sourceLanguage
|
rule DoCatalogs target : signature : sources : sourceLanguage : regexp
|
||||||
{
|
{
|
||||||
# DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ]
|
# DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ]
|
||||||
|
# [ : <regexp> ]
|
||||||
#
|
#
|
||||||
# Extracts the catkeys from a target's source files, generates the
|
# Extracts the catkeys from a target's source files, generates the
|
||||||
# default catalog from them, and also generates catalogs for all
|
# default catalog from them, and also generates catalogs for all
|
||||||
@@ -373,12 +379,14 @@ rule DoCatalogs target : signature : sources : sourceLanguage
|
|||||||
# sources: List of cpp files where to search keys.
|
# sources: List of cpp files where to search keys.
|
||||||
# sourceLanguage Short name of the language of used for the strings in
|
# sourceLanguage Short name of the language of used for the strings in
|
||||||
# the sources. Optional: default is "en".
|
# the sources. Optional: default is "en".
|
||||||
|
# regexp The regular expression used to parse the files.
|
||||||
|
# Optional: default is matching be_catalog->GetString
|
||||||
|
|
||||||
local generatedCatalog = [ FGristFiles $(sourceLanguage:E=en:S=.catalog) ] ;
|
local generatedCatalog = [ FGristFiles $(sourceLanguage:E=en:S=.catalog) ] ;
|
||||||
|
|
||||||
# generate catkeys file from sources
|
# generate catkeys file from sources
|
||||||
ExtractCatalogEntries $(generatedCatalog:S=.catkeys)
|
ExtractCatalogEntries $(generatedCatalog:S=.catkeys)
|
||||||
: [ FGristFiles $(sources) ] : $(signature) ;
|
: [ FGristFiles $(sources) ] : $(signature) : $(regexp) ;
|
||||||
|
|
||||||
# find translations
|
# find translations
|
||||||
local translationsDir
|
local translationsDir
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
1 english system 1811097932
|
||||||
|
%3.2f GiB StringForSize %3.2f Gio
|
||||||
|
%3.2f KiB StringForSize %3.2f Kio
|
||||||
|
%d bytes StringForSize %d octets
|
||||||
|
%.2f TiB StringForSize %.2f Tio
|
||||||
|
%3.2f MiB StringForSize %3.2f Mio
|
||||||
@@ -56,7 +56,6 @@ class BCatalog {
|
|||||||
extern BCatalog* be_catalog;
|
extern BCatalog* be_catalog;
|
||||||
extern BCatalog* be_app_catalog;
|
extern BCatalog* be_app_catalog;
|
||||||
|
|
||||||
|
|
||||||
#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:
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class BLocaleRoster {
|
|||||||
|
|
||||||
// status_t GetLocaleFor(const char *langCode, const char *countryCode);
|
// status_t GetLocaleFor(const char *langCode, const char *countryCode);
|
||||||
|
|
||||||
|
status_t GetSystemCatalog(BCatalogAddOn **) const;
|
||||||
status_t GetDefaultCollator(BCollator **) const;
|
status_t GetDefaultCollator(BCollator **) const;
|
||||||
status_t GetDefaultLanguage(BLanguage **) const;
|
status_t GetDefaultLanguage(BLanguage **) const;
|
||||||
status_t GetDefaultCountry(BCountry **) const;
|
status_t GetDefaultCountry(BCountry **) const;
|
||||||
|
|||||||
@@ -35,3 +35,10 @@ SharedLibrary liblocale.so
|
|||||||
UnicodeChar.cpp
|
UnicodeChar.cpp
|
||||||
: be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so
|
: be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so
|
||||||
;
|
;
|
||||||
|
|
||||||
|
DoCatalogs liblocale.so :
|
||||||
|
system
|
||||||
|
: ../shared/StringForSize.cpp
|
||||||
|
:
|
||||||
|
: '"systemCatalog\\s*->\\s*GetString\\s*"'
|
||||||
|
;
|
||||||
|
|||||||
@@ -414,6 +414,16 @@ BLocaleRoster::~BLocaleRoster()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
BLocaleRoster::GetSystemCatalog(BCatalogAddOn **catalog) const
|
||||||
|
{
|
||||||
|
if(!catalog)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
*catalog = be_locale_roster->LoadCatalog("system");
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
BLocaleRoster::GetDefaultCollator(BCollator **collator) const
|
BLocaleRoster::GetDefaultCollator(BCollator **collator) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <LocaleRoster.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
@@ -14,27 +18,35 @@ namespace BPrivate {
|
|||||||
const char*
|
const char*
|
||||||
string_for_size(double size, char* string, size_t stringSize)
|
string_for_size(double size, char* string, size_t stringSize)
|
||||||
{
|
{
|
||||||
|
BCatalogAddOn* systemCatalog;
|
||||||
|
be_locale_roster->GetSystemCatalog(&systemCatalog);
|
||||||
double kib = size / 1024.0;
|
double kib = size / 1024.0;
|
||||||
if (kib < 1.0) {
|
if (kib < 1.0) {
|
||||||
snprintf(string, stringSize, "%d bytes", (int)size);
|
snprintf(string, stringSize,
|
||||||
|
systemCatalog->GetString("%d bytes","StringForSize",""),
|
||||||
|
(int)size);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double mib = kib / 1024.0;
|
double mib = kib / 1024.0;
|
||||||
if (mib < 1.0) {
|
if (mib < 1.0) {
|
||||||
snprintf(string, stringSize, "%3.2f KiB", kib);
|
snprintf(string, stringSize,
|
||||||
|
systemCatalog->GetString("%3.2f KiB","StringForSize",""), kib);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double gib = mib / 1024.0;
|
double gib = mib / 1024.0;
|
||||||
if (gib < 1.0) {
|
if (gib < 1.0) {
|
||||||
snprintf(string, stringSize, "%3.2f MiB", mib);
|
snprintf(string, stringSize,
|
||||||
|
systemCatalog->GetString("%3.2f MiB","StringForSize",""), mib);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
double tib = gib / 1024.0;
|
double tib = gib / 1024.0;
|
||||||
if (tib < 1.0) {
|
if (tib < 1.0) {
|
||||||
snprintf(string, stringSize, "%3.2f GiB", gib);
|
snprintf(string, stringSize,
|
||||||
|
systemCatalog->GetString("%3.2f GiB","StringForSize",""), gib);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
snprintf(string, stringSize, "%.2f TiB", tib);
|
snprintf(string, stringSize,
|
||||||
|
systemCatalog->GetString("%.2f TiB","StringForSize",""), tib);
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ SharedLibrary libtracker.so :
|
|||||||
VolumeWindow.cpp
|
VolumeWindow.cpp
|
||||||
WidgetAttributeText.cpp
|
WidgetAttributeText.cpp
|
||||||
|
|
||||||
: be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a
|
: be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a liblocale.so
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user