* add PreBabelPreamble to Language definition (fixes #4786).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36291 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2010-11-14 09:54:24 +00:00
parent 37d45c01c8
commit 12c7e7dde3
6 changed files with 46 additions and 12 deletions

View File

@ -12,6 +12,9 @@
# RTL <true|false> # RTL <true|false>
# LangCode <language_code> # LangCode <language_code>
# LangVariety <language_variety> # LangVariety <language_variety>
# PreBabelPreamble
# <extra latex code inserted before babel>
# EndPreBabelPreamble
# PostBabelPreamble # PostBabelPreamble
# <extra latex code inserted after babel> # <extra latex code inserted after babel>
# EndPostBabelPreamble # EndPostBabelPreamble
@ -250,8 +253,8 @@ Language farsi
RTL true RTL true
LangCode fa_IR LangCode fa_IR
PostBabelPreamble PostBabelPreamble
\DeclareTextSymbol{\guillemotright}{LFE}{62} \DeclareTextSymbol{\guillemotright}{LFE}{62}
\DeclareTextSymbol{\guillemotleft}{LFE}{60} \DeclareTextSymbol{\guillemotleft}{LFE}{60}
EndPostBabelPreamble EndPostBabelPreamble
End End
@ -269,10 +272,10 @@ Language french
Encoding iso8859-15 Encoding iso8859-15
LangCode fr_FR LangCode fr_FR
PostBabelPreamble PostBabelPreamble
\addto\extrasfrench{% \addto\extrasfrench{%
\providecommand{\og}{\leavevmode\flqq~} \providecommand{\og}{\leavevmode\flqq~}
\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq} \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}
} }
EndPostBabelPreamble EndPostBabelPreamble
End End
@ -530,7 +533,7 @@ Language spanish
Encoding iso8859-15 Encoding iso8859-15
LangCode es_ES LangCode es_ES
PostBabelPreamble PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>}} \addto\shorthandsspanish{\spanishdeactivate{~<>}}
EndPostBabelPreamble EndPostBabelPreamble
End End
@ -540,7 +543,7 @@ Language spanish-mexico
Encoding iso8859-15 Encoding iso8859-15
LangCode es_MX LangCode es_MX
PostBabelPreamble PostBabelPreamble
\addto\shorthandsspanish{\spanishdeactivate{~<>.}} \addto\shorthandsspanish{\spanishdeactivate{~<>.}}
EndPostBabelPreamble EndPostBabelPreamble
End End
@ -557,7 +560,7 @@ Language thai
Encoding tis620-0 Encoding tis620-0
LangCode th_TH LangCode th_TH
PostBabelPreamble PostBabelPreamble
\usepackage{thswitch} \usepackage{thswitch}
EndPostBabelPreamble EndPostBabelPreamble
End End

View File

@ -1743,8 +1743,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
|| features.isRequired("vietnamese") || features.isRequired("vietnamese")
|| features.isRequired("japanese") ) ) { || features.isRequired("japanese") ) ) {
// FIXME UNICODE // FIXME UNICODE
lyxpreamble += from_utf8(features.getBabelPresettings());
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelPostsettings()) + '\n'; lyxpreamble += from_utf8(features.getBabelPostsettings());
} }
// The optional packages; // The optional packages;
@ -1886,8 +1887,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
&& !features.isRequired("vietnamese") && !features.isRequired("vietnamese")
&& !features.isRequired("japanese")) { && !features.isRequired("japanese")) {
// FIXME UNICODE // FIXME UNICODE
lyxpreamble += from_utf8(features.getBabelPresettings());
lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n';
lyxpreamble += from_utf8(features.getBabelPostsettings()) + '\n'; lyxpreamble += from_utf8(features.getBabelPostsettings());
} }
docstring const i18npreamble = features.getTClassI18nPreamble(use_babel); docstring const i18npreamble = features.getTClassI18nPreamble(use_babel);

View File

