Correct placement of the \selectlanguage commands.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2962 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Dekel Tsur 2001-11-03 17:15:43 +00:00
parent 45a5dda367
commit 4925a78eb2
3 changed files with 70 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2001-11-03 Dekel Tsur <dekelts@tau.ac.il>
* paragraph.C (TeXOnePar): Correct placement of \selectlanguage
commands.
2001-10-31 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 2001-10-31 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* gettext.C (locale_init): set LC_NUMERIC to "C" even if nls is * gettext.C (locale_init): set LC_NUMERIC to "C" even if nls is

View File

@ -243,7 +243,6 @@ void LyXRC::setDefaults() {
language_use_babel = true; language_use_babel = true;
language_package = "\\usepackage{babel}"; language_package = "\\usepackage{babel}";
language_command_begin = "\\selectlanguage{$$lang}"; language_command_begin = "\\selectlanguage{$$lang}";
language_command_end = "\\selectlanguage{$$lang}";
language_command_local = "\\foreignlanguage{$$lang}{"; language_command_local = "\\foreignlanguage{$$lang}{";
default_language = "english"; default_language = "english";
// //

View File

@ -1281,14 +1281,30 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
Language const * language = getParLanguage(bparams); Language const * language = getParLanguage(bparams);
Language const * doc_language = bparams.language; Language const * doc_language = bparams.language;
Language const * previous_language = previous_ Language const * previous_language = previous()
? previous_->getParLanguage(bparams) : doc_language; ? previous()->getParLanguage(bparams) : doc_language;
if (language->babel() != doc_language->babel() &&
language->babel() != previous_language->babel()) { if (language->babel() != previous_language->babel()
os << subst(lyxrc.language_command_begin, "$$lang", // check if we already put language command in TeXEnvironment()
language->babel()) && !(textclasslist.Style(bparams.textclass, layout).isEnvironment()
<< endl; && (!previous() || previous()->layout != layout ||
texrow.newline(); previous()->params().depth() != params().depth()))) {
if (!lyxrc.language_command_end.empty() &&
previous_language->babel() != doc_language->babel()) {
os << subst(lyxrc.language_command_end, "$$lang",
previous_language->babel())
<< endl;
texrow.newline();
}
if (lyxrc.language_command_end.empty() ||
language->babel() != doc_language->babel()) {
os << subst(lyxrc.language_command_begin, "$$lang",
language->babel())
<< endl;
texrow.newline();
}
} }
if (bparams.inputenc == "auto" && if (bparams.inputenc == "auto" &&
@ -1345,15 +1361,6 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
} else if (is_command) } else if (is_command)
os << "}"; os << "}";
if (language->babel() != doc_language->babel() &&
(!next_ ||
next_->getParLanguage(bparams)->babel() != language->babel()))
{
os << endl
<< subst(lyxrc.language_command_end, "$$lang",
doc_language->babel());
}
switch (style.latextype) { switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT: case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT: case LATEX_LIST_ENVIRONMENT:
@ -1411,6 +1418,24 @@ Paragraph * Paragraph::TeXOnePar(Buffer const * buf,
if (next_) { if (next_) {
os << '\n'; os << '\n';
texrow.newline(); texrow.newline();
} else {
// Since \selectlanguage write the language to the aux file,
// we need to reset the language at the end of footnote or
// float.
if (language->babel() != doc_language->babel()) {
if (lyxrc.language_command_end.empty())
os << subst(lyxrc.language_command_begin,
"$$lang",
doc_language->babel())
<< endl;
else
os << subst(lyxrc.language_command_end,
"$$lang",
language->babel())
<< endl;
texrow.newline();
}
} }
lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl; lyxerr[Debug::LATEX] << "TeXOnePar...done " << next_ << endl;
@ -1734,6 +1759,29 @@ Paragraph * Paragraph::TeXEnvironment(Buffer const * buf,
textclasslist.Style(bparams.textclass, textclasslist.Style(bparams.textclass,
layout); layout);
Language const * language = getParLanguage(bparams);
Language const * doc_language = bparams.language;
Language const * previous_language = previous_
? previous_->getParLanguage(bparams) : doc_language;
if (language->babel() != previous_language->babel()) {
if (!lyxrc.language_command_end.empty() &&
previous_language->babel() != doc_language->babel()) {
os << subst(lyxrc.language_command_end, "$$lang",
previous_language->babel())
<< endl;
texrow.newline();
}
if (lyxrc.language_command_end.empty() ||
language->babel() != doc_language->babel()) {
os << subst(lyxrc.language_command_begin, "$$lang",
language->babel())
<< endl;
texrow.newline();
}
}
if (style.isEnvironment()){ if (style.isEnvironment()){
if (style.latextype == LATEX_LIST_ENVIRONMENT) { if (style.latextype == LATEX_LIST_ENVIRONMENT) {
os << "\\begin{" << style.latexname() << "}{" os << "\\begin{" << style.latexname() << "}{"