diff --git a/Jamfile b/Jamfile index 075ec4cac8..39bfc85ef9 100644 --- a/Jamfile +++ b/Jamfile @@ -113,7 +113,6 @@ Depends ScreenSaverKit : # TODO: src/add-ons/locale/collators/GermanDIN-2.cpp does not compile NotFile LocaleKit ; Depends LocaleKit : - liblocale.so Locale # binaries for building localized software on haiku diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index cf43dc5aaa..cd766ca0af 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -477,7 +477,7 @@ HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway # locale libraries -HAIKU_LOCALE_LIBS = liblocale.so liblocalestub.a ; +HAIKU_LOCALE_LIBS = liblocalestub.a ; # library and executable glue code @@ -904,6 +904,7 @@ if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) { [ FDirName $(HAIKU_TOP) headers build os drivers ] [ FDirName $(HAIKU_TOP) headers build os kernel ] [ FDirName $(HAIKU_TOP) headers build os interface ] + [ FDirName $(HAIKU_TOP) headers build os locale ] [ FDirName $(HAIKU_TOP) headers build os opengl ] [ FDirName $(HAIKU_TOP) headers build os storage ] [ FDirName $(HAIKU_TOP) headers build os support ] @@ -1067,7 +1068,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) && $(TARGET_PLATFORM_BEOS_COMPATIBLE) { if $(TARGET_PLATFORM) = libbe_test { # headers and flags TARGET_HDRS += - [ PublicHeaders $(DOT) app drivers game interface kernel storage + [ PublicHeaders $(DOT) app drivers game interface kernel locale storage support ] [ PrivateHeaders $(DOT) ] ; TARGET_DEFINES += __HAIKU__ ; diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index c0c5026324..639771409d 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -88,7 +88,6 @@ SYSTEM_LIBS = libdebug.so libdevice.so libgame.so $(X86_ONLY)libGL.so libgnu.so libjpeg.so - liblocale.so libmail.so libmedia.so libmidi.so libmidi2.so libnetwork.so libpng.so @@ -312,10 +311,22 @@ if $(TARGET_ARCH) = x86 { } } +# libbe.so now includes what used to be in liblocale.so +# TODO: Remove this once all optional packages have been rebuilt (i.e. after +# next release)! +SYSTEM_LIBS_LIBBE_ALIASES = liblocale.so ; +if $(TARGET_ARCH) = x86 { + local lib ; + for lib in $(SYSTEM_LIBS_LIBBE_ALIASES) { + AddSymlinkToHaikuHybridImage system lib : libbe.so : $(lib) : : true ; + } +} + SYSTEM_LIBS_ALIASES = $(SYSTEM_LIBS_LIBNETWORK_ALIASES) libnetapi.so $(SYSTEM_LIBS_LIBGL_ALIASES) + $(SYSTEM_LIBS_LIBBE_ALIASES) ; # libfreetype.so links to the current freetype lib diff --git a/headers/private/libbe/LocaleBackend.h b/headers/private/libbe/LocaleBackend.h deleted file mode 100644 index d89353c265..0000000000 --- a/headers/private/libbe/LocaleBackend.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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 deleted file mode 100644 index 67f11ea7cc..0000000000 --- a/headers/private/locale/LibbeLocaleBackend.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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/headers/private/locale/SystemCatalog.h b/headers/private/locale/SystemCatalog.h new file mode 100644 index 0000000000..ef0708e944 --- /dev/null +++ b/headers/private/locale/SystemCatalog.h @@ -0,0 +1,18 @@ +/* + * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSTEM_CATALOG_H_ +#define _SYSTEM_CATALOG_H_ + + +#include + +namespace BPrivate { + +extern BCatalogAddOn* gSystemCatalog; + +} // namespace BPrivate + + +#endif // _SYSTEM_CATALOG_H_ diff --git a/src/add-ons/locale/catalogs/plaintext/Jamfile b/src/add-ons/locale/catalogs/plaintext/Jamfile index 7476b60ec4..4bee8a1fc3 100644 --- a/src/add-ons/locale/catalogs/plaintext/Jamfile +++ b/src/add-ons/locale/catalogs/plaintext/Jamfile @@ -5,5 +5,5 @@ UsePrivateHeaders locale shared ; Addon plaintext : Catalog.cpp - : be $(TARGET_LIBSTDC++) liblocale.so + : be $(TARGET_LIBSTDC++) ; diff --git a/src/add-ons/locale/catalogs/zeta/Jamfile b/src/add-ons/locale/catalogs/zeta/Jamfile index e6c9edf543..c02cecb084 100644 --- a/src/add-ons/locale/catalogs/zeta/Jamfile +++ b/src/add-ons/locale/catalogs/zeta/Jamfile @@ -4,5 +4,5 @@ UsePublicHeaders locale ; Addon zeta : Catalog.cpp - : be liblocale.so $(TARGET_LIBSUPC++) + : be $(TARGET_LIBSUPC++) ; diff --git a/src/add-ons/locale/collators/Jamfile b/src/add-ons/locale/collators/Jamfile index b90c300bd4..0919466f94 100644 --- a/src/add-ons/locale/collators/Jamfile +++ b/src/add-ons/locale/collators/Jamfile @@ -12,11 +12,11 @@ Depends LocaleKitCollatorAddons Addon GermanDIN-2 : GermanDIN-2.cpp - : be liblocale.so $(TARGET_LIBSUPC++) + : be $(TARGET_LIBSUPC++) ; Addon French : French.cpp - : be liblocale.so $(TARGET_LIBSUPC++) + : be $(TARGET_LIBSUPC++) ; diff --git a/src/add-ons/translators/raw/Jamfile b/src/add-ons/translators/raw/Jamfile index d922c7842f..0fe5a72d05 100644 --- a/src/add-ons/translators/raw/Jamfile +++ b/src/add-ons/translators/raw/Jamfile @@ -12,10 +12,11 @@ Translator RAWTranslator : RAWTranslator.cpp ConfigView.cpp RAW.cpp - : be locale translation libtranslatorsutils.a -$(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) + : + be translation libtranslatorsutils.a $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) - : true + : + true ; DoCatalogs RAWTranslator : @@ -28,5 +29,6 @@ DoCatalogs RAWTranslator : Package haiku-translationkit-cvs : RAWTranslator - : boot home config add-ons Translators + : + boot home config add-ons Translators ; diff --git a/src/apps/charactermap/Jamfile b/src/apps/charactermap/Jamfile index 90c728bd96..194b0e2754 100644 --- a/src/apps/charactermap/Jamfile +++ b/src/apps/charactermap/Jamfile @@ -11,7 +11,7 @@ Application CharacterMap : UnicodeBlocks.cpp UnicodeBlockView.cpp - : be locale $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) + : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : CharacterMap.rdef ; diff --git a/src/apps/mediaplayer/Jamfile b/src/apps/mediaplayer/Jamfile index c9f9e7096c..23a3bd0ea2 100644 --- a/src/apps/mediaplayer/Jamfile +++ b/src/apps/mediaplayer/Jamfile @@ -114,7 +114,7 @@ Application MediaPlayer : MainWin.cpp VideoView.cpp - : be game locale media tracker translation textencoding $(TARGET_LIBSTDC++) + : be game media tracker translation textencoding $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS) libshared.a : MediaPlayer.rdef ; diff --git a/src/bin/Jamfile b/src/bin/Jamfile index 6c099aa8d5..c6b83559b6 100644 --- a/src/bin/Jamfile +++ b/src/bin/Jamfile @@ -81,6 +81,7 @@ StdBinCommands catattr.cpp checkfs.cpp clipboard.cpp + clockconfig.cpp df.cpp diskimage.cpp dpms.cpp @@ -96,6 +97,7 @@ StdBinCommands modifiers.cpp open.cpp play.cpp + query.cpp quit.cpp roster.cpp setversion.cpp @@ -123,13 +125,13 @@ StdBinCommands urlwrapper.cpp : be $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ; -# commands that need libbe.so and liblocale.so +# commands that need libbe.so and the stub catalog StdBinCommands clockconfig.cpp query.cpp : be $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; -# commands that need libbe.so, libsupc++.so and liblocale.so +# commands that need libbe.so, libsupc++.so and the stub catalog StdBinCommands dstcheck.cpp : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; @@ -212,7 +214,7 @@ StdBinCommands checkitout.cpp : be tracker $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ; -#standard commands that need libbe.so, libtracker.so, liblocale.so +#standard commands that need libbe.so, libtracker.so and the stub catalog StdBinCommands filepanel.cpp : be tracker $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; diff --git a/src/bin/locale/Jamfile b/src/bin/locale/Jamfile index 82594c7f1c..af63c66a51 100644 --- a/src/bin/locale/Jamfile +++ b/src/bin/locale/Jamfile @@ -6,10 +6,10 @@ UsePublicHeaders locale ; UsePrivateHeaders locale shared ; BinCommand collectcatkeys : collectcatkeys.cpp RegExp.cpp - : be liblocale.so $(TARGET_LIBSUPC++) ; + : be $(TARGET_LIBSUPC++) ; -BinCommand linkcatkeys : linkcatkeys.cpp : be liblocale.so $(TARGET_LIBSTDC++) ; +BinCommand linkcatkeys : linkcatkeys.cpp : be $(TARGET_LIBSTDC++) ; -BinCommand dumpcatalog : dumpcatalog.cpp : be liblocale.so $(TARGET_LIBSUPC++) ; +BinCommand dumpcatalog : dumpcatalog.cpp : be $(TARGET_LIBSUPC++) ; -BinCommand locale : locale.cpp : be liblocale.so $(TARGET_LIBSUPC++) ; +BinCommand locale : locale.cpp : be $(TARGET_LIBSUPC++) ; diff --git a/src/kits/locale/CountryFlags.rdef b/src/kits/CountryFlags.rdef similarity index 100% rename from src/kits/locale/CountryFlags.rdef rename to src/kits/CountryFlags.rdef diff --git a/src/kits/Jamfile b/src/kits/Jamfile index 41da18a889..9ddc9117c3 100644 --- a/src/kits/Jamfile +++ b/src/kits/Jamfile @@ -19,19 +19,20 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 { UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h #UsePrivateHeaders syslog_daemon ; # For syslog.cpp -UsePrivateHeaders libbe ; # Build our libbe.so -AddResources libbe.so : libbe_version.rdef ; +AddResources libbe.so : + libbe_version.rdef CountryFlags.rdef LanguageFlags.rdef +; + SetVersionScript libbe.so : libbe_versions ; -SharedLibrary libbe.so : - LocaleBackend.cpp - : +SharedLibrary libbe.so : : app_kit.o interface_kit.o + locale_kit.o storage_kit.o support_kit.o @@ -39,7 +40,7 @@ SharedLibrary libbe.so : libagg.a libroot.so # make sure it links against our libroot.so - $(TARGET_LIBSTDC++) + $(TARGET_LIBSTDC++) $(HAIKU_ICU_LIBS) ; # Build libbe_test.so @@ -62,6 +63,30 @@ SharedLibrary libbe_test.so : $(TARGET_LIBSTDC++) ; +SEARCH on [ FGristFiles AboutMenuItem.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; +SEARCH on [ FGristFiles AboutWindow.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; +SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; +SEARCH on [ FGristFiles TextView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles Dragger.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles Menu.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles PrintJob.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; +SEARCH on [ FGristFiles ZombieReplicantView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; + +DoCatalogs libbe.so + : x-vnd.Haiku-libbe + : + AboutMenuItem.cpp + AboutWindow.cpp + ColorControl.cpp + Dragger.cpp + Menu.cpp + PrintJob.cpp + StringForSize.cpp + TextView.cpp + ZombieReplicantView.cpp + ; + #SEARCH on [ FGristFiles KMessage.cpp ] # = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ; # diff --git a/src/kits/locale/LanguageFlags.rdef b/src/kits/LanguageFlags.rdef similarity index 100% rename from src/kits/locale/LanguageFlags.rdef rename to src/kits/LanguageFlags.rdef diff --git a/src/kits/LocaleBackend.cpp b/src/kits/LocaleBackend.cpp deleted file mode 100644 index 7fda14a5f6..0000000000 --- a/src/kits/LocaleBackend.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. - * Distributed under the terms of the MIT License. - */ - - -#include "LocaleBackend.h" - -#include -#include -#include -#include - -#include - - -namespace BPrivate { - - -LocaleBackend* gLocaleBackend = NULL; - - -static pthread_once_t sBackendInitOnce = PTHREAD_ONCE_INIT; - - -static void -LoadBackend() -{ - void* imageHandle = dlopen("liblocale.so", RTLD_LAZY); - if (imageHandle == NULL) - return; - - typedef LocaleBackend* (*symbolType)(); - symbolType createInstanceFunc = (symbolType)dlsym(imageHandle, - "CreateLocaleBackendInstance"); - if (createInstanceFunc == NULL) - return; - - 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/app/InitTerminateLibBe.cpp b/src/kits/app/InitTerminateLibBe.cpp index 6d5b017523..469e270498 100644 --- a/src/kits/app/InitTerminateLibBe.cpp +++ b/src/kits/app/InitTerminateLibBe.cpp @@ -18,6 +18,9 @@ #include +extern void __initialize_locale_kit(); + + // debugging //#define DBG(x) x #define DBG(x) @@ -56,6 +59,8 @@ initialize_after() { DBG(OUT("initialize_after()\n")); + __initialize_locale_kit(); + DBG(OUT("initialize_after() done\n")); } diff --git a/src/kits/app/Jamfile b/src/kits/app/Jamfile index 1f01a00d89..1aec0536d7 100644 --- a/src/kits/app/Jamfile +++ b/src/kits/app/Jamfile @@ -18,7 +18,7 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 { } UseLibraryHeaders icon ; -UsePrivateHeaders shared app interface kernel notification ; +UsePrivateHeaders shared app interface kernel locale notification ; UsePrivateSystemHeaders ; SetSubDirSupportedPlatforms haiku libbe_test ; diff --git a/src/kits/interface/ColorControl.cpp b/src/kits/interface/ColorControl.cpp index 00659bddca..47bf460817 100644 --- a/src/kits/interface/ColorControl.cpp +++ b/src/kits/interface/ColorControl.cpp @@ -23,12 +23,10 @@ #include #include #include +#include #include -#include -#include -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #include @@ -78,11 +76,6 @@ 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) - LocaleBackend::LoadBackend(); - 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 @@ -97,11 +90,9 @@ BColorControl::_InitData(color_control_layout layout, float size, const char* red = B_TRANSLATE_MARK("Red:"); const char* green = B_TRANSLATE_MARK("Green:"); const char* blue = B_TRANSLATE_MARK("Blue:"); - if (gLocaleBackend) { - red = gLocaleBackend->GetString(red, "ColorControl"); - green = gLocaleBackend->GetString(green, "ColorControl"); - blue = gLocaleBackend->GetString(blue, "ColorControl"); - } + red = gSystemCatalog->GetString(red, "ColorControl"); + green = gSystemCatalog->GetString(green, "ColorControl"); + blue = gSystemCatalog->GetString(blue, "ColorControl"); if (archive) { fRedText = (BTextControl*)FindView("_red"); diff --git a/src/kits/interface/Dragger.cpp b/src/kits/interface/Dragger.cpp index ee714e58b8..374b312cee 100644 --- a/src/kits/interface/Dragger.cpp +++ b/src/kits/interface/Dragger.cpp @@ -18,13 +18,12 @@ #include #include #include -#include #include -#include #include #include #include #include +#include #include #include @@ -37,15 +36,14 @@ #include "ZombieReplicantView.h" -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "Dragger" #undef B_TRANSLATE #define B_TRANSLATE(str) \ - gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Dragger") + gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Dragger") const uint32 kMsgDragStarted = 'Drgs'; @@ -629,11 +627,6 @@ BDragger::_InitData() { fBitmap = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false); fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); - - // we need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); } diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index aa214c9521..81c59e0b32 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -25,7 +25,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { SetSubDirSupportedPlatforms haiku libbe_test ; UseLibraryHeaders agg ; -UsePrivateHeaders app input print interface libbe shared support tracker ; +UsePrivateHeaders app input print interface locale shared support tracker ; UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ; diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp index 24a5e5ba36..9055ce77f8 100644 --- a/src/kits/interface/Menu.cpp +++ b/src/kits/interface/Menu.cpp @@ -17,14 +17,12 @@ #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -32,6 +30,7 @@ #include #include #include +#include #include #include @@ -46,15 +45,14 @@ #define USE_CACHED_MENUWINDOW 1 -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "Menu" #undef B_TRANSLATE #define B_TRANSLATE(str) \ - gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Menu") + gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Menu") using std::nothrow; @@ -1429,11 +1427,6 @@ void BMenu::_ReservedMenu6() {} void BMenu::_InitData(BMessage* archive) { - // we need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); - BPrivate::kEmptyMenuLabel = B_TRANSLATE(""); // TODO: Get _color, _fname, _fflt from the message, if present diff --git a/src/kits/interface/PrintJob.cpp b/src/kits/interface/PrintJob.cpp index ad761779aa..6a884f97d2 100644 --- a/src/kits/interface/PrintJob.cpp +++ b/src/kits/interface/PrintJob.cpp @@ -19,32 +19,30 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "PrintJob" #undef B_TRANSLATE #define B_TRANSLATE(str) \ - gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "PrintJob") + gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "PrintJob") /*! Summary of spool file: @@ -170,11 +168,6 @@ BPrintJob::BPrintJob(const char* jobName) fCurrentPageHeader = new _page_header_; if (fCurrentPageHeader != NULL) memset(fCurrentPageHeader, 0, sizeof(_page_header_)); - - // we need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); } diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index d25034d815..b933443509 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -54,21 +55,17 @@ #include "UndoBuffer.h" #include "WidthBuffer.h" -#include -#include - using namespace std; -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "TextView" -#define TRANSLATE(str) gLocaleBackend->GetString(B_TRANSLATE_MARK(str), \ - "TextView") +#define TRANSLATE(str) \ + gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "TextView") #undef TRACE #undef CALLED @@ -3256,11 +3253,6 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont, fLastClickOffset = -1; SetDoesUndo(true); - - // We need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); } @@ -5562,7 +5554,7 @@ BTextView::_ShowContextMenu(BPoint where) int32 start; int32 finish; GetSelection(&start, &finish); - + bool canEdit = IsEditable(); int32 length = TextLength(); diff --git a/src/kits/interface/ZombieReplicantView.cpp b/src/kits/interface/ZombieReplicantView.cpp index ba7c772455..de908447f0 100644 --- a/src/kits/interface/ZombieReplicantView.cpp +++ b/src/kits/interface/ZombieReplicantView.cpp @@ -7,11 +7,10 @@ */ #include -#include -#include #include #include #include +#include #include "ZombieReplicantView.h" @@ -20,15 +19,14 @@ #include #include -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "ZombieReplicantView" #undef B_TRANSLATE #define B_TRANSLATE(str) \ - gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView") + gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "ZombieReplicantView") _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error) @@ -40,11 +38,6 @@ _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error) font.SetSize(9.0f); // TODO SetFont(&font); SetViewColor(kZombieColor); - - // we need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); } @@ -62,7 +55,7 @@ _BZombieReplicantView_::MessageReceived(BMessage* msg) const char* addOn = NULL; BString error; if (fArchive->FindString("add_on", &addOn) == B_OK) { - char description[B_MIME_TYPE_LENGTH] = ""; + char description[B_MIME_TYPE_LENGTH] = ""; BMimeType type(addOn); type.GetShortDescription(description); error = B_TRANSLATE("Cannot create the replicant for " @@ -71,9 +64,9 @@ _BZombieReplicantView_::MessageReceived(BMessage* msg) } else error = B_TRANSLATE("Cannot locate the application for the " "replicant. No application signature supplied.\n%error"); - + error.ReplaceFirst("%error", strerror(fError)); - + BAlert* alert = new (std::nothrow) BAlert(B_TRANSLATE("Error"), error.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); @@ -113,7 +106,7 @@ status_t _BZombieReplicantView_::Archive(BMessage* archive, bool) const { *archive = *fArchive; - + return B_OK; } diff --git a/src/kits/locale/LibraryInit.cpp b/src/kits/locale/InitLocaleKit.cpp similarity index 94% rename from src/kits/locale/LibraryInit.cpp rename to src/kits/locale/InitLocaleKit.cpp index 68fc0b2cfe..ac246844f8 100644 --- a/src/kits/locale/LibraryInit.cpp +++ b/src/kits/locale/InitLocaleKit.cpp @@ -10,8 +10,17 @@ #include #include -#include #include +#include +#include + + +namespace BPrivate { + +BCatalogAddOn* gSystemCatalog; + +} + // helper function that makes sure an attribute-index exists: static void EnsureIndexExists(const char *attrName) @@ -115,9 +124,10 @@ SetupCatalogBasics() } -extern "C" void -initialize_after() +__initialize_locale_kit() { SetupCatalogBasics(); + + MutableLocaleRoster::Default()->GetSystemCatalog(&BPrivate::gSystemCatalog); } diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index 41a1f82fe4..87430d962e 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -2,7 +2,7 @@ SubDir HAIKU_TOP src kits locale ; AddSubDirSupportedPlatforms libbe_test ; -UsePrivateHeaders libbe locale shared ; +UsePrivateHeaders locale shared ; UsePublicHeaders locale storage ; local sources = @@ -13,9 +13,8 @@ local sources = DefaultCatalog.cpp FormattingConventions.cpp HashMapCatalog.cpp + InitLocaleKit.cpp Language.cpp - LibbeLocaleBackend.cpp - LibraryInit.cpp Locale.cpp LocaleRoster.cpp MutableLocaleRoster.cpp @@ -52,37 +51,10 @@ Includes [ FGristFiles $(sources) ] : $(HAIKU_ICU_HEADERS_DEPENDENCY) ; # Dependency needed to trigger downloading/unzipping the package before # compiling the files. -AddResources liblocale.so : CountryFlags.rdef LanguageFlags.rdef ; - -SharedLibrary liblocale.so - : $(sources) - : be $(TARGET_LIBSTDC++) $(HAIKU_ICU_LIBS) +MergeObject locale_kit.o : + $(sources) ; StaticLibrary liblocalestub.a : CatalogStub.cpp ; - -SEARCH on [ FGristFiles AboutMenuItem.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; -SEARCH on [ FGristFiles AboutWindow.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; -SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; -SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ; -SEARCH on [ FGristFiles TextView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; -SEARCH on [ FGristFiles Dragger.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; -SEARCH on [ FGristFiles Menu.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; -SEARCH on [ FGristFiles PrintJob.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; -SEARCH on [ FGristFiles ZombieReplicantView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ; - -DoCatalogs liblocale.so - : x-vnd.Haiku-libbe - : - AboutMenuItem.cpp - AboutWindow.cpp - ColorControl.cpp - Dragger.cpp - Menu.cpp - PrintJob.cpp - StringForSize.cpp - TextView.cpp - ZombieReplicantView.cpp - ; diff --git a/src/kits/locale/LibbeLocaleBackend.cpp b/src/kits/locale/LibbeLocaleBackend.cpp deleted file mode 100644 index 9953b4fa5b..0000000000 --- a/src/kits/locale/LibbeLocaleBackend.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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 "MutableLocaleRoster.h" - -#include - - -namespace BPrivate { - - -extern "C" LocaleBackend* -CreateLocaleBackendInstance() -{ - return new(std::nothrow) LibbeLocaleBackend(); -} - - -LibbeLocaleBackend::LibbeLocaleBackend() -{ - MutableLocaleRoster::Default()->GetSystemCatalog(&systemCatalog); -} - - -LibbeLocaleBackend::~LibbeLocaleBackend() -{ -} - - -const char* -LibbeLocaleBackend::GetString(const char* string, const char* context, - const char* comment) -{ - // The system catalog will not be there for non-localized apps. - if (systemCatalog) { - const char *translated = systemCatalog->GetString(string, context, comment); - if (translated) - return translated; - } - return string; -} - - -} // namespace BPrivate diff --git a/src/kits/shared/AboutMenuItem.cpp b/src/kits/shared/AboutMenuItem.cpp index 6d00cddc14..3b4f45fbd9 100644 --- a/src/kits/shared/AboutMenuItem.cpp +++ b/src/kits/shared/AboutMenuItem.cpp @@ -10,14 +10,11 @@ #include #include -#include -#include #include #include +#include - -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT @@ -33,15 +30,8 @@ BAboutMenuItem::BAboutMenuItem() if (be_app != NULL && be_app->GetAppInfo(&info) == B_OK) name = B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(info.ref.name); - // we need to translate some strings, and in order to do so, we need - // to use the LocaleBackend to reach liblocale.so - if (gLocaleBackend == NULL) - LocaleBackend::LoadBackend(); - const char* string = B_TRANSLATE_MARK("About %app%"); - if (gLocaleBackend) { - string = gLocaleBackend->GetString(string, "AboutMenuItem"); - } + string = gSystemCatalog->GetString(string, "AboutMenuItem"); BString label = string; if (name != NULL) diff --git a/src/kits/shared/AboutWindow.cpp b/src/kits/shared/AboutWindow.cpp index 56548409d8..6c84a0f4be 100644 --- a/src/kits/shared/AboutWindow.cpp +++ b/src/kits/shared/AboutWindow.cpp @@ -14,12 +14,10 @@ #include #include #include +#include #include -#include -#include -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT @@ -31,17 +29,11 @@ BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear, { fAppName = new BString(appName); - // 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) - LocaleBackend::LoadBackend(); - - const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT " %years% Haiku, Inc."); + const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT + " %years% Haiku, Inc."); const char* writtenBy = B_TRANSLATE_MARK("Written by:"); - if (gLocaleBackend) { - copyright = gLocaleBackend->GetString(copyright, "AboutWindow"); - writtenBy = gLocaleBackend->GetString(writtenBy, "AboutWindow"); - } + copyright = gSystemCatalog->GetString(copyright, "AboutWindow"); + writtenBy = gSystemCatalog->GetString(writtenBy, "AboutWindow"); // Get current year time_t tp; @@ -85,10 +77,8 @@ BAboutWindow::Show() { const char* aboutTitle = B_TRANSLATE_MARK("About" B_UTF8_ELLIPSIS); const char* closeLabel = B_TRANSLATE_MARK("Close"); - if (gLocaleBackend) { - aboutTitle = gLocaleBackend->GetString(aboutTitle, "AboutWindow"); - closeLabel = gLocaleBackend->GetString(closeLabel, "AboutWindow"); - } + aboutTitle = gSystemCatalog->GetString(aboutTitle, "AboutWindow"); + closeLabel = gSystemCatalog->GetString(closeLabel, "AboutWindow"); BAlert *alert = new BAlert(aboutTitle, fText->String(), closeLabel); BTextView *view = alert->TextView(); diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index d9ced4eaeb..109df80924 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -4,7 +4,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ; AddSubDirSupportedPlatforms libbe_test ; UseLibraryHeaders agg ; -UsePrivateHeaders shared libbe ; +UsePrivateHeaders shared locale ; UseHeaders [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR) servers input ] ; UseHeaders [ FDirName $(HAIKU_TOP) src kits ] ; diff --git a/src/kits/shared/StringForSize.cpp b/src/kits/shared/StringForSize.cpp index 32cb1dd121..2517203df1 100644 --- a/src/kits/shared/StringForSize.cpp +++ b/src/kits/shared/StringForSize.cpp @@ -7,10 +7,9 @@ #include -#include -#include -using BPrivate::gLocaleBackend; -using BPrivate::LocaleBackend; +#include + +using BPrivate::gSystemCatalog; #undef B_TRANSLATE_CONTEXT @@ -23,40 +22,36 @@ namespace BPrivate { const char* string_for_size(double size, char* string, size_t stringSize) { - // 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) - LocaleBackend::LoadBackend(); double kib = size / 1024.0; if (kib < 1.0) { const char* trKey = B_TRANSLATE_MARK("%d bytes"); - snprintf(string, stringSize, gLocaleBackend->GetString(trKey, + snprintf(string, stringSize, gSystemCatalog->GetString(trKey, B_TRANSLATE_CONTEXT), (int)size); return string; } double mib = kib / 1024.0; if (mib < 1.0) { const char* trKey = B_TRANSLATE_MARK("%3.2f KiB"); - snprintf(string, stringSize, gLocaleBackend->GetString(trKey, + snprintf(string, stringSize, gSystemCatalog->GetString(trKey, B_TRANSLATE_CONTEXT), kib); return string; } double gib = mib / 1024.0; if (gib < 1.0) { const char* trKey = B_TRANSLATE_MARK("%3.2f MiB"); - snprintf(string, stringSize, gLocaleBackend->GetString(trKey, + snprintf(string, stringSize, gSystemCatalog->GetString(trKey, B_TRANSLATE_CONTEXT), mib); return string; } double tib = gib / 1024.0; if (tib < 1.0) { const char* trKey = B_TRANSLATE_MARK("%3.2f GiB"); - snprintf(string, stringSize, gLocaleBackend->GetString(trKey, + snprintf(string, stringSize, gSystemCatalog->GetString(trKey, B_TRANSLATE_CONTEXT), gib); return string; } const char* trKey = B_TRANSLATE_MARK("%.2f TiB"); - snprintf(string, stringSize, gLocaleBackend->GetString(trKey, + snprintf(string, stringSize, gSystemCatalog->GetString(trKey, B_TRANSLATE_CONTEXT), tib); return string; } diff --git a/src/tests/kits/locale/Jamfile b/src/tests/kits/locale/Jamfile index e430b0cbc9..ce8092e101 100644 --- a/src/tests/kits/locale/Jamfile +++ b/src/tests/kits/locale/Jamfile @@ -22,7 +22,7 @@ rule LocaleTest # LocaleTest ; local sources = $(1) ; local name = $(sources[1]:B) ; - Application $(name) : $(sources) : be liblocale.so $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; + Application $(name) : $(sources) : be $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) ; } LocaleTest catalogSpeed.cpp ; @@ -44,7 +44,7 @@ Application ICUTest : Addon catalogTestAddOn : catalogTestAddOn.cpp - : be liblocale.so + : be ; SubInclude HAIKU_TOP src tests kits locale number_format ; diff --git a/src/tests/kits/locale/number_format/Jamfile b/src/tests/kits/locale/number_format/Jamfile index d4d28cd0fb..cb71edcc2d 100644 --- a/src/tests/kits/locale/number_format/Jamfile +++ b/src/tests/kits/locale/number_format/Jamfile @@ -11,5 +11,5 @@ UnitTestLib libNumberFormatTests.so GenericNumberFormatTests.cpp GenericNumberFormatConstructorTest.cpp - : be $(TARGET_LIBSTDC++) liblocale.so + : be $(TARGET_LIBSTDC++) ;