@ -947,6 +947,22 @@ docstring const LaTeXFeatures::getMacros() const
} }
string const LaTeXFeatures::getBabelPresettings() const
{
ostringstream tmp;
LanguageList::const_iterator it = UsedLanguages_.begin();
LanguageList::const_iterator end = UsedLanguages_.end();
for (; it != end; ++it)
if (!(*it)->babel_presettings().empty())
tmp << (*it)->babel_presettings() << '\n';
if (!params_.language->babel_presettings().empty())
tmp << params_.language->babel_presettings() << '\n';
return tmp.str();
}
string const LaTeXFeatures::getBabelPostsettings() const string const LaTeXFeatures::getBabelPostsettings() const
{ {
ostringstream tmp; ostringstream tmp;

View File

@ -52,7 +52,9 @@ public:
std::string const getPackages() const; std::string const getPackages() const;
/// The macros definitions needed by the document /// The macros definitions needed by the document
docstring const getMacros() const; docstring const getMacros() const;
/// /// Extra preamble code before babel is called
std::string const getBabelPresettings() const;
/// Extra preamble code after babel is called
std::string const getBabelPostsettings() const; std::string const getBabelPostsettings() const;
/// The definitions needed by the document's textclass /// The definitions needed by the document's textclass
docstring const getTClassPreamble() const; docstring const getTClassPreamble() const;

View File

@ -5,6 +5,7 @@
* *
* \author Lars Gullik Bjønnes * \author Lars Gullik Bjønnes
* \author Jean-Marc Lasgouttes * \author Jean-Marc Lasgouttes
* \author Jürgen Spitzmüller
* \author Dekel Tsur * \author Dekel Tsur
* *
* Full author contact details are available in file CREDITS. * Full author contact details are available in file CREDITS.
@ -48,6 +49,7 @@ bool Language::readLanguage(Lexer & lex)
LA_LANG_CODE, LA_LANG_CODE,
LA_LANG_VARIETY, LA_LANG_VARIETY,
LA_POSTBABELPREAMBLE, LA_POSTBABELPREAMBLE,
LA_PREBABELPREAMBLE,
LA_RTL LA_RTL
}; };
@ -61,6 +63,7 @@ bool Language::readLanguage(Lexer & lex)
{ "langcode", LA_LANG_CODE }, { "langcode", LA_LANG_CODE },
{ "langvariety", LA_LANG_VARIETY }, { "langvariety", LA_LANG_VARIETY },
{ "postbabelpreamble", LA_POSTBABELPREAMBLE }, { "postbabelpreamble", LA_POSTBABELPREAMBLE },
{ "prebabelpreamble", LA_PREBABELPREAMBLE },
{ "rtl", LA_RTL } { "rtl", LA_RTL }
}; };
@ -109,6 +112,10 @@ bool Language::readLanguage(Lexer & lex)
babel_postsettings_ = babel_postsettings_ =
lex.getLongString("EndPostBabelPreamble"); lex.getLongString("EndPostBabelPreamble");
break; break;
case LA_PREBABELPREAMBLE:
babel_presettings_ =
lex.getLongString("EndPreBabelPreamble");
break;
case LA_RTL: case LA_RTL:
lex >> rightToLeft_; lex >> rightToLeft_;
break; break;

View File

@ -54,6 +54,8 @@ public:
/// ///
std::string const & babel_postsettings() const { return babel_postsettings_; } std::string const & babel_postsettings() const { return babel_postsettings_; }
/// ///
std::string const & babel_presettings() const { return babel_presettings_; }
///
bool internalFontEncoding() const { return internal_enc_; } bool internalFontEncoding() const { return internal_enc_; }
/// ///
bool read(Lexer & lex); bool read(Lexer & lex);
@ -81,6 +83,8 @@ private:
/// ///
std::string babel_postsettings_; std::string babel_postsettings_;
/// ///
std::string babel_presettings_;
///
bool internal_enc_; bool internal_enc_;
}; };