]> git.lyx.org Git - lyx.git/blobdiff - src/gettext.C
fix aspell encoding (confirmed on linux, cygwin and native windows,
[lyx.git] / src / gettext.C
index 9e48e11d0a77d46f8b181dae463dd7f82ae92ca0..55b2ef80821f79cd55665386522d35198d16868f 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * \file gettext.C
+ * \file src/gettext.C
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
 #include "gettext.h"
 #include "messages.h"
 
+#include "support/environment.h"
+#include "support/lstrings.h"
+
+
+namespace lyx {
 
 #ifdef HAVE_LOCALE_H
 #  include <locale.h>
 #endif
 
+using support::setEnv;
+
 using std::string;
 
 
 namespace {
 
-Messages & getLyXMessages()
+static Messages & getLyXMessages()
 {
        static Messages lyx_messages;
 
@@ -34,7 +41,7 @@ Messages & getLyXMessages()
 } // anon namespace
 
 
-string const _(string const & str)
+docstring const _(string const & str)
 {
        return getLyXMessages().get(str);
 }
@@ -44,6 +51,8 @@ string const _(string const & str)
 
 void locale_init()
 {
+       // Disable, as otherwise it overrides everything else incl. the doc language
+       setEnv("LANGUAGE", "");
 #  ifdef HAVE_LC_MESSAGES
        setlocale(LC_MESSAGES, "");
 #  endif
@@ -59,3 +68,20 @@ void locale_init()
 }
 
 #endif
+
+
+docstring const translateIfPossible(docstring const & name)
+{
+       if (support::isAscii(name))
+               // Probably from a standard configuration file, try to
+               // translate
+               return _(to_ascii(name));
+       else
+               // This must be from a user defined configuration file. We
+               // cannot translate this, since gettext accepts only ascii
+               // keys.
+               return name;
+}
+
+
+} // namespace lyx