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.
17 #include "support/debug.h"
22 #include "support/FileName.h"
34 Language const * english_language;
35 Language const * default_language;
36 Language ignore_lang("ignore", "ignore", "Ignore", false, "", 0, "ignore", "");
37 Language const * ignore_language = &ignore_lang;
38 Language latex_lang("latex", "", "Latex", false, "", 0, "latex", "");
39 Language const * latex_language = &latex_lang;
42 void Languages::read(support::FileName const & filename)
44 // We need to set the encoding of latex_lang
45 latex_lang = Language("latex", "", "Latex", false, "iso8859-1",
46 encodings.getFromLyXName("iso8859-1"),
50 lex.setFile(filename);
61 lang = lex.getString();
64 LYXERR(Debug::INFO, "Reading language " << lang);
67 babel = lex.getString();
69 display = lex.getString();
73 encoding_str = lex.getString();
75 code = lex.getString();
77 latex_options = lex.getString();
79 Encoding const * encoding = encodings.getFromLyXName(encoding_str);
81 encoding = encodings.getFromLyXName("iso8859-1");
82 lyxerr << "Unknown encoding " << encoding_str << endl;
85 languagelist[lang] = Language(lang, babel, display, rtl,
86 encoding_str, encoding, code, latex_options);
89 default_language = getLanguage(lyxrc.default_language);
90 if (!default_language) {
91 lyxerr << "Default language \"" << lyxrc.default_language
92 << "\" not found!" << endl;
93 default_language = getLanguage("english");
94 if (!default_language)
95 default_language = &(*languagelist.begin()).second;
96 lyxerr << "Using \"" << default_language->lang()
97 << "\" instead!" << endl;
99 english_language = getLanguage("english");
100 if (!english_language)
101 english_language = default_language;
105 Language const * Languages::getLanguage(string const & language) const
107 const_iterator it = languagelist.find(language);
108 return it == languagelist.end() ? 0 : &it->second;