]> git.lyx.org Git - lyx.git/blobdiff - src/support/Messages.cpp
Add quote style information to languages
[lyx.git] / src / support / Messages.cpp
index fc6ca0aaf051a3557d4adf4e7c276d9ff7a46063..8d85460ea6dba9e1930b181f9bd73b64f1ab9be1 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"
 
@@ -28,8 +29,6 @@ namespace lyx {
 // Instanciate static member.
 string Messages::main_lang_;
 
-namespace {
-
 void cleanTranslation(docstring & trans) 
 {
        /*
@@ -50,7 +49,6 @@ void cleanTranslation(docstring & trans)
        }
 }
 
-} // anonymous
 } // lyx
 
 
@@ -63,7 +61,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;
@@ -105,7 +103,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 +119,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 +162,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 +216,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 +230,12 @@ docstring const Messages::get(string const & m) const
        return trans;
 }
 
+
+bool Messages::available() const
+{
+       return false;
+}
+
 } // namespace lyx
 
 #endif