gettext cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1715 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2001-03-08 14:22:43 +00:00
parent de26c5e188
commit 7d09a8c0e7
7 changed files with 68 additions and 42 deletions

View File

@ -1,3 +1,7 @@
2001-03-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* INSTALL: remove mention of problem with gettext.
2001-03-02 John Levon <moz@compsoc.man.ac.uk>
* configure.in:

10
INSTALL
View File

@ -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'

View File

@ -1,3 +1,15 @@
2001-03-08 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* 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 <leuven@fee.uva.nl>
* Moved credits to frontends:

View File

@ -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 <config.h>
#include "LString.h"
#include "gettext.h"
#ifdef ENABLE_NLS
#include "LString.h"
# if HAVE_GETTEXT
# include <libintl.h> // use the header already in the system *EK*
# ifdef HAVE_LOCALE_H
# include <locale.h> // 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

View File

@ -34,41 +34,27 @@
#include "LString.h"
# if HAVE_GETTEXT
# include <libintl.h> // use the header already in the system *EK*
# ifdef HAVE_LOCALE_H
# include <locale.h> // 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

View File

@ -10,7 +10,6 @@
#include <config.h>
#include <cstdlib>
#include <clocale>
#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 =

View File

@ -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);