]> git.lyx.org Git - lyx.git/blobdiff - src/gettext.C
Alfredo's second patch
[lyx.git] / src / gettext.C
index ef13c283eaf6b25d2f6f9e2b3441e8fc0da79eab..6165efb3fbb91e3938d5585a3137e2bab97f879c 100644 (file)
@@ -1,25 +1,65 @@
+/* This file is part of
+ * ======================================================
+ *
+ *           LyX, The Document Processor
+ *
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2001 The LyX Team.
+ *
+ * ====================================================== */
+
 #include <config.h>
 
+#include "messages.h"
 #include "LString.h"
-#include "gettext.h"
+#include "support/LAssert.h"
+
+#include <boost/scoped_ptr.hpp>
+
+#ifdef HAVE_LOCALE_H
+#  include <locale.h>
+#endif
+
+namespace {
+
+Messages & getLyXMessages()
+{
+       static Messages lyx_messages;
+
+       return lyx_messages;
+}
+
+} // anon namespace
 
-#ifdef ENABLE_NLS
 
 char const * _(char const * str)
 {
-       return gettext(str);
+       return getLyXMessages().get(str).c_str();
+}
+
+
+string const _(string const & str)
+{
+       return getLyXMessages().get(str);
+}
+
+
+#ifdef ENABLE_NLS
+
+void locale_init()
+{
+#  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()
 {
-       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;
+       setlocale(LC_NUMERIC, "C");
 }
 
 #endif