]> git.lyx.org Git - lyx.git/blobdiff - src/Language.cpp
use return value of regex_match to check whether a match was found
[lyx.git] / src / Language.cpp
index e4142507e407def3436d0dc8870f829a0030b146..e588218047aea9c790753aa0d94b1a118188bd99 100644 (file)
@@ -5,6 +5,7 @@
  *
  * \author Lars Gullik Bjønnes
  * \author Jean-Marc Lasgouttes
+ * \author Jürgen Spitzmüller
  * \author Dekel Tsur
  *
  * Full author contact details are available in file CREDITS.
@@ -21,6 +22,7 @@
 #include "support/debug.h"
 #include "support/FileName.h"
 #include "support/lstrings.h"
+#include "support/Messages.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -40,19 +42,24 @@ Language const * reset_language = 0;
 bool Language::readLanguage(Lexer & lex)
 {
        enum LanguageTags {
-               LA_BABELNAME = 1,
+               LA_AS_BABELOPTS = 1,
+               LA_BABELNAME,
                LA_ENCODING,
                LA_END,
                LA_GUINAME,
                LA_INTERNAL_ENC,
                LA_LANG_CODE,
                LA_LANG_VARIETY,
+               LA_POLYGLOSSIANAME,
+               LA_POLYGLOSSIAOPTS,
                LA_POSTBABELPREAMBLE,
+               LA_PREBABELPREAMBLE,
                LA_RTL
        };
 
        // Keep these sorted alphabetically!
        LexerKeyword languageTags[] = {
+               { "asbabeloptions",       LA_AS_BABELOPTS },
                { "babelname",            LA_BABELNAME },
                { "encoding",             LA_ENCODING },
                { "end",                  LA_END },
@@ -60,7 +67,10 @@ bool Language::readLanguage(Lexer & lex)
                { "internalencoding",     LA_INTERNAL_ENC },
                { "langcode",             LA_LANG_CODE },
                { "langvariety",          LA_LANG_VARIETY },
+               { "polyglossianame",      LA_POLYGLOSSIANAME },
+               { "polyglossiaopts",      LA_POLYGLOSSIAOPTS },
                { "postbabelpreamble",    LA_POSTBABELPREAMBLE },
+               { "prebabelpreamble",     LA_PREBABELPREAMBLE },
                { "rtl",                  LA_RTL }
        };
 
@@ -87,9 +97,18 @@ bool Language::readLanguage(Lexer & lex)
                case LA_END: // end of structure
                        finished = true;
                        break;
+               case LA_AS_BABELOPTS:
+                       lex >> as_babel_options_;
+                       break;
                case LA_BABELNAME:
                        lex >> babel_;
                        break;
+               case LA_POLYGLOSSIANAME:
+                       lex >> polyglossia_name_;
+                       break;
+               case LA_POLYGLOSSIAOPTS:
+                       lex >> polyglossia_opts_;
+                       break;
                case LA_ENCODING:
                        lex >> encodingStr_;
                        break;
@@ -109,6 +128,10 @@ bool Language::readLanguage(Lexer & lex)
                        babel_postsettings_ =
                                lex.getLongString("EndPostBabelPreamble");
                        break;
+               case LA_PREBABELPREAMBLE:
+                       babel_presettings_ =
+                               lex.getLongString("EndPreBabelPreamble");
+                       break;
                case LA_RTL:
                        lex >> rightToLeft_;
                        break;
@@ -121,6 +144,7 @@ bool Language::readLanguage(Lexer & lex)
 
 bool Language::read(Lexer & lex)
 {
+       as_babel_options_ = 0;
        encoding_ = 0;
        internal_enc_ = 0;
        rightToLeft_ = 0;
@@ -142,6 +166,10 @@ bool Language::read(Lexer & lex)
                encoding_ = encodings.fromLyXName("iso8859-1");
                LYXERR0("Unknown encoding " << encodingStr_);
        }
+       // cache translation status. Calling getMessages() directly in
+       // PrefLanguage::PrefLanguage() did only work if the gui language
+       // was set to auto (otherwise all languages would be marked as available).
+       translated_ = getMessages(code()).available();
        return true;
 }