]> git.lyx.org Git - lyx.git/blobdiff - src/support/Messages.cpp
add debug function which prints the callstack to stderr, disabled by default
[lyx.git] / src / support / Messages.cpp
index fc6ca0aaf051a3557d4adf4e7c276d9ff7a46063..17ba0c56961db70f7698496fdd7012330c3a42c1 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"
 
@@ -105,7 +106,7 @@ void Messages::init()
        int e = errno;
        if (e) {
                LYXERR(Debug::LOCALE, "Error code: " << errno << '\n'
-                       << "Directory : " << package().locale_dir().absFilename() << '\n'
+                       << "Directory : " << package().locale_dir().absFileName() << '\n'
                        << "Rtn value : " << c);
        }
 
@@ -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