diff --git a/build/jam/BeOSRules b/build/jam/BeOSRules index a28377cea2..5deff28d80 100644 --- a/build/jam/BeOSRules +++ b/build/jam/BeOSRules @@ -274,7 +274,7 @@ actions ResAttr1 # 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 # linkcatkeys. -rule ExtractCatalogEntries target : source : signature +rule ExtractCatalogEntries target : source : signature : regexp { # get compiler and defines for the platform local headers ; @@ -320,6 +320,11 @@ rule ExtractCatalogEntries target : source : signature CC on $(target) = $(cc) ; 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) ; @@ -333,7 +338,7 @@ actions ExtractCatalogEntries1 { $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) 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 @@ -359,9 +364,10 @@ actions LinkApplicationCatalog1 -s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)" } -rule DoCatalogs target : signature : sources : sourceLanguage +rule DoCatalogs target : signature : sources : sourceLanguage : regexp { # DoCatalogs : : [ : ] + # [ : ] # # Extracts the catkeys from a target's source files, generates the # 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. # sourceLanguage Short name of the language of used for the strings in # 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) ] ; # generate catkeys file from sources ExtractCatalogEntries $(generatedCatalog:S=.catkeys) - : [ FGristFiles $(sources) ] : $(signature) ; + : [ FGristFiles $(sources) ] : $(signature) : $(regexp) ; # find translations local translationsDir diff --git a/data/catalogs/kits/locale/fr.catkeys b/data/catalogs/kits/locale/fr.catkeys new file mode 100644 index 0000000000..140c68d016 --- /dev/null +++ b/data/catalogs/kits/locale/fr.catkeys @@ -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 diff --git a/headers/os/locale/Catalog.h b/headers/os/locale/Catalog.h index ff463290bb..b353b16642 100644 --- a/headers/os/locale/Catalog.h +++ b/headers/os/locale/Catalog.h @@ -56,7 +56,6 @@ class BCatalog { extern BCatalog* be_catalog; extern BCatalog* be_app_catalog; - #ifndef B_AVOID_TRANSLATION_MACROS // macros for easy catalog-access, define B_AVOID_TRANSLATION_MACROS if // you don't want these: diff --git a/headers/os/locale/LocaleRoster.h b/headers/os/locale/LocaleRoster.h index 07ae49f3b6..36ab22cd15 100644 --- a/headers/os/locale/LocaleRoster.h +++ b/headers/os/locale/LocaleRoster.h @@ -36,6 +36,7 @@ class BLocaleRoster { // status_t GetLocaleFor(const char *langCode, const char *countryCode); + status_t GetSystemCatalog(BCatalogAddOn **) const; status_t GetDefaultCollator(BCollator **) const; status_t GetDefaultLanguage(BLanguage **) const; status_t GetDefaultCountry(BCountry **) const; diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index e83ec61249..ac85fe83e9 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -35,3 +35,10 @@ SharedLibrary liblocale.so UnicodeChar.cpp : be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so ; + +DoCatalogs liblocale.so : + system + : ../shared/StringForSize.cpp + : + : '"systemCatalog\\s*->\\s*GetString\\s*"' +; diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index 2eaabf1b7f..e8d6601255 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -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 BLocaleRoster::GetDefaultCollator(BCollator **collator) const { diff --git a/src/kits/shared/StringForSize.cpp b/src/kits/shared/StringForSize.cpp index ae7831e397..80c9723501 100644 --- a/src/kits/shared/StringForSize.cpp +++ b/src/kits/shared/StringForSize.cpp @@ -7,6 +7,10 @@ #include +#include +#include +#include + namespace BPrivate { @@ -14,27 +18,35 @@ namespace BPrivate { const char* string_for_size(double size, char* string, size_t stringSize) { + BCatalogAddOn* systemCatalog; + be_locale_roster->GetSystemCatalog(&systemCatalog); double kib = size / 1024.0; if (kib < 1.0) { - snprintf(string, stringSize, "%d bytes", (int)size); + snprintf(string, stringSize, + systemCatalog->GetString("%d bytes","StringForSize",""), + (int)size); return string; } double mib = kib / 1024.0; if (mib < 1.0) { - snprintf(string, stringSize, "%3.2f KiB", kib); + snprintf(string, stringSize, + systemCatalog->GetString("%3.2f KiB","StringForSize",""), kib); return string; } double gib = mib / 1024.0; if (gib < 1.0) { - snprintf(string, stringSize, "%3.2f MiB", mib); + snprintf(string, stringSize, + systemCatalog->GetString("%3.2f MiB","StringForSize",""), mib); return string; } double tib = gib / 1024.0; if (tib < 1.0) { - snprintf(string, stringSize, "%3.2f GiB", gib); + snprintf(string, stringSize, + systemCatalog->GetString("%3.2f GiB","StringForSize",""), gib); return string; } - snprintf(string, stringSize, "%.2f TiB", tib); + snprintf(string, stringSize, + systemCatalog->GetString("%.2f TiB","StringForSize",""), tib); return string; } diff --git a/src/kits/tracker/Jamfile b/src/kits/tracker/Jamfile index 2502779fd3..049f295e9b 100644 --- a/src/kits/tracker/Jamfile +++ b/src/kits/tracker/Jamfile @@ -91,7 +91,7 @@ SharedLibrary libtracker.so : VolumeWindow.cpp WidgetAttributeText.cpp - : be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a + : be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a liblocale.so ;