diff --git a/lib/languages b/lib/languages index a29d2470ef..6ed813da18 100644 --- a/lib/languages +++ b/lib/languages @@ -891,6 +891,7 @@ Language hebrew GuiName "Hebrew" HasGuiSupport true BabelName hebrew + BabelProvide 2 PolyglossiaName hebrew XindyName hebrew Encoding cp1255 diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py index fa9641c5c9..ef9d4afd44 100644 --- a/lib/lyx2lyx/lyx_2_5.py +++ b/lib/lyx2lyx/lyx_2_5.py @@ -1010,6 +1010,11 @@ def revert_new_babel_languages(document): if have_oldrussian: add_to_preamble(document, ["\\AddToHook{package/babel/after}{\\languageattribute{russian}{ancient}}"]) + # Some babel languages require special treatment with unicode engines + if get_bool_value(document.header, "\\use_non_tex_fonts"): + if document.language == "hebrew" or find_token(document.body, "\\lang oldrussian", 0) != -1: + add_to_preamble(document, ["\\PassOptionsToPackage{provide*=*}{babel}"]) + ## # Conversion hub # diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 5930aaf7b9..3115e6b03b 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -3504,6 +3504,7 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts, // add main language langs.insert(language); ostringstream os; + string force_provide; for (auto const & l : langs) { string blang = l->babel(); bool use_opt = langoptions; @@ -3523,7 +3524,8 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts, use_opt = true; } } - if (l->useBabelProvide() == 1 || (l->useBabelProvide() == 2 && useNonTeXFonts)) { + int const bp = l->useBabelProvide(); + if (bp == 1) { os << "\n\\babelprovide[import"; if (l == language) os << ", main"; @@ -3532,11 +3534,28 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts, os << "]{" << blang << "}"; have_mods = true; } - else if (use_opt) + if (bp == 2 && useNonTeXFonts) { + // here we need to tell babel to use the ini + // even though an *.ldf exists + if (l == language) + force_provide = force_provide.empty() + ? "provide=*" + : "provide*=*"; + else + force_provide = "provide+=*"; + have_mods = true; + } + if (bp != 1 && use_opt) blangs.push_back(blang); } - if (have_mods) + if (have_mods) { lang_opts = getStringFromVector(blangs); + if (!force_provide.empty()) { + if (!lang_opts.empty()) + lang_opts += ", "; + lang_opts += force_provide; + } + } // The prefs may require the languages to // be submitted to babel itself (not the class). if ((langoptions || have_mods) && !lang_opts.empty())