]> git.lyx.org Git - lyx.git/blobdiff - src/support/Messages.cpp
Minor cleanup.
[lyx.git] / src / support / Messages.cpp
index 8d1b29315668ed6d3dd027ee4e8ccef982064b2e..81b4eaee67873d929cf35838afc5619f68fadc75 100644 (file)
@@ -14,6 +14,7 @@
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/environment.h"
+#include "support/lstrings.h"
 #include "support/Package.h"
 #include "support/unicode.h"
 
@@ -63,7 +64,7 @@ void cleanTranslation(docstring & trans)
 #  if HAVE_GETTEXT
 #    include <libintl.h>      // use the header already in the system *EK*
 #  else
-#    include "../../intl/libintl.h"
+#    include "intl/libintl.h"
 #  endif
 
 using namespace lyx::support;
@@ -121,6 +122,14 @@ void Messages::init()
 }
 
 
+bool Messages::available() const
+{
+       string const test = languageTestString();
+       string const trans = to_utf8(get(test));
+       return !trans.empty() && trans != test;
+}
+
+
 docstring const Messages::get(string const & m) const
 {
        if (m.empty())
@@ -156,6 +165,11 @@ docstring const Messages::get(string const & m) const
 #endif
        }
 
+       // FIXME: gettext sometimes "forgets" the ucs4_codeset we set
+       // in init(), which leads to severe message corruption (#7371)
+       // We set it again here unconditionally. A real fix must be found!
+       LASSERT(bind_textdomain_codeset(PACKAGE, ucs4_codeset), /**/);
+
        char const * m_c = m.c_str();
        char const * trans_c = gettext(m_c);
        docstring trans;
@@ -205,7 +219,7 @@ docstring const Messages::get(string const & m) const
 
 namespace lyx {
 
-Messages::Messages(string const & l) {}
+Messages::Messages(string const & /* l */) {}
 
 void Messages::init()
 {
@@ -219,6 +233,12 @@ docstring const Messages::get(string const & m) const
        return trans;
 }
 
+
+bool Messages::available() const
+{
+       return false;
+}
+
 } // namespace lyx
 
 #endif