Author: pulkomandy Date: 2010-04-12 01:00:25 +0200 (Mon, 12 Apr 2010) New Revision: 36175 Changeset: http://dev.haiku-os.org/changeset/36175/haiku Added: haiku/trunk/data/catalogs/kits/ haiku/trunk/data/catalogs/kits/locale/ haiku/trunk/data/catalogs/kits/locale/fr.catkeys Modified: haiku/trunk/build/jam/BeOSRules haiku/trunk/headers/os/locale/Catalog.h haiku/trunk/headers/os/locale/LocaleRoster.h haiku/trunk/src/kits/locale/Jamfile haiku/trunk/src/kits/locale/LocaleRoster.cpp haiku/trunk/src/kits/shared/StringForSize.cpp haiku/trunk/src/kits/tracker/Jamfile Log: * 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. Modified: haiku/trunk/build/jam/BeOSRules =================================================================== --- haiku/trunk/build/jam/BeOSRules 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/build/jam/BeOSRules 2010-04-11 23:00:25 UTC (rev 36175) @@ -274,7 +274,7 @@ # 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 @@ 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 @@ { $(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 @@ -s $(HAIKU_CATALOG_SIGNATURE) -o "$(1)" } -rule DoCatalogs target : signature : sources : sourceLanguage +rule DoCatalogs target : signature : sources : sourceLanguage : regexp { # DoCatalogs <target> : <signature> : <sources> [ : <sourceLanguage> ] + # [ : <regexp> ] # # 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 @@ # 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 Added: haiku/trunk/data/catalogs/kits/locale/fr.catkeys =================================================================== --- haiku/trunk/data/catalogs/kits/locale/fr.catkeys (rev 0) +++ haiku/trunk/data/catalogs/kits/locale/fr.catkeys 2010-04-11 23:00:25 UTC (rev 36175) @@ -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 Modified: haiku/trunk/headers/os/locale/Catalog.h =================================================================== --- haiku/trunk/headers/os/locale/Catalog.h 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/headers/os/locale/Catalog.h 2010-04-11 23:00:25 UTC (rev 36175) @@ -56,7 +56,6 @@ 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: Modified: haiku/trunk/headers/os/locale/LocaleRoster.h =================================================================== --- haiku/trunk/headers/os/locale/LocaleRoster.h 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/headers/os/locale/LocaleRoster.h 2010-04-11 23:00:25 UTC (rev 36175) @@ -36,6 +36,7 @@ // 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; Modified: haiku/trunk/src/kits/locale/Jamfile =================================================================== --- haiku/trunk/src/kits/locale/Jamfile 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/src/kits/locale/Jamfile 2010-04-11 23:00:25 UTC (rev 36175) @@ -35,3 +35,10 @@ UnicodeChar.cpp : be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so ; + +DoCatalogs liblocale.so : + system + : ../shared/StringForSize.cpp + : + : '"systemCatalog\\s*->\\s*GetString\\s*"' +; Modified: haiku/trunk/src/kits/locale/LocaleRoster.cpp =================================================================== --- haiku/trunk/src/kits/locale/LocaleRoster.cpp 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/src/kits/locale/LocaleRoster.cpp 2010-04-11 23:00:25 UTC (rev 36175) @@ -415,6 +415,16 @@ 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 { // It should just use the archived collator from the locale settings; Modified: haiku/trunk/src/kits/shared/StringForSize.cpp =================================================================== --- haiku/trunk/src/kits/shared/StringForSize.cpp 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/src/kits/shared/StringForSize.cpp 2010-04-11 23:00:25 UTC (rev 36175) @@ -7,34 +7,46 @@ #include <stdio.h> +#include <Catalog.h> +#include <Locale.h> +#include <LocaleRoster.h> + 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; } Modified: haiku/trunk/src/kits/tracker/Jamfile =================================================================== --- haiku/trunk/src/kits/tracker/Jamfile 2010-04-11 22:48:33 UTC (rev 36174) +++ haiku/trunk/src/kits/tracker/Jamfile 2010-04-11 23:00:25 UTC (rev 36175) @@ -91,7 +91,7 @@ VolumeWindow.cpp WidgetAttributeText.cpp - : be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a + : be translation $(vector_icon_libs) $(TARGET_LIBSTDC++) libshared.a liblocale.so ;