diff --git a/data/catalogs/kits/locale/fr.catkeys b/data/catalogs/kits/locale/fr.catkeys index 140c68d016..a6bbb4d165 100644 --- a/data/catalogs/kits/locale/fr.catkeys +++ b/data/catalogs/kits/locale/fr.catkeys @@ -1,6 +1,9 @@ -1 english system 1811097932 +1 french system 2677153267 %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 +Red: ColorControl Rouge : +Green: ColorControl Vert : +Blue: ColorControl Bleu : diff --git a/headers/private/libbe/LocaleBackend.h b/headers/private/libbe/LocaleBackend.h new file mode 100644 index 0000000000..d89353c265 --- /dev/null +++ b/headers/private/libbe/LocaleBackend.h @@ -0,0 +1,34 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _LOCALE_BACKEND_H +#define _LOCALE_BACKEND_H + + +#include + + +namespace BPrivate { + + +class LocaleBackend { +public: + LocaleBackend(); +virtual ~LocaleBackend(); + +virtual const char* GetString(const char* string, + const char* context = NULL, + const char* comment = NULL) = 0; + +static status_t LoadBackend(); +}; + + +extern LocaleBackend* gLocaleBackend; + + +} // namespace BPrivate + + +#endif // _LOCALE_BACKEND_H diff --git a/headers/private/locale/LibbeLocaleBackend.h b/headers/private/locale/LibbeLocaleBackend.h new file mode 100644 index 0000000000..67f11ea7cc --- /dev/null +++ b/headers/private/locale/LibbeLocaleBackend.h @@ -0,0 +1,32 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _LIBBE_LOCALE_BACKEND_H +#define _LIBBE_LOCALE_BACKEND_H + + +#include + +class BCatalogAddOn; + +namespace BPrivate { + + +class LibbeLocaleBackend : public LocaleBackend { +public: + LibbeLocaleBackend(); +virtual ~LibbeLocaleBackend(); + +virtual const char* GetString(const char* string, + const char* context = NULL, + const char* comment = NULL); +private: + BCatalogAddOn* systemCatalog; +}; + + +} // namespace BPrivate + + +#endif // _LIBBE_LOCALE_BACKEND_H diff --git a/src/kits/Jamfile b/src/kits/Jamfile index 2dfec9e13d..1c8e19ea31 100644 --- a/src/kits/Jamfile +++ b/src/kits/Jamfile @@ -19,6 +19,7 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 { UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h #UsePrivateHeaders syslog_daemon ; # For syslog.cpp +UsePrivateHeaders libbe ; # Build our libbe.so @@ -27,6 +28,7 @@ AddResources libbe.so : libbe_version.rdef ; SetVersionScript libbe.so : libbe_versions ; SharedLibrary libbe.so : + LocaleBackend.cpp : app_kit.o interface_kit.o diff --git a/src/kits/LocaleBackend.cpp b/src/kits/LocaleBackend.cpp new file mode 100644 index 0000000000..d255687eff --- /dev/null +++ b/src/kits/LocaleBackend.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ + + +#include "LocaleBackend.h" + +#include +#include +#include + +#include + + +namespace BPrivate { + + +LocaleBackend* gLocaleBackend = NULL; + + +static pthread_once_t sBackendInitOnce = PTHREAD_ONCE_INIT; + + +static void +LoadBackend() +{ + image_id libLocaleAddonID = load_add_on("/system/lib/liblocale.so"); +printf("backend-id: %ld\n", libLocaleAddonID); + if (libLocaleAddonID < 0) + return; + LocaleBackend* (*createInstanceFunc)(); + if (get_image_symbol(libLocaleAddonID, "CreateLocaleBackendInstance", + B_SYMBOL_TYPE_TEXT, (void**)&createInstanceFunc) != B_OK) + return; + +printf("invoking creator func\n"); + gLocaleBackend = createInstanceFunc(); +} + + +LocaleBackend::LocaleBackend() +{ +} + + +LocaleBackend::~LocaleBackend() +{ +} + + +status_t +LocaleBackend::LoadBackend() +{ + if (gLocaleBackend == NULL) + pthread_once(&sBackendInitOnce, &BPrivate::LoadBackend); + + return gLocaleBackend != NULL ? B_OK : B_ERROR; +} + + +} // namespace BPrivate diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 5b106852ed..d1b9478d53 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -23,9 +23,17 @@ #include #include +#include +#include +using BPrivate::gLocaleBackend; +using BPrivate::LocaleBackend; + #include +#undef TR_CONTEXT +#define TR_CONTEXT "ColorControl" + static const uint32 kMsgColorEntered = 'ccol'; static const uint32 kMinCellSize = 6; static const float kSelectorPenSize = 2.0f; @@ -68,6 +76,14 @@ void BColorControl::_InitData(color_control_layout layout, float size, bool useOffscreen, BMessage* archive) { + // we need to translate some strings, and in order to do so, we need + // to use the LocaleBackend to reache liblocale.so + if (gLocaleBackend == NULL) +{ +printf("trying to load backend\n"); + LocaleBackend::LoadBackend(); +printf("backend = %p\n", gLocaleBackend); +} fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8; //TODO: we don't support workspace and colorspace changing for now // so we take the main_screen colorspace at startup @@ -78,6 +94,15 @@ BColorControl::_InitData(color_control_layout layout, float size, fSelectedPaletteColorIndex = -1; fPreviousSelectedPaletteColorIndex = -1; fFocusedComponent = 0; + + const char* red = TR_MARK("Red:"); + const char* green = TR_MARK("Green:"); + const char* blue = TR_MARK("Blue:"); + if (gLocaleBackend) { + red = gLocaleBackend->GetString(red, "ColorControl"); + green = gLocaleBackend->GetString(green, "ColorControl"); + blue = gLocaleBackend->GetString(blue, "ColorControl"); + } if (archive) { fRedText = (BTextControl*)FindView("_red"); @@ -95,7 +120,7 @@ BColorControl::_InitData(color_control_layout layout, float size, // red - fRedText = new BTextControl(rect, "_red", "Red:", "0", + fRedText = new BTextControl(rect, "_red", red, "0", new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); fRedText->SetDivider(labelWidth); @@ -111,7 +136,7 @@ BColorControl::_InitData(color_control_layout layout, float size, // green rect.OffsetBy(0.0f, offset); - fGreenText = new BTextControl(rect, "_green", "Green:", "0", + fGreenText = new BTextControl(rect, "_green", green, "0", new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); fGreenText->SetDivider(labelWidth); @@ -125,7 +150,7 @@ BColorControl::_InitData(color_control_layout layout, float size, // blue rect.OffsetBy(0.0f, offset); - fBlueText = new BTextControl(rect, "_blue", "Blue:", "0", + fBlueText = new BTextControl(rect, "_blue", blue, "0", new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); fBlueText->SetDivider(labelWidth); diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index 2cad5dcd04..47b7581912 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -26,7 +26,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { SetSubDirSupportedPlatforms haiku libbe_test ; UseLibraryHeaders agg icon ; -UsePrivateHeaders app input print interface shared tracker ; +UsePrivateHeaders app input print interface libbe shared tracker ; SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index ac85fe83e9..d96d5a0ed9 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src kits locale ; -UsePrivateHeaders locale shared ; +UsePrivateHeaders libbe locale shared ; UsePublicHeaders locale storage ; UseLibraryHeaders icu ; @@ -24,6 +24,7 @@ SharedLibrary liblocale.so IntegerFormatParameters.cpp langinfo.cpp Language.cpp + LibbeLocaleBackend.cpp LibraryInit.cpp Locale.cpp LocaleRoster.cpp @@ -36,9 +37,13 @@ SharedLibrary liblocale.so : be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so ; +SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; +SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; + DoCatalogs liblocale.so : system - : ../shared/StringForSize.cpp + : StringForSize.cpp + ColorControl.cpp : - : '"systemCatalog\\s*->\\s*GetString\\s*"' + : '"(systemCatalog\\s*->\\s*GetString\\s*|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)"' ; diff --git a/src/kits/locale/LibbeLocaleBackend.cpp b/src/kits/locale/LibbeLocaleBackend.cpp new file mode 100644 index 0000000000..c9e8d292d8 --- /dev/null +++ b/src/kits/locale/LibbeLocaleBackend.cpp @@ -0,0 +1,45 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ + + +#include "LibbeLocaleBackend.h" + +#include "Catalog.h" +#include "Locale.h" +#include "LocaleRoster.h" + +#include + + +namespace BPrivate { + + +extern "C" LocaleBackend* +CreateLocaleBackendInstance() +{ + return new(std::nothrow) LibbeLocaleBackend(); +} + + +LibbeLocaleBackend::LibbeLocaleBackend() +{ + be_locale_roster->GetSystemCatalog(&systemCatalog); +} + + +LibbeLocaleBackend::~LibbeLocaleBackend() +{ +} + + +const char* +LibbeLocaleBackend::GetString(const char* string, const char* context, + const char* comment) +{ + return systemCatalog->GetString(string, context, comment); +} + + +} // namespace BPrivate