]> git.lyx.org Git - lyx.git/commitdiff
Fix language options glitches
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 23 Aug 2024 14:45:52 +0000 (16:45 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Fri, 23 Aug 2024 14:46:30 +0000 (16:46 +0200)
src/BufferParams.cpp
src/LaTeXFeatures.cpp
src/frontends/qt/GuiDocument.cpp

index c26a808cd54fad6d6dc982f9cdf0e7ff4fd55557..78223fa0a7df1eb35c5a5f65bc6a86fabea955fc 100644 (file)
@@ -3498,10 +3498,13 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
        // get language options with modifiers
        bool have_mods = false;
        vector<string> blangs;
-       for (auto const & l : features.getLanguages()) {
-               if (l->babel().empty())
-                       continue;
+       std::set<Language const *> langs = features.getLanguages();
+       // add main language
+       langs.insert(language);
+       for (auto const & l : langs) {
                string blang = l->babel();
+               if (blang.empty())
+                       continue;
                if (l->babelOptFormat() == "modifier") {
                        vector<string> opts = getVectorFromString(babelLangOptions(l->lang()));
                        bool have_one = false;
index 2e1ed4328d590c862c230ad5f9e84b5332a94a71..373793833826262ff1a150fb9fb8bff12925f3a9 100644 (file)
@@ -1816,7 +1816,10 @@ docstring const LaTeXFeatures::getBabelPostsettings() const
 {
        odocstringstream tmp;
 
-       for (auto const & lang : UsedLanguages_) {
+       std::set<Language const *> langs = UsedLanguages_;
+       // add main language
+       langs.insert(bufferParams().language);
+       for (auto const & lang : langs) {
                if (!lang->babel_postsettings().empty())
                        tmp << lang->babel_postsettings() << '\n';
                if (lang->babelOptFormat() != "modifier") {
index 151d0a5913f4ef01dd185a3fb125ac24cf4cdef3..acdf9c2999d3201dcd82347a4a8ad78e3a4b65e3 100644 (file)
@@ -2564,6 +2564,8 @@ void GuiDocument::languageChanged(int i)
 
        // set appropriate quotation mark style
        updateQuoteStyles(true);
+
+       updateLanguageOptions();
 }
 
 
@@ -2860,7 +2862,13 @@ void GuiDocument::updateLanguageOptions()
        bool const use_polyglossia = extern_polyglossia
                        || (langpack != "babel" && !extern_babel
                            && fontModule->osFontsCB->isChecked());
-       for (auto const & l : buffer().getLanguages()) {
+       std::set<Language const *> langs = buffer().getLanguages();
+       // We might have a non-yet applied document language
+       QString const langname = langModule->languageCO->itemData(
+               langModule->languageCO->currentIndex()).toString();
+       Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
+       langs.insert(newlang);
+       for (auto const & l : langs) {
                QTreeWidgetItem * twi = new QTreeWidgetItem();
                twi->setData(0, Qt::DisplayRole, qt_(l->display()));
                twi->setData(0, Qt::UserRole, toqstr(l->lang()));