Merge liblocale.so into libbe.so.

* Make the locale kit a part of libbe.
* Drop the LocaleBackend kludge used from within libbe (and from
  other places, too) in order to access system catalog strings. 
  This is now done via gSystemCatalog, which is provided and initialized
  by libbe.
* Drop all references to liblocale.so from all Jamfiles.
* Add legacy symlink liblocale.so in order to keep optional packages
  that rely on it in a working state.

TODO: the documentation hasn't been updated.
This commit is contained in:
Oliver Tappe
2012-04-04 22:44:42 +02:00
parent 06114afc50
commit 60f75e901c
36 changed files with 158 additions and 363 deletions
-1
View File
@@ -113,7 +113,6 @@ Depends ScreenSaverKit :
# TODO: src/add-ons/locale/collators/GermanDIN-2.cpp does not compile # TODO: src/add-ons/locale/collators/GermanDIN-2.cpp does not compile
NotFile LocaleKit ; NotFile LocaleKit ;
Depends LocaleKit : Depends LocaleKit :
liblocale.so
Locale Locale
# binaries for building localized software on haiku # binaries for building localized software on haiku
+3 -2
View File
@@ -477,7 +477,7 @@ HAIKU_SELECT_UNAME_ETC_LIB = ; # libroot, against which we link anyway
# locale libraries # locale libraries
HAIKU_LOCALE_LIBS = liblocale.so liblocalestub.a ; HAIKU_LOCALE_LIBS = liblocalestub.a ;
# library and executable glue code # 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 drivers ]
[ FDirName $(HAIKU_TOP) headers build os kernel ] [ FDirName $(HAIKU_TOP) headers build os kernel ]
[ FDirName $(HAIKU_TOP) headers build os interface ] [ 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 opengl ]
[ FDirName $(HAIKU_TOP) headers build os storage ] [ FDirName $(HAIKU_TOP) headers build os storage ]
[ FDirName $(HAIKU_TOP) headers build os support ] [ 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 { if $(TARGET_PLATFORM) = libbe_test {
# headers and flags # headers and flags
TARGET_HDRS += TARGET_HDRS +=
[ PublicHeaders $(DOT) app drivers game interface kernel storage [ PublicHeaders $(DOT) app drivers game interface kernel locale storage
support ] support ]
[ PrivateHeaders $(DOT) ] ; [ PrivateHeaders $(DOT) ] ;
TARGET_DEFINES += __HAIKU__ ; TARGET_DEFINES += __HAIKU__ ;
+12 -1
View File
@@ -88,7 +88,6 @@ SYSTEM_LIBS =
libdebug.so libdevice.so libdebug.so libdevice.so
libgame.so $(X86_ONLY)libGL.so libgnu.so libgame.so $(X86_ONLY)libGL.so libgnu.so
libjpeg.so libjpeg.so
liblocale.so
libmail.so libmedia.so libmidi.so libmidi2.so libmail.so libmedia.so libmidi.so libmidi2.so
libnetwork.so libnetwork.so
libpng.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_ALIASES =
$(SYSTEM_LIBS_LIBNETWORK_ALIASES) $(SYSTEM_LIBS_LIBNETWORK_ALIASES)
libnetapi.so libnetapi.so
$(SYSTEM_LIBS_LIBGL_ALIASES) $(SYSTEM_LIBS_LIBGL_ALIASES)
$(SYSTEM_LIBS_LIBBE_ALIASES)
; ;
# libfreetype.so links to the current freetype lib # libfreetype.so links to the current freetype lib
-34
View File
@@ -1,34 +0,0 @@
/*
* Copyright 2010, Oliver Tappe, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _LOCALE_BACKEND_H
#define _LOCALE_BACKEND_H
#include <SupportDefs.h>
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
@@ -1,32 +0,0 @@
/*
* Copyright 2010, Oliver Tappe, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _LIBBE_LOCALE_BACKEND_H
#define _LIBBE_LOCALE_BACKEND_H
#include <LocaleBackend.h>
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
+18
View File
@@ -0,0 +1,18 @@
/*
* Copyright 2010, Oliver Tappe, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_CATALOG_H_
#define _SYSTEM_CATALOG_H_
#include <Catalog.h>
namespace BPrivate {
extern BCatalogAddOn* gSystemCatalog;
} // namespace BPrivate
#endif // _SYSTEM_CATALOG_H_
@@ -5,5 +5,5 @@ UsePrivateHeaders locale shared ;
Addon <catalog-addon>plaintext Addon <catalog-addon>plaintext
: Catalog.cpp : Catalog.cpp
: be $(TARGET_LIBSTDC++) liblocale.so : be $(TARGET_LIBSTDC++)
; ;
+1 -1
View File
@@ -4,5 +4,5 @@ UsePublicHeaders locale ;
Addon <catalog-addon>zeta Addon <catalog-addon>zeta
: Catalog.cpp : Catalog.cpp
: be liblocale.so $(TARGET_LIBSUPC++) : be $(TARGET_LIBSUPC++)
; ;
+2 -2
View File
@@ -12,11 +12,11 @@ Depends LocaleKitCollatorAddons
Addon <collator-addon>GermanDIN-2 Addon <collator-addon>GermanDIN-2
: GermanDIN-2.cpp : GermanDIN-2.cpp
: be liblocale.so $(TARGET_LIBSUPC++) : be $(TARGET_LIBSUPC++)
; ;
Addon <collator-addon>French Addon <collator-addon>French
: French.cpp : French.cpp
: be liblocale.so $(TARGET_LIBSUPC++) : be $(TARGET_LIBSUPC++)
; ;
+6 -4
View File
@@ -12,10 +12,11 @@ Translator RAWTranslator :
RAWTranslator.cpp RAWTranslator.cpp
ConfigView.cpp ConfigView.cpp
RAW.cpp RAW.cpp
: be locale translation libtranslatorsutils.a :
$(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) be translation libtranslatorsutils.a $(TARGET_LIBSUPC++)
$(HAIKU_LOCALE_LIBS) $(HAIKU_LOCALE_LIBS)
: true :
true
; ;
DoCatalogs RAWTranslator : DoCatalogs RAWTranslator :
@@ -28,5 +29,6 @@ DoCatalogs RAWTranslator :
Package haiku-translationkit-cvs : Package haiku-translationkit-cvs :
RAWTranslator RAWTranslator
: boot home config add-ons Translators :
boot home config add-ons Translators
; ;
+1 -1
View File
@@ -11,7 +11,7 @@ Application CharacterMap :
UnicodeBlocks.cpp UnicodeBlocks.cpp
UnicodeBlockView.cpp UnicodeBlockView.cpp
: be locale $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS)
: CharacterMap.rdef : CharacterMap.rdef
; ;
+1 -1
View File
@@ -114,7 +114,7 @@ Application MediaPlayer :
MainWin.cpp MainWin.cpp
VideoView.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 $(HAIKU_LOCALE_LIBS) libshared.a
: MediaPlayer.rdef : MediaPlayer.rdef
; ;
+5 -3
View File
@@ -81,6 +81,7 @@ StdBinCommands
catattr.cpp catattr.cpp
checkfs.cpp checkfs.cpp
clipboard.cpp clipboard.cpp
clockconfig.cpp
df.cpp df.cpp
diskimage.cpp diskimage.cpp
dpms.cpp dpms.cpp
@@ -96,6 +97,7 @@ StdBinCommands
modifiers.cpp modifiers.cpp
open.cpp open.cpp
play.cpp play.cpp
query.cpp
quit.cpp quit.cpp
roster.cpp roster.cpp
setversion.cpp setversion.cpp
@@ -123,13 +125,13 @@ StdBinCommands
urlwrapper.cpp urlwrapper.cpp
: be $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ; : be $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ;
# commands that need libbe.so and liblocale.so # commands that need libbe.so and the stub catalog
StdBinCommands StdBinCommands
clockconfig.cpp clockconfig.cpp
query.cpp query.cpp
: be $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; : 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 StdBinCommands
dstcheck.cpp dstcheck.cpp
: be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; : be $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ;
@@ -212,7 +214,7 @@ StdBinCommands
checkitout.cpp checkitout.cpp
: be tracker $(TARGET_LIBSUPC++) : $(haiku-utils_rsrc) ; : 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 StdBinCommands
filepanel.cpp filepanel.cpp
: be tracker $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ; : be tracker $(TARGET_LIBSUPC++) $(HAIKU_LOCALE_LIBS) : $(haiku-utils_rsrc) ;
+4 -4
View File
@@ -6,10 +6,10 @@ UsePublicHeaders locale ;
UsePrivateHeaders locale shared ; UsePrivateHeaders locale shared ;
BinCommand collectcatkeys : collectcatkeys.cpp RegExp.cpp 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++) ;
+31 -6
View File
@@ -19,19 +19,20 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 {
UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h
#UsePrivateHeaders syslog_daemon ; # For syslog.cpp #UsePrivateHeaders syslog_daemon ; # For syslog.cpp
UsePrivateHeaders libbe ;
# Build our libbe.so # 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 ; SetVersionScript libbe.so : libbe_versions ;
SharedLibrary libbe.so : SharedLibrary libbe.so : :
LocaleBackend.cpp
:
<libbe>app_kit.o <libbe>app_kit.o
<libbe>interface_kit.o <libbe>interface_kit.o
<libbe>locale_kit.o
<libbe>storage_kit.o <libbe>storage_kit.o
<libbe>support_kit.o <libbe>support_kit.o
@@ -39,7 +40,7 @@ SharedLibrary libbe.so :
libagg.a libagg.a
libroot.so # make sure it links against our libroot.so libroot.so # make sure it links against our libroot.so
$(TARGET_LIBSTDC++) $(TARGET_LIBSTDC++) $(HAIKU_ICU_LIBS)
; ;
# Build libbe_test.so # Build libbe_test.so
@@ -62,6 +63,30 @@ SharedLibrary libbe_test.so :
$(TARGET_LIBSTDC++) $(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 ] #SEARCH on [ FGristFiles KMessage.cpp ]
# = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ; # = [ FDirName $(HAIKU_TOP) src system kernel messaging ] ;
# #
-63
View File
@@ -1,63 +0,0 @@
/*
* Copyright 2010, Oliver Tappe, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "LocaleBackend.h"
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <image.h>
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
+5
View File
@@ -18,6 +18,9 @@
#include <TokenSpace.h> #include <TokenSpace.h>
extern void __initialize_locale_kit();
// debugging // debugging
//#define DBG(x) x //#define DBG(x) x
#define DBG(x) #define DBG(x)
@@ -56,6 +59,8 @@ initialize_after()
{ {
DBG(OUT("initialize_after()\n")); DBG(OUT("initialize_after()\n"));
__initialize_locale_kit();
DBG(OUT("initialize_after() done\n")); DBG(OUT("initialize_after() done\n"));
} }
+1 -1
View File
@@ -18,7 +18,7 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 {
} }
UseLibraryHeaders icon ; UseLibraryHeaders icon ;
UsePrivateHeaders shared app interface kernel notification ; UsePrivateHeaders shared app interface kernel locale notification ;
UsePrivateSystemHeaders ; UsePrivateSystemHeaders ;
SetSubDirSupportedPlatforms haiku libbe_test ; SetSubDirSupportedPlatforms haiku libbe_test ;
+5 -14
View File
@@ -23,12 +23,10 @@
#include <TextControl.h> #include <TextControl.h>
#include <Region.h> #include <Region.h>
#include <Screen.h> #include <Screen.h>
#include <SystemCatalog.h>
#include <Window.h> #include <Window.h>
#include <Catalog.h> using BPrivate::gSystemCatalog;
#include <LocaleBackend.h>
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
#include <binary_compatibility/Interface.h> #include <binary_compatibility/Interface.h>
@@ -78,11 +76,6 @@ void
BColorControl::_InitData(color_control_layout layout, float size, BColorControl::_InitData(color_control_layout layout, float size,
bool useOffscreen, BMessage* archive) 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; fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8;
//TODO: we don't support workspace and colorspace changing for now //TODO: we don't support workspace and colorspace changing for now
// so we take the main_screen colorspace at startup // 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* red = B_TRANSLATE_MARK("Red:");
const char* green = B_TRANSLATE_MARK("Green:"); const char* green = B_TRANSLATE_MARK("Green:");
const char* blue = B_TRANSLATE_MARK("Blue:"); const char* blue = B_TRANSLATE_MARK("Blue:");
if (gLocaleBackend) { red = gSystemCatalog->GetString(red, "ColorControl");
red = gLocaleBackend->GetString(red, "ColorControl"); green = gSystemCatalog->GetString(green, "ColorControl");
green = gLocaleBackend->GetString(green, "ColorControl"); blue = gSystemCatalog->GetString(blue, "ColorControl");
blue = gLocaleBackend->GetString(blue, "ColorControl");
}
if (archive) { if (archive) {
fRedText = (BTextControl*)FindView("_red"); fRedText = (BTextControl*)FindView("_red");
+3 -10
View File
@@ -18,13 +18,12 @@
#include <Alert.h> #include <Alert.h>
#include <Beep.h> #include <Beep.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Catalog.h>
#include <Dragger.h> #include <Dragger.h>
#include <LocaleBackend.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h> #include <Message.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
#include <Shelf.h> #include <Shelf.h>
#include <SystemCatalog.h>
#include <Window.h> #include <Window.h>
#include <AutoLocker.h> #include <AutoLocker.h>
@@ -37,15 +36,14 @@
#include "ZombieReplicantView.h" #include "ZombieReplicantView.h"
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Dragger" #define B_TRANSLATE_CONTEXT "Dragger"
#undef B_TRANSLATE #undef B_TRANSLATE
#define B_TRANSLATE(str) \ #define B_TRANSLATE(str) \
gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Dragger") gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Dragger")
const uint32 kMsgDragStarted = 'Drgs'; 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 = new BBitmap(BRect(0.0f, 0.0f, 7.0f, 7.0f), B_CMAP8, false, false);
fBitmap->SetBits(kHandBitmap, fBitmap->BitsLength(), 0, B_CMAP8); 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();
} }
+1 -1
View File
@@ -25,7 +25,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
SetSubDirSupportedPlatforms haiku libbe_test ; SetSubDirSupportedPlatforms haiku libbe_test ;
UseLibraryHeaders agg ; 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 ] ; UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] ;
+3 -10
View File
@@ -17,14 +17,12 @@
#include <string.h> #include <string.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Catalog.h>
#include <ControlLook.h> #include <ControlLook.h>
#include <Debug.h> #include <Debug.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Layout.h> #include <Layout.h>
#include <LayoutUtils.h> #include <LayoutUtils.h>
#include <LocaleBackend.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Messenger.h> #include <Messenger.h>
@@ -32,6 +30,7 @@
#include <PropertyInfo.h> #include <PropertyInfo.h>
#include <Screen.h> #include <Screen.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <SystemCatalog.h>
#include <Window.h> #include <Window.h>
#include <AppServerLink.h> #include <AppServerLink.h>
@@ -46,15 +45,14 @@
#define USE_CACHED_MENUWINDOW 1 #define USE_CACHED_MENUWINDOW 1
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "Menu" #define B_TRANSLATE_CONTEXT "Menu"
#undef B_TRANSLATE #undef B_TRANSLATE
#define B_TRANSLATE(str) \ #define B_TRANSLATE(str) \
gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "Menu") gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "Menu")
using std::nothrow; using std::nothrow;
@@ -1429,11 +1427,6 @@ void BMenu::_ReservedMenu6() {}
void void
BMenu::_InitData(BMessage* archive) 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("<empty>"); BPrivate::kEmptyMenuLabel = B_TRANSLATE("<empty>");
// TODO: Get _color, _fname, _fflt from the message, if present // TODO: Get _color, _fname, _fflt from the message, if present
+3 -10
View File
@@ -19,32 +19,30 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h>
#include <Debug.h> #include <Debug.h>
#include <Entry.h> #include <Entry.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <LocaleBackend.h>
#include <Messenger.h> #include <Messenger.h>
#include <NodeInfo.h> #include <NodeInfo.h>
#include <OS.h> #include <OS.h>
#include <Path.h> #include <Path.h>
#include <Region.h> #include <Region.h>
#include <Roster.h> #include <Roster.h>
#include <SystemCatalog.h>
#include <View.h> #include <View.h>
#include <pr_server.h> #include <pr_server.h>
#include <ViewPrivate.h> #include <ViewPrivate.h>
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "PrintJob" #define B_TRANSLATE_CONTEXT "PrintJob"
#undef B_TRANSLATE #undef B_TRANSLATE
#define B_TRANSLATE(str) \ #define B_TRANSLATE(str) \
gLocaleBackend->GetString(B_TRANSLATE_MARK(str), "PrintJob") gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "PrintJob")
/*! Summary of spool file: /*! Summary of spool file:
@@ -170,11 +168,6 @@ BPrintJob::BPrintJob(const char* jobName)
fCurrentPageHeader = new _page_header_; fCurrentPageHeader = new _page_header_;
if (fCurrentPageHeader != NULL) if (fCurrentPageHeader != NULL)
memset(fCurrentPageHeader, 0, sizeof(_page_header_)); 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();
} }
+5 -13
View File
@@ -42,6 +42,7 @@
#include <PropertyInfo.h> #include <PropertyInfo.h>
#include <Region.h> #include <Region.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <SystemCatalog.h>
#include <TextView.h> #include <TextView.h>
#include <Window.h> #include <Window.h>
@@ -54,21 +55,17 @@
#include "UndoBuffer.h" #include "UndoBuffer.h"
#include "WidthBuffer.h" #include "WidthBuffer.h"
#include <Catalog.h>
#include <LocaleBackend.h>
using namespace std; using namespace std;
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "TextView" #define B_TRANSLATE_CONTEXT "TextView"
#define TRANSLATE(str) gLocaleBackend->GetString(B_TRANSLATE_MARK(str), \ #define TRANSLATE(str) \
"TextView") gSystemCatalog->GetString(B_TRANSLATE_MARK(str), "TextView")
#undef TRACE #undef TRACE
#undef CALLED #undef CALLED
@@ -3256,11 +3253,6 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
fLastClickOffset = -1; fLastClickOffset = -1;
SetDoesUndo(true); 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 start;
int32 finish; int32 finish;
GetSelection(&start, &finish); GetSelection(&start, &finish);
bool canEdit = IsEditable(); bool canEdit = IsEditable();
int32 length = TextLength(); int32 length = TextLength();
+7 -14
View File
@@ -7,11 +7,10 @@
*/ */
#include <Alert.h> #include <Alert.h>
#include <Catalog.h>
#include <LocaleBackend.h>
#include <Message.h> #include <Message.h>
#include <MimeType.h> #include <MimeType.h>
#include <String.h> #include <String.h>
#include <SystemCatalog.h>
#include "ZombieReplicantView.h" #include "ZombieReplicantView.h"
@@ -20,15 +19,14 @@
#include <string.h> #include <string.h>
#include <new> #include <new>
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "ZombieReplicantView" #define B_TRANSLATE_CONTEXT "ZombieReplicantView"
#undef B_TRANSLATE #undef B_TRANSLATE
#define B_TRANSLATE(str) \ #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) _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error)
@@ -40,11 +38,6 @@ _BZombieReplicantView_::_BZombieReplicantView_(BRect frame, status_t error)
font.SetSize(9.0f); // TODO font.SetSize(9.0f); // TODO
SetFont(&font); SetFont(&font);
SetViewColor(kZombieColor); 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; const char* addOn = NULL;
BString error; BString error;
if (fArchive->FindString("add_on", &addOn) == B_OK) { if (fArchive->FindString("add_on", &addOn) == B_OK) {
char description[B_MIME_TYPE_LENGTH] = ""; char description[B_MIME_TYPE_LENGTH] = "";
BMimeType type(addOn); BMimeType type(addOn);
type.GetShortDescription(description); type.GetShortDescription(description);
error = B_TRANSLATE("Cannot create the replicant for " error = B_TRANSLATE("Cannot create the replicant for "
@@ -71,9 +64,9 @@ _BZombieReplicantView_::MessageReceived(BMessage* msg)
} else } else
error = B_TRANSLATE("Cannot locate the application for the " error = B_TRANSLATE("Cannot locate the application for the "
"replicant. No application signature supplied.\n%error"); "replicant. No application signature supplied.\n%error");
error.ReplaceFirst("%error", strerror(fError)); error.ReplaceFirst("%error", strerror(fError));
BAlert* alert = new (std::nothrow) BAlert(B_TRANSLATE("Error"), BAlert* alert = new (std::nothrow) BAlert(B_TRANSLATE("Error"),
error.String(), B_TRANSLATE("OK"), NULL, NULL, error.String(), B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT); B_WIDTH_AS_USUAL, B_STOP_ALERT);
@@ -113,7 +106,7 @@ status_t
_BZombieReplicantView_::Archive(BMessage* archive, bool) const _BZombieReplicantView_::Archive(BMessage* archive, bool) const
{ {
*archive = *fArchive; *archive = *fArchive;
return B_OK; return B_OK;
} }
@@ -10,8 +10,17 @@
#include <Volume.h> #include <Volume.h>
#include <VolumeRoster.h> #include <VolumeRoster.h>
#include <LocaleRoster.h>
#include <DefaultCatalog.h> #include <DefaultCatalog.h>
#include <MutableLocaleRoster.h>
#include <SystemCatalog.h>
namespace BPrivate {
BCatalogAddOn* gSystemCatalog;
}
// helper function that makes sure an attribute-index exists: // helper function that makes sure an attribute-index exists:
static void EnsureIndexExists(const char *attrName) static void EnsureIndexExists(const char *attrName)
@@ -115,9 +124,10 @@ SetupCatalogBasics()
} }
extern "C"
void void
initialize_after() __initialize_locale_kit()
{ {
SetupCatalogBasics(); SetupCatalogBasics();
MutableLocaleRoster::Default()->GetSystemCatalog(&BPrivate::gSystemCatalog);
} }
+4 -32
View File
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src kits locale ;
AddSubDirSupportedPlatforms libbe_test ; AddSubDirSupportedPlatforms libbe_test ;
UsePrivateHeaders libbe locale shared ; UsePrivateHeaders locale shared ;
UsePublicHeaders locale storage ; UsePublicHeaders locale storage ;
local sources = local sources =
@@ -13,9 +13,8 @@ local sources =
DefaultCatalog.cpp DefaultCatalog.cpp
FormattingConventions.cpp FormattingConventions.cpp
HashMapCatalog.cpp HashMapCatalog.cpp
InitLocaleKit.cpp
Language.cpp Language.cpp
LibbeLocaleBackend.cpp
LibraryInit.cpp
Locale.cpp Locale.cpp
LocaleRoster.cpp LocaleRoster.cpp
MutableLocaleRoster.cpp MutableLocaleRoster.cpp
@@ -52,37 +51,10 @@ Includes [ FGristFiles $(sources) ] : $(HAIKU_ICU_HEADERS_DEPENDENCY) ;
# Dependency needed to trigger downloading/unzipping the package before # Dependency needed to trigger downloading/unzipping the package before
# compiling the files. # compiling the files.
AddResources liblocale.so : CountryFlags.rdef LanguageFlags.rdef ; MergeObject <libbe>locale_kit.o :
$(sources)
SharedLibrary liblocale.so
: $(sources)
: be $(TARGET_LIBSTDC++) $(HAIKU_ICU_LIBS)
; ;
StaticLibrary liblocalestub.a StaticLibrary liblocalestub.a
: CatalogStub.cpp : 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
;
-51
View File
@@ -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 <new>
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
+3 -13
View File
@@ -10,14 +10,11 @@
#include <AboutMenuItem.h> #include <AboutMenuItem.h>
#include <Application.h> #include <Application.h>
#include <Catalog.h>
#include <LocaleBackend.h>
#include <Roster.h> #include <Roster.h>
#include <String.h> #include <String.h>
#include <SystemCatalog.h>
using BPrivate::gSystemCatalog;
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
@@ -33,15 +30,8 @@ BAboutMenuItem::BAboutMenuItem()
if (be_app != NULL && be_app->GetAppInfo(&info) == B_OK) if (be_app != NULL && be_app->GetAppInfo(&info) == B_OK)
name = B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(info.ref.name); 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%"); const char* string = B_TRANSLATE_MARK("About %app%");
if (gLocaleBackend) { string = gSystemCatalog->GetString(string, "AboutMenuItem");
string = gLocaleBackend->GetString(string, "AboutMenuItem");
}
BString label = string; BString label = string;
if (name != NULL) if (name != NULL)
+8 -18
View File
@@ -14,12 +14,10 @@
#include <Alert.h> #include <Alert.h>
#include <Font.h> #include <Font.h>
#include <String.h> #include <String.h>
#include <SystemCatalog.h>
#include <TextView.h> #include <TextView.h>
#include <Catalog.h> using BPrivate::gSystemCatalog;
#include <LocaleBackend.h>
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
@@ -31,17 +29,11 @@ BAboutWindow::BAboutWindow(const char *appName, int32 firstCopyrightYear,
{ {
fAppName = new BString(appName); fAppName = new BString(appName);
// we need to translate some strings, and in order to do so, we need const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT
// to use the LocaleBackend to reache liblocale.so " %years% Haiku, Inc.");
if (gLocaleBackend == NULL)
LocaleBackend::LoadBackend();
const char* copyright = B_TRANSLATE_MARK("Copyright " B_UTF8_COPYRIGHT " %years% Haiku, Inc.");
const char* writtenBy = B_TRANSLATE_MARK("Written by:"); const char* writtenBy = B_TRANSLATE_MARK("Written by:");
if (gLocaleBackend) { copyright = gSystemCatalog->GetString(copyright, "AboutWindow");
copyright = gLocaleBackend->GetString(copyright, "AboutWindow"); writtenBy = gSystemCatalog->GetString(writtenBy, "AboutWindow");
writtenBy = gLocaleBackend->GetString(writtenBy, "AboutWindow");
}
// Get current year // Get current year
time_t tp; time_t tp;
@@ -85,10 +77,8 @@ BAboutWindow::Show()
{ {
const char* aboutTitle = B_TRANSLATE_MARK("About" B_UTF8_ELLIPSIS); const char* aboutTitle = B_TRANSLATE_MARK("About" B_UTF8_ELLIPSIS);
const char* closeLabel = B_TRANSLATE_MARK("Close"); const char* closeLabel = B_TRANSLATE_MARK("Close");
if (gLocaleBackend) { aboutTitle = gSystemCatalog->GetString(aboutTitle, "AboutWindow");
aboutTitle = gLocaleBackend->GetString(aboutTitle, "AboutWindow"); closeLabel = gSystemCatalog->GetString(closeLabel, "AboutWindow");
closeLabel = gLocaleBackend->GetString(closeLabel, "AboutWindow");
}
BAlert *alert = new BAlert(aboutTitle, fText->String(), closeLabel); BAlert *alert = new BAlert(aboutTitle, fText->String(), closeLabel);
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
+1 -1
View File
@@ -4,7 +4,7 @@ SetSubDirSupportedPlatformsBeOSCompatible ;
AddSubDirSupportedPlatforms libbe_test ; AddSubDirSupportedPlatforms libbe_test ;
UseLibraryHeaders agg ; UseLibraryHeaders agg ;
UsePrivateHeaders shared libbe ; UsePrivateHeaders shared locale ;
UseHeaders [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR) servers input ] ; UseHeaders [ FDirName $(HAIKU_COMMON_DEBUG_OBJECT_DIR) servers input ] ;
UseHeaders [ FDirName $(HAIKU_TOP) src kits ] ; UseHeaders [ FDirName $(HAIKU_TOP) src kits ] ;
+8 -13
View File
@@ -7,10 +7,9 @@
#include <stdio.h> #include <stdio.h>
#include <Catalog.h> #include <SystemCatalog.h>
#include <LocaleBackend.h>
using BPrivate::gLocaleBackend; using BPrivate::gSystemCatalog;
using BPrivate::LocaleBackend;
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
@@ -23,40 +22,36 @@ namespace BPrivate {
const char* const char*
string_for_size(double size, char* string, size_t stringSize) 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; double kib = size / 1024.0;
if (kib < 1.0) { if (kib < 1.0) {
const char* trKey = B_TRANSLATE_MARK("%d bytes"); 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); B_TRANSLATE_CONTEXT), (int)size);
return string; return string;
} }
double mib = kib / 1024.0; double mib = kib / 1024.0;
if (mib < 1.0) { if (mib < 1.0) {
const char* trKey = B_TRANSLATE_MARK("%3.2f KiB"); 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); B_TRANSLATE_CONTEXT), kib);
return string; return string;
} }
double gib = mib / 1024.0; double gib = mib / 1024.0;
if (gib < 1.0) { if (gib < 1.0) {
const char* trKey = B_TRANSLATE_MARK("%3.2f MiB"); 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); B_TRANSLATE_CONTEXT), mib);
return string; return string;
} }
double tib = gib / 1024.0; double tib = gib / 1024.0;
if (tib < 1.0) { if (tib < 1.0) {
const char* trKey = B_TRANSLATE_MARK("%3.2f GiB"); 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); B_TRANSLATE_CONTEXT), gib);
return string; return string;
} }
const char* trKey = B_TRANSLATE_MARK("%.2f TiB"); const char* trKey = B_TRANSLATE_MARK("%.2f TiB");
snprintf(string, stringSize, gLocaleBackend->GetString(trKey, snprintf(string, stringSize, gSystemCatalog->GetString(trKey,
B_TRANSLATE_CONTEXT), tib); B_TRANSLATE_CONTEXT), tib);
return string; return string;
} }
+2 -2
View File
@@ -22,7 +22,7 @@ rule LocaleTest
# LocaleTest <sources> ; # LocaleTest <sources> ;
local sources = $(1) ; local sources = $(1) ;
local name = $(sources[1]:B) ; 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 ; LocaleTest catalogSpeed.cpp ;
@@ -44,7 +44,7 @@ Application ICUTest :
Addon catalogTestAddOn Addon catalogTestAddOn
: catalogTestAddOn.cpp : catalogTestAddOn.cpp
: be liblocale.so : be
; ;
SubInclude HAIKU_TOP src tests kits locale number_format ; SubInclude HAIKU_TOP src tests kits locale number_format ;
+1 -1
View File
@@ -11,5 +11,5 @@ UnitTestLib libNumberFormatTests.so
GenericNumberFormatTests.cpp GenericNumberFormatTests.cpp
GenericNumberFormatConstructorTest.cpp GenericNumberFormatConstructorTest.cpp
: be $(TARGET_LIBSTDC++) liblocale.so : be $(TARGET_LIBSTDC++)
; ;