diff --git a/build/jam/BeOSRules b/build/jam/BeOSRules index 0eb29d8cb8..ad5aaa1e72 100644 --- a/build/jam/BeOSRules +++ b/build/jam/BeOSRules @@ -271,8 +271,8 @@ actions ResAttr1 # Localization rules -# 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 +# 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 { @@ -332,12 +332,12 @@ rule ExtractCatalogEntries target : source : signature actions ExtractCatalogEntries1 { $(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 $(LOCALE_KIT_SIGNATURE) -p -o "$(1)" "$(1)".pre } # Link catalog entries from given catkey file into output compiled catalog file. -# Compiled catalog file will then be copied into the image, but only if the +# Compiled catalog file will then be copied into the image, but only if the # fingerprint matches the one from the untranslated catalog for the same file. rule LinkApplicationCatalog target : sources : signature : language { @@ -345,7 +345,7 @@ rule LinkApplicationCatalog target : sources : signature : language LOCALE_KIT_SIGNATURE on $(target) = $(signature) ; Depends $(target) : $(sources) linkcatkeys ; LocalClean clean : $(target) ; - LinkApplicationCatalog1 $(target) + LinkApplicationCatalog1 $(target) : linkcatkeys $(language) $(sources) ; } @@ -366,18 +366,20 @@ rule DoCatalogs appName # Application name : translatedCatalogs # List of available translations { genCat = [ FGristFiles $(generatedCatalog) ] ; - + trans = [ FGristFiles $(translatedCatalogs) ] ; + SEARCH on $(trans) += $(SEARCH_SOURCE) ; + ExtractCatalogEntries $(genCat:S=.catkeys) : $(sources) : $(signature) ; LinkApplicationCatalog $(genCat) : $(genCat:S=.catkeys) : $(signature) : $(genCat:B) ; - for catalog in $(translatedCatalogs) + for catalog in $(trans) { - LinkApplicationCatalog $(catalog:B).catalog : $(catalog) + LinkApplicationCatalog $(catalog:S=.catalog) : $(catalog) : $(signature) : $(catalog:B) ; } AddFilesToHaikuImage system etc locale catalogs $(signature) : - $(genCat) $(translatedCatalogs:B).catalog ; + $(genCat) $(trans:S=.catalog) ; } diff --git a/headers/os/locale/Country.h b/headers/os/locale/Country.h index 1673c87603..597c72c1bb 100644 --- a/headers/os/locale/Country.h +++ b/headers/os/locale/Country.h @@ -6,13 +6,11 @@ #include #include -#include - namespace icu_4_2 { class DateFormat; + class Locale; } - enum { B_METRIC = 0, B_US @@ -51,7 +49,7 @@ class BCountry { // numbers virtual void FormatNumber(char* string, size_t maxSize, double value); - virtual UErrorCode FormatNumber(BString* string, double value); + virtual status_t FormatNumber(BString* string, double value); virtual void FormatNumber(char* string, size_t maxSize, int32 value); virtual void FormatNumber(BString* string, int32 value); @@ -83,7 +81,7 @@ class BCountry { icu_4_2::DateFormat* fICULongDateFormatter; icu_4_2::DateFormat* fICUShortDateFormatter; const char** fStrings; - Locale fICULocale; + icu_4_2::Locale* fICULocale; }; #endif /* _COUNTRY_H_ */ diff --git a/src/bin/locale/collectcatkeys.cpp b/src/bin/locale/collectcatkeys.cpp index c5970337c5..d41462e4c9 100644 --- a/src/bin/locale/collectcatkeys.cpp +++ b/src/bin/locale/collectcatkeys.cpp @@ -29,7 +29,8 @@ const char *inputFile = NULL; BString outputFile; const char *catalogSig = NULL; const char *catalogLang = "English"; -BString rxString("be_catalog\\s*->\\s*GetString\\s*"); +BString rxString("(be_catalog\\s*->\\s*GetString\\s*" + "|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)"); BString str, ctx, cmt; diff --git a/src/kits/locale/Country.cpp b/src/kits/locale/Country.cpp index 267c3dd307..cd3d433dbb 100644 --- a/src/kits/locale/Country.cpp +++ b/src/kits/locale/Country.cpp @@ -43,26 +43,27 @@ const char* gStrings[] = { BCountry::BCountry(const char* languageCode, const char* countryCode) : - fStrings(gStrings), - fICULocale(languageCode, countryCode) + fStrings(gStrings) { + fICULocale = new icu_4_2::Locale(languageCode, countryCode); } BCountry::BCountry(const char* languageAndCountryCode) : - fStrings(gStrings), - fICULocale(languageAndCountryCode) + fStrings(gStrings) { + fICULocale = new icu_4_2::Locale(languageAndCountryCode); fICULongDateFormatter = DateFormat::createDateInstance( - DateFormat::FULL, fICULocale); + DateFormat::FULL, *fICULocale); fICUShortDateFormatter = DateFormat::createDateInstance( - DateFormat::SHORT, fICULocale); + DateFormat::SHORT, *fICULocale); } BCountry::~BCountry() { + delete fICULocale; } @@ -70,7 +71,7 @@ bool BCountry::Name(BString& name) const { UnicodeString uString; - fICULocale.getDisplayName(uString); + fICULocale->getDisplayName(uString); BStringByteSink stringConverter(&name); uString.toUTF8(stringConverter); return true; @@ -80,7 +81,7 @@ BCountry::Name(BString& name) const const char* BCountry::Code() const { - return fICULocale.getName(); + return fICULocale->getName(); } @@ -138,7 +139,7 @@ BCountry::FormatTime(BString* string, time_t time, bool longFormat) icu_4_2::DateFormat* timeFormatter; timeFormatter = DateFormat::createTimeInstance( longFormat ? DateFormat::FULL : DateFormat::SHORT, - fICULocale); + *fICULocale); UnicodeString ICUString; ICUString = timeFormatter->format((UDate)time * 1000, ICUString); @@ -187,7 +188,7 @@ BCountry::TimeFormat(BString& format, bool longFormat) const icu_4_2::DateFormat* dateFormatter; dateFormatter = DateFormat::createTimeInstance( longFormat ? DateFormat::FULL : DateFormat::SHORT, - fICULocale); + *fICULocale); SimpleDateFormat* dateFormatterImpl = static_cast(dateFormatter); @@ -228,14 +229,15 @@ BCountry::FormatNumber(char* string, size_t maxSize, double value) } -UErrorCode +status_t BCountry::FormatNumber(BString* string, double value) { UErrorCode err = U_ZERO_ERROR; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, NumberFormat::kNumberStyle, + = NumberFormat::createInstance(*fICULocale, NumberFormat::kNumberStyle, err); + // Warning: we're returning an ICU error here but the type is status_t. if (U_FAILURE(err)) return err; UnicodeString ICUString; @@ -264,7 +266,7 @@ BCountry::FormatNumber(BString* string, int32 value) { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); @@ -284,7 +286,7 @@ BCountry::DecimalPoint(BString& format) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); @@ -312,7 +314,7 @@ BCountry::ThousandsSeparator(BString& separator) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -338,7 +340,7 @@ BCountry::Grouping(BString& grouping) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -364,7 +366,7 @@ BCountry::PositiveSign(BString& sign) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -390,7 +392,7 @@ BCountry::NegativeSign(BString& sign) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createInstance(fICULocale, err); + = NumberFormat::createInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -433,7 +435,7 @@ BCountry::FormatMonetary(BString* string, double value) { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); @@ -454,7 +456,7 @@ BCountry::CurrencySymbol(BString& symbol) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -480,7 +482,7 @@ BCountry::InternationalCurrencySymbol(BString& symbol) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -506,7 +508,7 @@ BCountry::MonDecimalPoint(BString& decimal) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -532,7 +534,7 @@ BCountry::MonThousandsSeparator(BString& separator) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); @@ -558,7 +560,7 @@ BCountry::MonGrouping(BString& grouping) const { UErrorCode err; NumberFormat* numberFormatter - = NumberFormat::createCurrencyInstance(fICULocale, err); + = NumberFormat::createCurrencyInstance(*fICULocale, err); assert(err == U_ZERO_ERROR); DecimalFormat* decimalFormatter = dynamic_cast(numberFormatter); diff --git a/src/preferences/appearance/APRMain.cpp b/src/preferences/appearance/APRMain.cpp index 4ef3989d6f..117e6adf99 100644 --- a/src/preferences/appearance/APRMain.cpp +++ b/src/preferences/appearance/APRMain.cpp @@ -10,9 +10,17 @@ #include #include "defs.h" +#include +#include + APRApplication::APRApplication(void) : BApplication(APPEARANCE_APP_SIGNATURE) { + // Do this now because we need to call BWindow constructor with a translated + // string. + BCatalog cat; + be_locale->GetAppCatalog(&cat); + fWindow = new APRWindow(BRect(100, 100, 550, 420)); fWindow->Show(); } diff --git a/src/preferences/appearance/APRWindow.cpp b/src/preferences/appearance/APRWindow.cpp index ebffab057e..e0878e8014 100644 --- a/src/preferences/appearance/APRWindow.cpp +++ b/src/preferences/appearance/APRWindow.cpp @@ -8,7 +8,9 @@ #include "APRWindow.h" #include +#include #include +#include #include #include #include @@ -16,20 +18,23 @@ #include "APRView.h" #include "defs.h" +#define TR_CONTEXT "APRWindow" + static const uint32 kMsgSetDefaults = 'dflt'; static const uint32 kMsgRevert = 'rvrt'; APRWindow::APRWindow(BRect frame) - : BWindow(frame, "Appearance", B_TITLED_WINDOW, + : BWindow(frame, TR("Appearance"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES) { + SetLayout(new BGroupLayout(B_HORIZONTAL)); - fDefaultsButton = new BButton("defaults", "Defaults", + fDefaultsButton = new BButton("defaults", TR("Defaults"), new BMessage(kMsgSetDefaults), B_WILL_DRAW); - fRevertButton = new BButton("revert", "Revert", + fRevertButton = new BButton("revert", TR("Revert"), new BMessage(kMsgRevert), B_WILL_DRAW); BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); diff --git a/src/preferences/appearance/AntialiasingSettingsView.cpp b/src/preferences/appearance/AntialiasingSettingsView.cpp index bcf463f6bb..37409ab718 100644 --- a/src/preferences/appearance/AntialiasingSettingsView.cpp +++ b/src/preferences/appearance/AntialiasingSettingsView.cpp @@ -13,8 +13,10 @@ // for detected the availablility of subpixel anti-aliasing #include +#include #include #include +#include #include #include #include @@ -25,6 +27,8 @@ #include "APRWindow.h" +#define TR_CONTEXT "AntialiasingSettingsView" + //#define DISABLE_HINTING_CONTROL // if defined, the hinting menu is disabled (hinting not properly @@ -33,11 +37,11 @@ static const int32 kMsgSetAntialiasing = 'anti'; static const int32 kMsgSetHinting = 'hint'; static const int32 kMsgSetAverageWeight = 'avrg'; -static const char* kSubpixelLabel = "LCD subpixel"; -static const char* kGrayscaleLabel = "Grayscale"; -static const char* kNoHintingLabel = "Off"; -static const char* kMonospacedHintingLabel = "Monospaced Fonts Only"; -static const char* kFullHintingLabel = "On"; +static const char* kSubpixelLabel = TR_MARK("LCD subpixel"); +static const char* kGrayscaleLabel = TR_MARK("Grayscale"); +static const char* kNoHintingLabel = TR_MARK("Off"); +static const char* kMonospacedHintingLabel = TR_MARK("Monospaced Fonts Only"); +static const char* kFullHintingLabel = TR_MARK("On"); // #pragma mark - private libbe API @@ -228,14 +232,14 @@ AntialiasingSettingsView::_BuildAntialiasingMenu() BMessage* message = new BMessage(kMsgSetAntialiasing); message->AddBool("antialiasing", false); - BMenuItem* item = new BMenuItem(kGrayscaleLabel, message); + BMenuItem* item = new BMenuItem(TR(kGrayscaleLabel), message); fAntialiasingMenu->AddItem(item); message = new BMessage(kMsgSetAntialiasing); message->AddBool("antialiasing", true); - item = new BMenuItem(kSubpixelLabel, message); + item = new BMenuItem(TR(kSubpixelLabel), message); fAntialiasingMenu->AddItem(item); } @@ -248,15 +252,15 @@ AntialiasingSettingsView::_BuildHintingMenu() BMessage* message = new BMessage(kMsgSetHinting); message->AddInt8("hinting", HINTING_MODE_OFF); - fHintingMenu->AddItem(new BMenuItem(kNoHintingLabel, message)); + fHintingMenu->AddItem(new BMenuItem(TR(kNoHintingLabel), message)); message = new BMessage(kMsgSetHinting); message->AddInt8("hinting", HINTING_MODE_ON); - fHintingMenu->AddItem(new BMenuItem(kFullHintingLabel, message)); + fHintingMenu->AddItem(new BMenuItem(TR(kFullHintingLabel), message)); message = new BMessage(kMsgSetHinting); message->AddInt8("hinting", HINTING_MODE_MONOSPACED_ONLY); - fHintingMenu->AddItem(new BMenuItem(kMonospacedHintingLabel, message)); + fHintingMenu->AddItem(new BMenuItem(TR(kMonospacedHintingLabel), message)); } @@ -264,7 +268,7 @@ void AntialiasingSettingsView::_SetCurrentAntialiasing() { BMenuItem *item = fAntialiasingMenu->FindItem( - fCurrentSubpixelAntialiasing ? kSubpixelLabel : kGrayscaleLabel); + fCurrentSubpixelAntialiasing ? TR(kSubpixelLabel) : TR(kGrayscaleLabel)); if (item != NULL) item->SetMarked(true); if (fCurrentSubpixelAntialiasing) @@ -288,7 +292,7 @@ AntialiasingSettingsView::_SetCurrentHinting() break; } - BMenuItem *item = fHintingMenu->FindItem(label); + BMenuItem *item = fHintingMenu->FindItem(TR(label)); if (item != NULL) item->SetMarked(true); } diff --git a/src/preferences/appearance/Jamfile b/src/preferences/appearance/Jamfile index 94caee0db3..5969a68745 100644 --- a/src/preferences/appearance/Jamfile +++ b/src/preferences/appearance/Jamfile @@ -22,7 +22,20 @@ Preference Appearance : #FontMenu.cpp #MenuView.cpp - : be $(TARGET_LIBSTDC++) + : be $(TARGET_LIBSTDC++) liblocale.so : Appearance.rdef ; +DoCatalogs Appearance : + x-vnd.Haiku-Appearance + : + AntialiasingSettingsView.cpp + APRView.cpp + APRWindow.cpp + ColorSet.cpp + ColorWell.cpp + ColorWhichItem.cpp + : en.catalog + : fr.catkeys + ; + diff --git a/src/preferences/locale/Jamfile b/src/preferences/locale/Jamfile index 514c89a91d..023ff57d23 100644 --- a/src/preferences/locale/Jamfile +++ b/src/preferences/locale/Jamfile @@ -20,5 +20,5 @@ DoCatalogs Locale # application name TimeFormatSettingsView.cpp : en.catalog # default catalog generated from sourcecode : # translations - [ FDirName $(HAIKU_TOP) src preferences locale fr.catkeys ] + fr.catkeys ; diff --git a/src/preferences/locale/TimeFormatSettingsView.cpp b/src/preferences/locale/TimeFormatSettingsView.cpp index 996429f0f3..eab4e4946d 100644 --- a/src/preferences/locale/TimeFormatSettingsView.cpp +++ b/src/preferences/locale/TimeFormatSettingsView.cpp @@ -29,6 +29,8 @@ #include #include +#include + #define TR_CONTEXT "TimeFormatSettings" @@ -680,11 +682,11 @@ TimeFormatSettingsView::_UpdateExamples() fCountry->FormatTime(&timeFormat, timeValue, false); fShortTimeExampleView->SetText(timeFormat); - UErrorCode Error = fCountry->FormatNumber(&timeFormat, 1234.5678); - if (Error == 0) + status_t Error = fCountry->FormatNumber(&timeFormat, 1234.5678); + if (Error == U_ZERO_ERROR) fNumberFormatExampleView->SetText(timeFormat); else - fNumberFormatExampleView->SetText(u_errorName(Error)); + fNumberFormatExampleView->SetText(u_errorName((UErrorCode)Error)); } diff --git a/src/tools/locale/collectcatkeys.cpp b/src/tools/locale/collectcatkeys.cpp index 2af16924ba..f7825bb858 100644 --- a/src/tools/locale/collectcatkeys.cpp +++ b/src/tools/locale/collectcatkeys.cpp @@ -28,7 +28,8 @@ const char *inputFile = NULL; BString outputFile; const char *catalogSig = NULL; const char *catalogLang = "English"; -BString rxString("be_catalog\\s*->\\s*GetString\\s*"); +BString rxString("(be_catalog\\s*->\\s*GetString\\s*" + "|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)"); BString str, ctx, cmt;