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"
23 #include "support/lstrings.h"
26 using namespace lyx::support;
34 Language const * default_language;
35 Language const * ignore_language = &ignore_lang;
36 Language const * latex_language = &latex_lang;
37 Language const * reset_language = 0;
40 bool Language::read(Lexer & lex)
49 lex >> latex_options_;
53 variety_ = split(codeStr_, code_, '-');
55 encoding_ = encodings.fromLyXName(encodingStr_);
56 if (!encoding_ && !encodingStr_.empty()) {
57 encoding_ = encodings.fromLyXName("iso8859-1");
58 LYXERR0("Unknown encoding " << encodingStr_);
63 bool Language::internalFontEncoding() const
65 // FIXME: list incomplete
66 // FIXME: instead of hardcoding, this
67 // should go to the languages file
68 return lang_ == "hebrew"
70 || lang_ == "polutonikogreek";
74 void Languages::read(FileName const & filename)
77 lex.setFile(filename);
78 lex.setContext("Languages::read");
84 LYXERR(Debug::INFO, "Reading language " << l.lang());
85 if (l.lang() == "latex")
87 else if (l.lang() == "ignore")
90 languagelist[l.lang()] = l;
93 default_language = getLanguage(lyxrc.default_language);
94 if (!default_language) {
95 LYXERR0("Default language \"" << lyxrc.default_language
97 default_language = getLanguage("english");
98 if (!default_language)
99 default_language = &(*languagelist.begin()).second;
100 LYXERR0("Using \"" << default_language->lang() << "\" instead!");
105 Language const * Languages::getLanguage(string const & language) const
107 if (language == "reset")
108 return reset_language;
109 if (language == "ignore")
110 return ignore_language;
111 const_iterator it = languagelist.find(language);
112 return it == languagelist.end() ? reset_language : &it->second;