]> git.lyx.org Git - lyx.git/commitdiff
revert_language: fix document language assignment
authorJuergen Spitzmueller <spitz@lyx.org>
Mon, 11 Mar 2019 10:42:54 +0000 (11:42 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Mon, 11 Mar 2019 10:42:54 +0000 (11:42 +0100)
lib/lyx2lyx/lyx2lyx_tools.py

index 6c0f5aa819e6ad7036eb72d3b10dd6b042a4aef5..75a5c820def0b75b958f5b13505e2780ff08fcec 100644 (file)
@@ -644,6 +644,7 @@ def revert_language(document, lyxname, babelname, polyglossianame):
     primary = False
     secondary = False
 
+    orig_doc_language = document.language
     # Main language first
     if document.language == lyxname:
         primary = True
@@ -761,14 +762,14 @@ def revert_language(document, lyxname, babelname, polyglossianame):
     # With babel, we need to add the language options
     if with_babel and (primary or secondary):
         insert_document_option(document, babelname)
-        if secondary and document.body[10] != "selectlanguage{%s}" % document.language:
+        if secondary and document.body[10] != "selectlanguage{%s}" % orig_doc_language:
             # Since the user options are always placed after the babel options,
             # we need to reset the main language
             document.body[2 : 2] = ["\\begin_layout Standard",
                                     "\\begin_inset ERT", "status open", "",
                                     "\\begin_layout Plain Layout", "", "",
                                     "\\backslash",
-                                    "selectlanguage{%s}" % document.language,
+                                    "selectlanguage{%s}" % orig_doc_language,
                                     "\\end_layout", "", "\\end_inset", "", "",
                                     "\\end_layout", ""]