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
NotFile LocaleKit ;
Depends LocaleKit :
liblocale.so
Locale
# 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
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__ ;
+12 -1
View File
@@ -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
-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
: Catalog.cpp
: be $(TARGET_LIBSTDC++) liblocale.so
: be $(TARGET_LIBSTDC++)
;
+1 -1
View File
@@ -4,5 +4,5 @@ UsePublicHeaders locale ;
Addon <catalog-addon>zeta
: 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
: GermanDIN-2.cpp
: be liblocale.so $(TARGET_LIBSUPC++)
: be $(TARGET_LIBSUPC++)
;
Addon <collator-addon>French
: French.cpp
: be liblocale.so $(TARGET_LIBSUPC++)
: be $(TARGET_LIBSUPC++)
;
+6 -4
View File
@@ -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
;
+1 -1
View File
@@ -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
;
+1 -1
View File
@@ -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
;
+5 -3
View File
@@ -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) ;
+4 -4
View File
@@ -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++) ;
+31 -6
View File
@@ -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 : :
<libbe>app_kit.o
<libbe>interface_kit.o
<libbe>locale_kit.o
<libbe>storage_kit.o
<libbe>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 ] ;
#
-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>
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"));
}
+1 -1
View File
@@ -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 ;
+5 -14
View File
@@ -23,12 +23,10 @@
#include <TextControl.h>
#include <Region.h>
#include <Screen.h>
#include <SystemCatalog.h>
#include <Window.h>
#include <Catalog.h>
#include <LocaleBackend.h>
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
using BPrivate::gSystemCatalog;
#include <binary_compatibility/Interface.h>
@@ -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");
+3 -10
View File
@@ -18,13 +18,12 @@
#include <Alert.h>
#include <Beep.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <Dragger.h>
#include <LocaleBackend.h>
#include <MenuItem.h>
#include <Message.h>
#include <PopUpMenu.h>
#include <Shelf.h>
#include <SystemCatalog.h>
#include <Window.h>
#include <AutoLocker.h>
@@ -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();
}
+1 -1
View File
@@ -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 ] ;
+3 -10
View File
@@ -17,14 +17,12 @@
#include <string.h>
#include <Bitmap.h>
#include <Catalog.h>
#include <ControlLook.h>
#include <Debug.h>
#include <File.h>
#include <FindDirectory.h>
#include <Layout.h>
#include <LayoutUtils.h>
#include <LocaleBackend.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <Messenger.h>
@@ -32,6 +30,7 @@
#include <PropertyInfo.h>
#include <Screen.h>
#include <ScrollBar.h>
#include <SystemCatalog.h>
#include <Window.h>
#include <AppServerLink.h>
@@ -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("<empty>");
// TODO: Get _color, _fname, _fflt from the message, if present
+3 -10
View File
@@ -19,32 +19,30 @@
#include <Alert.h>
#include <Application.h>
#include <Button.h>
#include <Catalog.h>
#include <Debug.h>
#include <Entry.h>
#include <File.h>
#include <FindDirectory.h>
#include <LocaleBackend.h>
#include <Messenger.h>
#include <NodeInfo.h>
#include <OS.h>
#include <Path.h>
#include <Region.h>
#include <Roster.h>
#include <SystemCatalog.h>
#include <View.h>
#include <pr_server.h>
#include <ViewPrivate.h>
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();
}
+5 -13
View File
@@ -42,6 +42,7 @@
#include <PropertyInfo.h>
#include <Region.h>
#include <ScrollBar.h>
#include <SystemCatalog.h>
#include <TextView.h>
#include <Window.h>
@@ -54,21 +55,17 @@
#include "UndoBuffer.h"
#include "WidthBuffer.h"
#include <Catalog.h>
#include <LocaleBackend.h>
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();
+7 -14
View File
@@ -7,11 +7,10 @@
*/
#include <Alert.h>
#include <Catalog.h>
#include <LocaleBackend.h>
#include <Message.h>
#include <MimeType.h>
#include <String.h>
#include <SystemCatalog.h>
#include "ZombieReplicantView.h"
@@ -20,15 +19,14 @@
#include <string.h>
#include <new>
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;
}
@@ -10,8 +10,17 @@
#include <Volume.h>
#include <VolumeRoster.h>
#include <LocaleRoster.h>
#include <DefaultCatalog.h>
#include <MutableLocaleRoster.h>
#include <SystemCatalog.h>
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);
}
+4 -32
View File
@@ -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 <libbe>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
;
-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 <Application.h>
#include <Catalog.h>
#include <LocaleBackend.h>
#include <Roster.h>
#include <String.h>
#include <SystemCatalog.h>
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)
+8 -18
View File
@@ -14,12 +14,10 @@
#include <Alert.h>
#include <Font.h>
#include <String.h>
#include <SystemCatalog.h>
#include <TextView.h>
#include <Catalog.h>
#include <LocaleBackend.h>
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();
+1 -1
View File
@@ -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 ] ;
+8 -13
View File
@@ -7,10 +7,9 @@
#include <stdio.h>
#include <Catalog.h>
#include <LocaleBackend.h>
using BPrivate::gLocaleBackend;
using BPrivate::LocaleBackend;
#include <SystemCatalog.h>
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;
}
+2 -2
View File
@@ -22,7 +22,7 @@ rule LocaleTest
# LocaleTest <sources> ;
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 ;
+1 -1
View File
@@ -11,5 +11,5 @@ UnitTestLib libNumberFormatTests.so
GenericNumberFormatTests.cpp
GenericNumberFormatConstructorTest.cpp
: be $(TARGET_LIBSTDC++) liblocale.so
: be $(TARGET_LIBSTDC++)
;