mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-14 06:57:01 +00:00
4506ec88ab
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33085 a592a061-630c-0410-9148-cb99ea01b6c8
117 lines
2.5 KiB
C++
117 lines
2.5 KiB
C++
/**
|
|
* \file Language.cpp
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Lars Gullik Bjønnes
|
|
* \author Jean-Marc Lasgouttes
|
|
* \author Dekel Tsur
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "Language.h"
|
|
|
|
#include "Encoding.h"
|
|
#include "Lexer.h"
|
|
#include "LyXRC.h"
|
|
|
|
#include "support/debug.h"
|
|
#include "support/FileName.h"
|
|
#include "support/lstrings.h"
|
|
|
|
using namespace std;
|
|
using namespace lyx::support;
|
|
|
|
|
|
namespace lyx {
|
|
|
|
Languages languages;
|
|
Language ignore_lang;
|
|
Language latex_lang;
|
|
Language const * default_language;
|
|
Language const * ignore_language = &ignore_lang;
|
|
Language const * latex_language = &latex_lang;
|
|
Language const * reset_language = 0;
|
|
|
|
|
|
bool Language::read(Lexer & lex)
|
|
{
|
|
encoding_ = 0;
|
|
lex >> lang_;
|
|
lex >> babel_;
|
|
lex >> display_;
|
|
lex >> rightToLeft_;
|
|
lex >> encodingStr_;
|
|
lex >> codeStr_;
|
|
lex >> latex_options_;
|
|
if (!lex)
|
|
return false;
|
|
|
|
variety_ = split(codeStr_, code_, '-');
|
|
|
|
encoding_ = encodings.fromLyXName(encodingStr_);
|
|
if (!encoding_ && !encodingStr_.empty()) {
|
|
encoding_ = encodings.fromLyXName("iso8859-1");
|
|
LYXERR0("Unknown encoding " << encodingStr_);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool Language::internalFontEncoding() const
|
|
{
|
|
// FIXME: list incomplete
|
|
// FIXME: instead of hardcoding, this
|
|
// should go to the languages file
|
|
return lang_ == "hebrew"
|
|
|| lang_ == "greek"
|
|
|| lang_ == "polutonikogreek";
|
|
}
|
|
|
|
|
|
void Languages::read(FileName const & filename)
|
|
{
|
|
Lexer lex;
|
|
lex.setFile(filename);
|
|
lex.setContext("Languages::read");
|
|
while (1) {
|
|
Language l;
|
|
l.read(lex);
|
|
if (!lex)
|
|
break;
|
|
LYXERR(Debug::INFO, "Reading language " << l.lang());
|
|
if (l.lang() == "latex")
|
|
latex_lang = l;
|
|
else if (l.lang() == "ignore")
|
|
ignore_lang = l;
|
|
else
|
|
languagelist[l.lang()] = l;
|
|
}
|
|
|
|
default_language = getLanguage(lyxrc.default_language);
|
|
if (!default_language) {
|
|
LYXERR0("Default language \"" << lyxrc.default_language
|
|
<< "\" not found!");
|
|
default_language = getLanguage("english");
|
|
if (!default_language)
|
|
default_language = &(*languagelist.begin()).second;
|
|
LYXERR0("Using \"" << default_language->lang() << "\" instead!");
|
|
}
|
|
}
|
|
|
|
|
|
Language const * Languages::getLanguage(string const & language) const
|
|
{
|
|
if (language == "reset")
|
|
return reset_language;
|
|
if (language == "ignore")
|
|
return ignore_language;
|
|
const_iterator it = languagelist.find(language);
|
|
return it == languagelist.end() ? reset_language : &it->second;
|
|
}
|
|
|
|
|
|
} // namespace lyx
|