X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Flanguage.C;h=e056463e93ca9fb528edef31c26ccc0f6de271c3;hb=35204f8f33d7400a5fefeffea533fb4cb4097211;hp=bb5d5f1d67d7e22ab49b0e4fe51609ce9d4d5524;hpb=8283e978f8d621041c432b9b88a476bfd567385c;p=lyx.git diff --git a/src/language.C b/src/language.C index bb5d5f1d67..e056463e93 100644 --- a/src/language.C +++ b/src/language.C @@ -1,51 +1,47 @@ -/* This file is part of - * ====================================================== +/** + * \file language.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor + * \author Lars Gullik Bjønnes + * \author Jean-Marc Lasgouttes + * \author Dekel Tsur * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. - * - * ====================================================== */ + * Full author contact details are available in file CREDITS. + */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "language.h" -#include "gettext.h" + +#include "debug.h" #include "encoding.h" -#include "lyxrc.h" #include "lyxlex.h" -#include "debug.h" +#include "lyxrc.h" + + +namespace lyx { using std::endl; +using std::string; + Languages languages; Language const * english_language; Language const * default_language; -Language ignore_lang("ignore", "ignore", "Ignore", false, 0, "ignore", ""); +Language ignore_lang("ignore", "ignore", "Ignore", false, "", 0, "ignore", ""); Language const * ignore_language = &ignore_lang; -Language latex_lang("latex", "latex", "Latex", false, 0, "latex", ""); +Language latex_lang("latex", "latex", "Latex", false, "", 0, "latex", ""); Language const * latex_language = &latex_lang; -#ifdef INHERIT_LANG -Language inherit_lang("inherit", "inherit", "Inherit", false, 0, "inherit", ""); -Language const * inherit_language = &inherit_lang; -#endif -void Languages::setDefaults() -{ - languagelist["english"] = Language("english", "english", N_("English"), - false, - encodings.getEncoding("iso8859-1"), - "en", ""); - english_language = default_language = &languagelist["english"]; -} void Languages::read(string const & filename) { + // We need to set the encoding of latex_lang + latex_lang = Language("latex", "latex", "Latex", false, "iso8859-1", + encodings.getFromLyXName("iso8859-1"), + "latex", ""); + LyXLex lex(0, 0); lex.setFile(filename); while (lex.isOK()) { @@ -61,7 +57,7 @@ void Languages::read(string const & filename) lang = lex.getString(); else break; - lyxerr[Debug::INIT] << "Reading language " << lang << endl; + lyxerr[Debug::INFO] << "Reading language " << lang << endl; if (lex.next()) babel = lex.getString(); @@ -76,14 +72,14 @@ void Languages::read(string const & filename) if (lex.next()) latex_options = lex.getString(); - Encoding const * encoding = encodings.getEncoding(encoding_str); + Encoding const * encoding = encodings.getFromLyXName(encoding_str); if (!encoding) { - encoding = encodings.getEncoding("iso8859-1"); + encoding = encodings.getFromLyXName("iso8859-1"); lyxerr << "Unknown encoding " << encoding_str << endl; } languagelist[lang] = Language(lang, babel, display, rtl, - encoding, code, latex_options); + encoding_str, encoding, code, latex_options); } default_language = getLanguage(lyxrc.default_language); @@ -101,11 +97,12 @@ void Languages::read(string const & filename) english_language = default_language; } + Language const * Languages::getLanguage(string const & language) const { const_iterator it = languagelist.find(language); - if (it != languagelist.end()) - return &it->second; - else - return 0; + return it == languagelist.end() ? 0 : &it->second; } + + +} // namespace lyx