Attached is a tex2lyxpatch for branch that fixes - the detection of the document language - the setting of the quotes language for German
It is an extension to JMarcs http://www.lyx.org/trac/changeset/31440 that I committed to trunk: http://www.lyx.org/trac/changeset/31685
OK JMarc and Jürgen? regards Uwe
Index: src/tex2lyx/preamble.cpp =================================================================== --- src/tex2lyx/preamble.cpp (revision 31683) +++ src/tex2lyx/preamble.cpp (working copy) @@ -49,9 +49,6 @@ // needed to handle encodings with babel bool one_language = true; -// to avoid that the babel options overwrite the documentclass options -bool documentclass_language; - namespace { const char * const known_languages[] = { "afrikaans", "american", "arabic", @@ -140,12 +137,13 @@ string h_output_changes = "false"; string h_margins = ""; - -void handle_opt(vector<string> & opts, char const * const * what, string & target) +// returns true if at least one of the options in what has been found +bool handle_opt(vector<string> & opts, char const * const * what, string & target) { if (opts.empty()) - return; + return false; + bool found = false; // the last language option is the document language (for babel and LyX) // the last size option is the document font size vector<string>::iterator it; @@ -153,13 +151,14 @@ for (; *what; ++what) { it = find(opts.begin(), opts.end(), *what); if (it != opts.end()) { - documentclass_language = true; if (it >= position) { + found = true; target = *what; position = it; } } } + return found; } @@ -169,8 +168,7 @@ return; // remove found options from the list - // do this after handle_opt to avoid potential memory leaks and to be able - // to find in every case the last language option + // do this after handle_opt to avoid potential memory leaks vector<string>::iterator it; for (; *what; ++what) { it = find(opts.begin(), opts.end(), *what); @@ -313,30 +311,29 @@ one_language = false; h_inputencoding = "auto"; } - // only set the document language when there was not already one set - // via the documentclass options - // babel takes the the last language given in the documentclass options - // as document language. If there is no such language option, the last - // option of its \usepackage call is used. - if (documentclass_language == false) { - handle_opt(options, known_languages, h_language); - delete_opt(options, known_languages); - if (is_known(h_language, known_brazilian_languages)) - h_language = "brazilian"; - else if (is_known(h_language, known_french_languages)) - h_language = "french"; - else if (is_known(h_language, known_german_languages)) - h_language = "german"; - else if (is_known(h_language, known_ngerman_languages)) - h_language = "ngerman"; - else if (is_known(h_language, known_portuguese_languages)) - h_language = "portuguese"; - else if (is_known(h_language, known_russian_languages)) - h_language = "russian"; - else if (is_known(h_language, known_ukrainian_languages)) - h_language = "ukrainian"; - h_quotes_language = h_language; - } + // babel takes the the last language of the option of its \usepackage + // call as document language. If there is no such language option, the + // last language in the documentclass options is used. + handle_opt(options, known_languages, h_language); + delete_opt(options, known_languages); + if (is_known(h_language, known_brazilian_languages)) + h_language = "brazilian"; + else if (is_known(h_language, known_french_languages)) + h_language = "french"; + else if (is_known(h_language, known_german_languages)) + h_language = "german"; + else if (is_known(h_language, known_ngerman_languages)) + h_language = "ngerman"; + else if (is_known(h_language, known_portuguese_languages)) + h_language = "portuguese"; + else if (is_known(h_language, known_russian_languages)) + h_language = "russian"; + else if (is_known(h_language, known_ukrainian_languages)) + h_language = "ukrainian"; + h_quotes_language = h_language; + // there is only the quotes language "german" + if (h_quotes_language == "ngerman") + h_quotes_language = "german"; } else if (name == "fontenc") @@ -369,7 +366,7 @@ else if (name == "varioref") ; // ignore this - else if (name == "verbatim") + else if (name == "verbatim") ; // ignore this else if (name == "nomencl") @@ -415,6 +412,9 @@ else h_language = name; h_quotes_language = h_language; + // there is only the quotes language "german" + if (h_quotes_language == "ngerman") + h_quotes_language = "german"; } else if (name == "natbib") { @@ -655,8 +655,9 @@ string::size_type i = h_paperfontsize.find("pt"); if (i != string::npos) h_paperfontsize.erase(i); - // to avoid that the babel options overwrite the documentclass options - documentclass_language = false; + // The documentclass options are always parsed before the options + // of the babel call so that a language cannot overwrite the babel + // options. handle_opt(opts, known_languages, h_language); delete_opt(opts, known_languages); if (is_known(h_language, known_brazilian_languages)) Index: status.16x =================================================================== --- status.16x (revision 31683) +++ status.16x (working copy) @@ -141,7 +141,12 @@ the master document language, restore the master language at the end of the child rather than the child language. +- Set the correct document language when importing TeX files. +- Set the correct style for the quotes when importing TeX files which + use the new German spelling. + + * USER INTERFACE - Fix crash when finishing certain math macros such as \frac or font