Jean-Marc Lasgouttes schrieb:

Let me say it again: you have the following test:
        if (language->babel().empty() && lang_opts.empty())

What is in lang_opts? There is the language of the document
(language->babel()), plus some other things (languages used in other
places of the text). Now assume that lang_opts is empty. It is not
difficult to deduce that language->babel() is also empty!

Now I get it!

Attached is your patch slightly adopted.

The patch furthermore fixes this case:

When you have e.g. a plain Chinese document without other languages, you get 
this output:

\documentclass[]{article}

The brackets should ion this case of course not be there.

Can I commit it?

regards Uwe
Index: BufferParams.cpp
===================================================================
--- BufferParams.cpp	(revision 18260)
+++ BufferParams.cpp	(working copy)
@@ -867,7 +867,7 @@
 				language_options << ',';
 			language_options << language->babel();
 		}
-		if (lyxrc.language_global_options)
+		if (lyxrc.language_global_options && !language_options.str().empty())
 			clsoptions << language_options.str() << ',';
 	}
 
@@ -1412,15 +1412,15 @@
 	if (lang_pack == "\\usepackage{babel}") {
 		// suppress the babel call when there is no babel language defined
 		// for the document language in the lib/languages file and if no
-		// other languages are used
-		if (language->babel().empty() && lang_opts.empty())
-			lang_pack.clear();
-		if (!lyxrc.language_global_options && !lang_opts.empty())
-			lang_pack = string("\\usepackage[") + lang_opts + "]{babel}";
-		if (lyxrc.language_global_options)
+		// other languages are used (lang_opts is then empty)
+		if (lang_opts.empty())
+			return string();
+		if (!lyxrc.language_global_options)
+			return string("\\usepackage[") + lang_opts + "]{babel}";
+		else
 			return lang_pack;
-	}
-	return lang_pack;
+	} else
+		return lang_pack;
 }
 
 

Reply via email to