3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
21 #include "support/debug.h"
22 #include "support/FileName.h"
25 using namespace lyx::support;
33 Language const * default_language;
34 Language const * ignore_language = &ignore_lang;
35 Language const * latex_language = &latex_lang;
36 Language const * reset_language = 0;
39 bool Language::read(Lexer & lex)
48 lex >> latex_options_;
52 encoding_ = encodings.fromLyXName(encodingStr_);
53 if (!encoding_ && !encodingStr_.empty()) {
54 encoding_ = encodings.fromLyXName("iso8859-1");
55 LYXERR0("Unknown encoding " << encodingStr_);
61 void Languages::read(FileName const & filename)
64 lex.setFile(filename);
65 lex.setContext("Languages::read");
71 LYXERR(Debug::INFO, "Reading language " << l.lang());
72 if (l.lang() == "latex")
74 else if (l.lang() == "ignore")
77 languagelist[l.lang()] = l;
80 default_language = getLanguage(lyxrc.default_language);
81 if (!default_language) {
82 LYXERR0("Default language \"" << lyxrc.default_language
84 default_language = getLanguage("english");
85 if (!default_language)
86 default_language = &(*languagelist.begin()).second;
87 LYXERR0("Using \"" << default_language->lang() << "\" instead!");
92 Language const * Languages::getLanguage(string const & language) const
94 if (language == "reset")
95 return reset_language;
96 if (language == "ignore")
97 return ignore_language;
98 const_iterator it = languagelist.find(language);
99 return it == languagelist.end() ? reset_language : &it->second;