diff --git a/ChangeLog b/ChangeLog index cd73f1e00b..40968d173e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2001-03-08 Jean-Marc Lasgouttes + + * INSTALL: remove mention of problem with gettext. + 2001-03-02 John Levon * configure.in: diff --git a/INSTALL b/INSTALL index ac82469ffe..30c7c6cb84 100644 --- a/INSTALL +++ b/INSTALL @@ -325,16 +325,6 @@ notify us. If you your version of gcc-c++ is > 2.96-69, you may not need to do this. - o If you have GNU gettext installed on your system (e.g. on linux), - you may get tons of warnings like: - - bullet_forms.C:101: warning: passing `char *' to argument 1 of - `__builtin_constant_p(int)' lacks a cast - - These are in harmless warnings caused by a bug in libintl.h, but - will be solved if you use --with-included-gettext when configuring - LyX. - o It is possible to compile lyx with Tru64 Unix cxx compiler version 6.2, provided one uses CXX='cxx -std strict_ansi' diff --git a/src/ChangeLog b/src/ChangeLog index a4c58c5e6d..4b3420b830 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2001-03-08 Jean-Marc Lasgouttes + + * main.C (main): pass lyx_localedir to gettext_init(). + + * gettext.h: remove locale_init and gettext_init macros + + * gettext.C (locale_init): new function + (gettext_init): new function + + * lyx_gui.C (LyXGUI): use locale_init() instead of explicit + setlocale(). + 2001-03-07 Edwin Leuven * Moved credits to frontends: diff --git a/src/gettext.C b/src/gettext.C index 49158949ce..08a948e8f4 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -1,10 +1,29 @@ +// -*- C++ -*- +/* This file is part of + * ====================================================== + * + * LyX, The Document Processor + * + * Copyright 1995 Matthias Ettrich + * Copyright 1995-2001 The LyX Team. + * + * ====================================================== */ + #include -#include "LString.h" -#include "gettext.h" - #ifdef ENABLE_NLS +#include "LString.h" + +# if HAVE_GETTEXT +# include // use the header already in the system *EK* +# ifdef HAVE_LOCALE_H +# include // for LC_MESSAGES +# endif +# else +# include "../intl/libintl.h" +# endif + char const * _(char const * str) { // I'd rather have an Assert on str, we should not allow @@ -32,4 +51,20 @@ string const _(string const & str) return string(); } +void locale_init() +{ +# ifdef HAVE_LC_MESSAGES + setlocale(LC_MESSAGES, ""); + setlocale(LC_CTYPE, ""); + setlocale(LC_NUMERIC, "C"); +# endif +} + +void gettext_init(string const & localedir) +{ + bindtextdomain(PACKAGE, localedir.c_str()); + textdomain(PACKAGE); +} + + #endif diff --git a/src/gettext.h b/src/gettext.h index 121e0428bd..ebd358a739 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -34,41 +34,27 @@ #include "LString.h" -# if HAVE_GETTEXT -# include // use the header already in the system *EK* -# ifdef HAVE_LOCALE_H -# include // for LC_MESSAGES -# endif -# else -# include "../intl/libintl.h" -# endif - +/// char const * _(char const *); - +/// string const _(string const &); +/// +void locale_init(); +/// +void gettext_init(string const & localedir); -//# define _(str) gettext(str) -# define N_(str) (str) // for detecting static strings - -# ifdef HAVE_LC_MESSAGES - // LC_TIME, LC_CTYPE, even LC_ALL -# define locale_init() { setlocale (LC_MESSAGES, ""); setlocale (LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); } -# else -# define locale_init() -# endif -# define gettext_init() { bindtextdomain (PACKAGE, lyx_localedir.c_str()); \ - textdomain (PACKAGE); } #else /// # define _(str) (str) /// # define S_(str) (str) /// -# define N_(str) (str) -/// # define locale_init() /// -# define gettext_init() -#endif +# define gettext_init(package, localedir) + +#endif + +# define N_(str) (str) // for detecting static strings #endif diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 306d8749e9..0880fdd93c 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -10,7 +10,6 @@ #include #include -#include #ifdef __GNUG__ #pragma implementation @@ -103,7 +102,7 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI) fl_initialize(argc, argv, "LyX", cmdopt, num_res); // It appears that, in xforms >=0.89.5, fl_initialize() // calls setlocale() and ruins our LC_NUMERIC setting. - setlocale(LC_NUMERIC, "C"); + locale_init(); fl_get_app_resources(res, num_res); static const int geometryBitmask = diff --git a/src/main.C b/src/main.C index 8d525321f0..770b5aedca 100644 --- a/src/main.C +++ b/src/main.C @@ -30,8 +30,8 @@ int main(int argc, char * argv[]) lyx_localedir = LOCALEDIR; // initialize for internationalized version *EK* - locale_init(); // macro - gettext_init(); // macro + locale_init(); + gettext_init(lyx_localedir); #ifdef __EMX__ _wildcard(&argc, &argv);