[LyX/master] Provide babel language options only for languages that have options

Juergen Spitzmueller spitz at lyx.org
Sat Aug 24 02:52:21 UTC 2024


commit 285f467f24aeedd54821ccd0b751ba59fab3a4c5
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat Aug 24 04:51:45 2024 +0200

    Provide babel language options only for languages that have options
---
 lib/languages                    | 14 +++++++++++++-
 src/Language.cpp                 |  1 -
 src/frontends/qt/GuiDocument.cpp |  2 ++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/languages b/lib/languages
index 04b3cfed14..9c5ba04a4c 100644
--- a/lib/languages
+++ b/lib/languages
@@ -131,7 +131,8 @@
 #   if a corresponding language module exists.
 # * BabelOptFormat specifies how the language-specific options shall be
 #   passed with babel (which differs between languages).
-#   Default is \languageattribute{$lang$}{$opts$}
+#   You can use the placeholders $lang$ and $opts$ (as in
+#   \languageattribute{$lang$}{$opts$})
 #   The special value "modifier" indicates to use babel modifiers.
 #
 ##########################################################################
@@ -217,6 +218,7 @@ End
 Language ancientgreek
 	GuiName          "Greek (ancient)"
 	BabelName        greek
+	BabelOptFormat   modifier
 	PostBabelPreamble
 	\languageattribute{greek}{ancient}
 	EndPostBabelPreamble
@@ -404,6 +406,7 @@ End
 Language belarusian
 	GuiName          "Belarusian"
 	BabelName        belarusian
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  belarusian
 	XindyName        belarusian
 	QuoteStyle       french
@@ -477,6 +480,7 @@ Language bulgarian
 	GuiName          "Bulgarian"
 	HasGuiSupport    true
 	BabelName        bulgarian
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  bulgarian
 	XindyName        bulgarian
 	QuoteStyle       german
@@ -588,6 +592,7 @@ Language czech
 	GuiName          "Czech"
 	HasGuiSupport    true
 	BabelName        czech
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  czech
 	XindyName        czech
 	QuoteStyle       german
@@ -834,6 +839,7 @@ Language greek
 	GuiName          "Greek"
 	HasGuiSupport    true
 	BabelName        greek
+	BabelOptFormat   modifier
 	PolyglossiaName  greek
 	PolyglossiaOpts  "variant=monotonic"
 	XindyName        greek
@@ -849,6 +855,7 @@ End
 Language polutonikogreek
 	GuiName          "Greek (polytonic)"
 	BabelName        polutonikogreek
+	BabelOptFormat   modifier
 	PolyglossiaName  greek
 	PolyglossiaOpts  "variant=polytonic"
 	XindyName        greek
@@ -956,6 +963,7 @@ Language japanese
 	GuiName          "Japanese"
 	HasGuiSupport    true
 	BabelName        japanese
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	Encoding         jis-platex
 	WordWrap         false
 	LangCode         ja_JP
@@ -1028,6 +1036,7 @@ End
 Language kurmanji
 	GuiName          "Kurdish (Kurmanji)"
 	BabelName        kurmanji
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  kurdish
 	XindyName        kurdish-bedirxan
 	PolyglossiaOpts  "variant=kurmanji"
@@ -1328,6 +1337,7 @@ Language russian
 	GuiName          "Russian"
 	HasGuiSupport    true
 	BabelName        russian
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  russian
 	PolyglossiaOpts  "spelling=modern"
 	XindyName        russian
@@ -1398,6 +1408,7 @@ End
 Language serbian-latin
 	GuiName          "Serbian (Latin)"
 	BabelName        serbian
+	BabelOptFormat   modifier
 	PolyglossiaName  serbian
 	PolyglossiaOpts  "script=Latin"
 	XindyName        croatian
@@ -1412,6 +1423,7 @@ Language slovak
 	GuiName          "Slovak"
 	HasGuiSupport    true
 	BabelName        slovak
+	BabelOptFormat   \languageattribute{$lang$}{$opts$}
 	PolyglossiaName  slovak
 	XindyName        slovak-large
 	QuoteStyle       german
diff --git a/src/Language.cpp b/src/Language.cpp
index 5fe1482fa8..c8d77411b1 100644
--- a/src/Language.cpp
+++ b/src/Language.cpp
@@ -288,7 +288,6 @@ bool Language::read(Lexer & lex)
 	encoding_ = nullptr;
 	internal_enc_ = false;
 	rightToLeft_ = false;
-	babeloptformat_ = "\\languageattribute{$lang$}{$opts$}";
 
 	if (!lex.next()) {
 		lex.printError("No name given for language: `$$Token'.");
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index acdf9c2999..32f98006d4 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -2869,6 +2869,8 @@ void GuiDocument::updateLanguageOptions()
 	Language const * newlang = lyx::languages.getLanguage(fromqstr(langname));
 	langs.insert(newlang);
 	for (auto const & l : langs) {
+		if (!use_polyglossia && l->babelOptFormat().empty())
+			continue;
 		QTreeWidgetItem * twi = new QTreeWidgetItem();
 		twi->setData(0, Qt::DisplayRole, qt_(l->display()));
 		twi->setData(0, Qt::UserRole, toqstr(l->lang()));


More information about the lyx-cvs mailing list