X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgettext.C;h=e65081c71cd10a286db1ce4881e7e0006d27825f;hb=98c966c64594611e469313314abd1e59524adb4a;hp=debe17e487772d13230fc635c15728b9d84ac5c3;hpb=f3c49c0a05e1623f1d7b746079b85a73a920f49a;p=lyx.git diff --git a/src/gettext.C b/src/gettext.C index debe17e487..e65081c71c 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -1,9 +1,8 @@ -// -*- C++ -*- /* This file is part of - * ====================================================== - * + * ====================================================== + * * LyX, The Document Processor - * + * * Copyright 1995 Matthias Ettrich * Copyright 1995-2001 The LyX Team. * @@ -11,15 +10,18 @@ #include +#ifdef HAVE_LOCALE_H +# include +#endif + #include "LString.h" +#include + #ifdef ENABLE_NLS # 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 @@ -36,33 +38,34 @@ char const * _(char const * str) } -string const _(string const & str) +string const _(string const & str) { if (!str.empty()) { int const s = str.length(); - char * tmp = new char[s + 1]; - str.copy(tmp, s); + boost::scoped_array tmp(new char[s + 1]); + str.copy(tmp.get(), s); tmp[s] = '\0'; - string ret(gettext(tmp)); - delete [] tmp; + string const ret(gettext(tmp.get())); return ret; - } - else + } else { return string(); + } } + void locale_init() { # ifdef HAVE_LC_MESSAGES setlocale(LC_MESSAGES, ""); +# endif setlocale(LC_CTYPE, ""); setlocale(LC_NUMERIC, "C"); -# endif } + void gettext_init(string const & localedir) { - bindtextdomain(PACKAGE, localedir.c_str()); + bindtextdomain(PACKAGE, localedir.c_str()); textdomain(PACKAGE); } @@ -71,8 +74,10 @@ void gettext_init(string const & localedir) void locale_init() { + setlocale(LC_NUMERIC, "C"); } + void gettext_init(string const &) { }