diff --git a/lib/languages b/lib/languages index ab0cc7f885..0d3d574a56 100644 --- a/lib/languages +++ b/lib/languages @@ -12,6 +12,9 @@ # RTL # LangCode # LangVariety +# PreBabelPreamble +# +# EndPreBabelPreamble # PostBabelPreamble # # EndPostBabelPreamble @@ -250,8 +253,8 @@ Language farsi RTL true LangCode fa_IR PostBabelPreamble - \DeclareTextSymbol{\guillemotright}{LFE}{62} - \DeclareTextSymbol{\guillemotleft}{LFE}{60} + \DeclareTextSymbol{\guillemotright}{LFE}{62} + \DeclareTextSymbol{\guillemotleft}{LFE}{60} EndPostBabelPreamble End @@ -269,10 +272,10 @@ Language french Encoding iso8859-15 LangCode fr_FR PostBabelPreamble - \addto\extrasfrench{% - \providecommand{\og}{\leavevmode\flqq~} - \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq} - } + \addto\extrasfrench{% + \providecommand{\og}{\leavevmode\flqq~} + \providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq} + } EndPostBabelPreamble End @@ -530,7 +533,7 @@ Language spanish Encoding iso8859-15 LangCode es_ES PostBabelPreamble - \addto\shorthandsspanish{\spanishdeactivate{~<>}} + \addto\shorthandsspanish{\spanishdeactivate{~<>}} EndPostBabelPreamble End @@ -540,7 +543,7 @@ Language spanish-mexico Encoding iso8859-15 LangCode es_MX PostBabelPreamble - \addto\shorthandsspanish{\spanishdeactivate{~<>.}} + \addto\shorthandsspanish{\spanishdeactivate{~<>.}} EndPostBabelPreamble End @@ -557,7 +560,7 @@ Language thai Encoding tis620-0 LangCode th_TH PostBabelPreamble - \usepackage{thswitch} + \usepackage{thswitch} EndPostBabelPreamble End diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 581673d4e3..2eca1bf2d5 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1743,8 +1743,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, || features.isRequired("vietnamese") || features.isRequired("japanese") ) ) { // FIXME UNICODE + lyxpreamble += from_utf8(features.getBabelPresettings()); lyxpreamble += from_utf8(babelCall(language_options.str())) + '\n'; - lyxpreamble += from_utf8(features.getBabelPostsettings()) + '\n'; + lyxpreamble += from_utf8(features.getBabelPostsettings()); } // The optional packages; @@ -1886,8 +1887,9 @@ bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features, && !features.isRequired("vietnamese") && !features.isRequired("japanese")) { // FIXME UNICODE + lyxpreamble += from_utf8(features.getBabelPresettings()); 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); diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index ac8a5b661c..8a40fd4b97 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -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 { ostringstream tmp; diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index dfad380279..6493f7b2fb 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -52,7 +52,9 @@ public: std::string const getPackages() const; /// The macros definitions needed by the document 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; /// The definitions needed by the document's textclass docstring const getTClassPreamble() const; diff --git a/src/Language.cpp b/src/Language.cpp index e4142507e4..219021557f 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -5,6 +5,7 @@ * * \author Lars Gullik Bjønnes * \author Jean-Marc Lasgouttes + * \author Jürgen Spitzmüller * \author Dekel Tsur * * Full author contact details are available in file CREDITS. @@ -48,6 +49,7 @@ bool Language::readLanguage(Lexer & lex) LA_LANG_CODE, LA_LANG_VARIETY, LA_POSTBABELPREAMBLE, + LA_PREBABELPREAMBLE, LA_RTL }; @@ -61,6 +63,7 @@ bool Language::readLanguage(Lexer & lex) { "langcode", LA_LANG_CODE }, { "langvariety", LA_LANG_VARIETY }, { "postbabelpreamble", LA_POSTBABELPREAMBLE }, + { "prebabelpreamble", LA_PREBABELPREAMBLE }, { "rtl", LA_RTL } }; @@ -109,6 +112,10 @@ bool Language::readLanguage(Lexer & lex) babel_postsettings_ = lex.getLongString("EndPostBabelPreamble"); break; + case LA_PREBABELPREAMBLE: + babel_presettings_ = + lex.getLongString("EndPreBabelPreamble"); + break; case LA_RTL: lex >> rightToLeft_; break; diff --git a/src/Language.h b/src/Language.h index bc705b7b95..b5aa3d98f6 100644 --- a/src/Language.h +++ b/src/Language.h @@ -54,6 +54,8 @@ public: /// 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 read(Lexer & lex); @@ -81,6 +83,8 @@ private: /// std::string babel_postsettings_; /// + std::string babel_presettings_; + /// bool internal_enc_; };