X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fgettext.C;h=7bc80b4f7b0fa31c566fb54860617567e6f694f9;hb=2e57f2ff0ae7cd4a6efbf634ffe6d2f4379d9cfc;hp=49158949ce3a10148bbcccefc77478799881b80b;hpb=67ef45b7c842efd9c971112627109724564f0c74;p=lyx.git diff --git a/src/gettext.C b/src/gettext.C index 49158949ce..7bc80b4f7b 100644 --- a/src/gettext.C +++ b/src/gettext.C @@ -1,35 +1,60 @@ +/** + * \file gettext.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Lars Gullik Bjønnes + * \author Jean-Marc Lasgouttes + * + * Full author contact details are available in file CREDITS + */ + #include +#include "messages.h" #include "LString.h" -#include "gettext.h" +#include "support/LAssert.h" + +#include + +#ifdef HAVE_LOCALE_H +# include +#endif + +namespace { + +Messages & getLyXMessages() +{ + static Messages lyx_messages; + + return lyx_messages; +} + +} // anon namespace + + +string const _(string const & str) +{ + return getLyXMessages().get(str); +} + #ifdef ENABLE_NLS -char const * _(char const * str) +void locale_init() { - // I'd rather have an Assert on str, we should not allow - // null pointers here. Lgb - // Assert(str); - if (str && str[0]) - return gettext(str); - else - return ""; +# ifdef HAVE_LC_MESSAGES + setlocale(LC_MESSAGES, ""); +# endif + setlocale(LC_CTYPE, ""); + setlocale(LC_NUMERIC, "C"); } +#else // ENABLE_NLS -string const _(string const & str) +void locale_init() { - if (!str.empty()) { - int const s = str.length(); - char * tmp = new char[s + 1]; - str.copy(tmp, s); - tmp[s] = '\0'; - string ret(gettext(tmp)); - delete [] tmp; - return ret; - } - else - return string(); + setlocale(LC_NUMERIC, "C"); } #endif