Am Dienstag, den 01.11.2016, 13:43 +0100 schrieb Jürgen Spitzmüller: > The second bug is that OutputParams::LUATEX does not use > polyglossia's > language varieties in the \setotherlanguage macro. This is what > causes > the LaTeX errors.
I've solved this part of the puzzle. In LaTeXFeatures::getPolyglossiaLanguages(), we used a map<string, string> to collect the polyglossia languages and varieties. The polyglossia name was the key. Now when we have two varieties of a language, only one is recorded, since the key must be unique. In the given case, the empty variety of "english" overwrote the variety option of "british". In other cases, when british was recorded after english, the opposite happened. Having thought about this whole thing carefully, I came to the conclusion that we should not output the language options in \setotherlanguage at all. Why? Because they are output in the language switching commands anyway, and if we have multiple varieties, we run into trouble. However, it also became clear to me that we need to output also the standard varieties of the languages. Consider a document with default language austrian and other language german. This would come out as: \setdefaultlanguage[variant=austrian,babelshorthands=true]{german} \begin{document} Austrian \textgerman[babelshorthands=true]{German} \end{document} whereas it is supposed to be \setdefaultlanguage[variant=austrian,babelshorthands=true]{german} \begin{document} Austrian \textgerman[variant=german,babelshorthands=true]{German} \end{document} All this is addressed by the attached patch. Thoughts? Jürgen
diff --git a/lib/languages b/lib/languages index d56d030..7c98444 100644 --- a/lib/languages +++ b/lib/languages @@ -138,7 +138,7 @@ Language ancientgreek \languageattribute{greek}{ancient} EndPostBabelPreamble PolyglossiaName greek - PolyglossiaOpts variant=ancient + PolyglossiaOpts "variant=ancient" QuoteStyle french Encoding iso8859-7 InternalEncoding true @@ -409,6 +409,7 @@ Language english HasGuiSupport true BabelName english PolyglossiaName english + PolyglossiaOpts "variant=american" QuoteStyle english Encoding iso8859-15 LangCode en_US @@ -507,7 +508,7 @@ Language german GuiName "German (old spelling)" BabelName german PolyglossiaName german - PolyglossiaOpts "spelling=old,babelshorthands=true" + PolyglossiaOpts "variant=german,spelling=old,babelshorthands=true" QuoteStyle german Encoding iso8859-15 LangCode de @@ -519,7 +520,7 @@ Language ngerman HasGuiSupport true BabelName ngerman PolyglossiaName german - PolyglossiaOpts "babelshorthands=true" + PolyglossiaOpts "variant=german,babelshorthands=true" QuoteStyle german Encoding iso8859-15 LangCode de_DE @@ -559,6 +560,7 @@ Language greek HasGuiSupport true BabelName greek PolyglossiaName greek + PolyglossiaOpts "variant=monotonic" QuoteStyle french Encoding iso8859-7 InternalEncoding true @@ -909,6 +911,7 @@ Language serbian HasGuiSupport true BabelName serbianc PolyglossiaName serbian + PolyglossiaOpts "script=cyrillic" QuoteStyle german Encoding utf8 FontEncoding T2A @@ -920,7 +923,7 @@ Language serbian-latin GuiName "Serbian (Latin)" BabelName serbian PolyglossiaName serbian - PolyglossiaOpts "script=Latin" + PolyglossiaOpts "script=latin" QuoteStyle german Encoding iso8859-2 LangCode sr_RS-Latin diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 6af82c1..3f0f44a 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -2173,14 +2173,17 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features, lyxpreamble += "[" + from_ascii(language->polyglossiaOpts()) + "]"; lyxpreamble += "{" + from_ascii(language->polyglossia()) + "}\n"; // now setup the other languages - std::map<std::string, std::string> const polylangs = + set<string> const polylangs = features.getPolyglossiaLanguages(); - for (std::map<std::string, std::string>::const_iterator mit = polylangs.begin(); + for (set<string>::const_iterator mit = polylangs.begin(); mit != polylangs.end() ; ++mit) { + // We do not output the options here; they are output in + // the language switch commands. This is safer if multiple + // varieties are used. + if (*mit == language->polyglossia()) + continue; lyxpreamble += "\\setotherlanguage"; - if (!mit->second.empty()) - lyxpreamble += "[" + from_ascii(mit->second) + "]"; - lyxpreamble += "{" + from_ascii(mit->first) + "}\n"; + lyxpreamble += "{" + from_ascii(*mit) + "}\n"; } } diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 96f0ced..15d4370 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -740,15 +740,16 @@ string LaTeXFeatures::getBabelLanguages() const } -std::map<std::string, std::string> LaTeXFeatures::getPolyglossiaLanguages() const +set<string> LaTeXFeatures::getPolyglossiaLanguages() const { - std::map<std::string, std::string> languages; + set<string> languages; LanguageList::const_iterator const begin = UsedLanguages_.begin(); for (LanguageList::const_iterator cit = begin; cit != UsedLanguages_.end(); ++cit) { - languages[(*cit)->polyglossia()] = (*cit)->polyglossiaOpts(); + // We do not need the variants here + languages.insert((*cit)->polyglossia()); } return languages; } diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 6c3e888..9bf0f62 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -129,7 +129,7 @@ public: /// std::string getBabelLanguages() const; /// - std::map<std::string, std::string> getPolyglossiaLanguages() const; + std::set<std::string> getPolyglossiaLanguages() const; /// std::set<std::string> getEncodingSet(std::string const & doc_encoding) const; ///
signature.asc
Description: This is a digitally signed message part