diff --git a/lib/languages b/lib/languages index 25169dc851..92d23c11e0 100644 --- a/lib/languages +++ b/lib/languages @@ -21,6 +21,7 @@ # PostBabelPreamble # # EndPostBabelPreamble +# Requires # End # # @@ -261,6 +262,7 @@ Language chinese-simplified GuiName "Chinese (simplified)" Encoding euc-cn LangCode zh_CN + Requires CJK End # uses CJK package @@ -268,6 +270,7 @@ Language chinese-traditional GuiName "Chinese (traditional)" Encoding utf8-cjk LangCode zh_CN + Requires CJK End # not supported by babel @@ -513,6 +516,7 @@ Language japanese Encoding jis-plain LangCode ja_JP AsBabelOptions true + Requires japanese End # uses CJK package @@ -520,6 +524,7 @@ Language japanese-cjk GuiName "Japanese (CJK)" Encoding euc-jp LangCode ja_JP + Requires CJK End # not yet supported by polyglossia @@ -534,6 +539,7 @@ Language korean GuiName "Korean" Encoding euc-kr LangCode ko_KR + Requires CJK End # not supported by babel @@ -873,6 +879,7 @@ Language vietnamese Encoding utf8 LangCode vi_VN AsBabelOptions true + Requires vietnamese End Language welsh diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 7237a94334..ac028fc232 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -1250,10 +1250,8 @@ void BufferParams::validate(LaTeXFeatures & features) const || useNonTeXFonts)) features.require("polyglossia"); - if (language->lang() == "vietnamese") - features.require("vietnamese"); - else if (language->lang() == "japanese") - features.require("japanese"); + if (!language->requires().empty()) + features.require(language->requires()); } @@ -2688,9 +2686,6 @@ void BufferParams::writeEncodingPreamble(otexstream & os, // If the "japanese" package (i.e. pLaTeX) is used, // inputenc must be omitted. // see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html - if (package == Encoding::japanese) - features.require("japanese"); - if ((!encodings.empty() || package == Encoding::inputenc) && !features.isRequired("japanese")) { os << "\\usepackage["; diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index f75fdc478b..c4b49e605a 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -453,8 +453,8 @@ void LaTeXFeatures::useLanguage(Language const * lang) { if (!lang->babel().empty()) UsedLanguages_.insert(lang); - if (lang->lang() == "vietnamese") - require("vietnamese"); + if (!lang->requires().empty()) + require(lang->requires()); // CJK languages do not have a babel name. // They use the CJK package if (lang->encoding()->package() == Encoding::CJK) diff --git a/src/Language.cpp b/src/Language.cpp index cbe425d3b9..ddb63e3b28 100644 --- a/src/Language.cpp +++ b/src/Language.cpp @@ -74,6 +74,7 @@ bool Language::readLanguage(Lexer & lex) LA_POLYGLOSSIAOPTS, LA_POSTBABELPREAMBLE, LA_PREBABELPREAMBLE, + LA_REQUIRES, LA_RTL }; @@ -91,6 +92,7 @@ bool Language::readLanguage(Lexer & lex) { "polyglossiaopts", LA_POLYGLOSSIAOPTS }, { "postbabelpreamble", LA_POSTBABELPREAMBLE }, { "prebabelpreamble", LA_PREBABELPREAMBLE }, + { "requires", LA_REQUIRES }, { "rtl", LA_RTL } }; @@ -152,6 +154,9 @@ bool Language::readLanguage(Lexer & lex) babel_presettings_ = lex.getLongString("EndPreBabelPreamble"); break; + case LA_REQUIRES: + lex >> requires_; + break; case LA_RTL: lex >> rightToLeft_; break; diff --git a/src/Language.h b/src/Language.h index 537c7f76fa..955df26b20 100644 --- a/src/Language.h +++ b/src/Language.h @@ -40,6 +40,8 @@ public: std::string const & polyglossia() const { return polyglossia_name_; } /// polyglossia language options std::string const & polyglossiaOpts() const { return polyglossia_opts_; } + /// requirement (package, function) + std::string const & requires() const { return requires_; } /// translatable GUI name std::string const & display() const { return display_; } /// is this a RTL language? @@ -93,6 +95,8 @@ private: /// std::string polyglossia_opts_; /// + std::string requires_; + /// std::string display_; /// bool rightToLeft_;