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_
);
60 bool Language::internalFontEncoding() const
62 // FIXME: list incomplete
63 // FIXME: instead of hardcoding, this
64 // should go to the languages file
65 return lang_
== "hebrew"
67 || lang_
== "polutonikogreek";
71 void Languages::read(FileName
const & filename
)
74 lex
.setFile(filename
);
75 lex
.setContext("Languages::read");
81 LYXERR(Debug::INFO
, "Reading language " << l
.lang());
82 if (l
.lang() == "latex")
84 else if (l
.lang() == "ignore")
87 languagelist
[l
.lang()] = l
;
90 default_language
= getLanguage(lyxrc
.default_language
);
91 if (!default_language
) {
92 LYXERR0("Default language \"" << lyxrc
.default_language
94 default_language
= getLanguage("english");
95 if (!default_language
)
96 default_language
= &(*languagelist
.begin()).second
;
97 LYXERR0("Using \"" << default_language
->lang() << "\" instead!");
102 Language
const * Languages::getLanguage(string
const & language
) const
104 if (language
== "reset")
105 return reset_language
;
106 if (language
== "ignore")
107 return ignore_language
;
108 const_iterator it
= languagelist
.find(language
);
109 return it
== languagelist
.end() ? reset_language
: &it
->second
;