-Started to localize the appearance preflet to find more locale kit bugs. It worked.

-MarkForTranslation was not scanned by collectcatkeys, improved the regexp to take it into account
-Some gristing was missing in jamrules, added a bit, still seem to miss some.
-Replaced $(var:B).ext with $(var:S=.ext) as it is the proper way in order not to loose grist and mess things up
-Removed icu include and replaced direct class nesting with pointer to avoid binary compatibility breakage on ICU updates.
-Fixed TimeFormatSettingsView to properly include needed icu things. Should not be there, actually. Needs cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33210 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues 2009-09-20 22:16:30 +00:00
parent 76065080e6
commit b254319360
11 changed files with 96 additions and 60 deletions

View File

@ -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) <build>linkcatkeys ;
LocalClean clean : $(target) ;
LinkApplicationCatalog1 $(target)
LinkApplicationCatalog1 $(target)
: <build>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) ;
}

View File

@ -6,13 +6,11 @@
#include <LocaleStrings.h>
#include <String.h>
#include <unicode/locid.h>
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_ */

View File

@ -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;

View File

@ -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<SimpleDateFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(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<DecimalFormat*>(numberFormatter);

View File

@ -10,9 +10,17 @@
#include <stdio.h>
#include "defs.h"
#include <Catalog.h>
#include <Locale.h>
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();
}

View File

@ -8,7 +8,9 @@
#include "APRWindow.h"
#include <Button.h>
#include <Catalog.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <Messenger.h>
#include <SpaceLayoutItem.h>
#include <TabView.h>
@ -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);

View File

@ -13,8 +13,10 @@
// for detected the availablility of subpixel anti-aliasing
#include <Box.h>
#include <Catalog.h>
#include <GridLayoutBuilder.h>
#include <GroupLayoutBuilder.h>
#include <Locale.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <PopUpMenu.h>
@ -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);
}

View File

@ -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
;

View File

@ -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
;

View File

@ -29,6 +29,8 @@
#include <TextControl.h>
#include <Window.h>
#include <unicode/utypes.h>
#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));
}

View File

@ -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;