]> git.lyx.org Git - lyx.git/commitdiff
Add proper support for BabelProvide 2
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 25 Aug 2024 12:56:05 +0000 (14:56 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 25 Aug 2024 12:56:05 +0000 (14:56 +0200)
We need to instruct babel not to load an existing ldf in this case

lib/languages
lib/lyx2lyx/lyx_2_5.py
src/BufferParams.cpp

index a29d2470ef68dfee2f26be03da2326c380550868..6ed813da18a695cfd593214dcaf8faac9df88377 100644 (file)
@@ -891,6 +891,7 @@ Language hebrew
        GuiName          "Hebrew"
        HasGuiSupport    true
        BabelName        hebrew
+       BabelProvide     2
        PolyglossiaName  hebrew
        XindyName        hebrew
        Encoding         cp1255
index fa9641c5c9dff92581471b0d752c6c4d6e1d96d4..ef9d4afd44452a2b5077b1f93139e13459439767 100644 (file)
@@ -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
 #
index 5930aaf7b9633bfc9493c6f16c45abbdbf725747..3115e6b03bf37c8213496a50d58b544715702c0d 100644 (file)
@@ -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())