Fix usage of multiple varieties of the same polyglossia language.

1. We must always output all (diverging) options, including
   default options; if not, default options might get overwritten.

2. Do not output options in \setotherlanguage, since we might have
   multiple "other languages" varieties from the same language (such
   as naustrian, nswissgerman). And the options are output for the
   language switches anyway.

Hence, LaTeXFeatures::getPolyglossiaLanguages() does not have to record
varieties. This was not done correctly anyway, since the map allowed
for one entry per language only.
This commit is contained in:
Juergen Spitzmueller 2016-11-02 17:07:49 +01:00
parent 24066805af
commit 3374b8548b
4 changed files with 30 additions and 16 deletions

View File

@ -30,6 +30,9 @@
#
# NOTES:
#
# * If we provide Polyglossia languages with different options, the default
# options (such as "variant=american", "spelling=modern") should be
# explicitely spelled out (in order to provide mixing of such variants).
# * Omitted elements will be treated as empty (if string) or "false"
# (if boolean).
# * When HasGuiSupport is true, the language is candidate to appear in
@ -146,7 +149,7 @@ Language ancientgreek
\languageattribute{greek}{ancient}
EndPostBabelPreamble
PolyglossiaName greek
PolyglossiaOpts variant=ancient
PolyglossiaOpts "variant=ancient"
QuoteStyle french
Encoding iso8859-7
InternalEncoding true
@ -225,7 +228,7 @@ Language naustrian
GuiName "German (Austria)"
BabelName naustrian
PolyglossiaName german
PolyglossiaOpts "variant=austrian,babelshorthands=true"
PolyglossiaOpts "variant=austrian,spelling=new,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
LangCode de_AT
@ -333,6 +336,8 @@ Language canadian
End
# not yet supported by polyglossia
# Note: If polyglossia support gets implemented, french needs
# PolyglossiaOpts "variant=french"
Language canadien
GuiName "French (Canada)"
BabelName canadien
@ -435,6 +440,7 @@ Language english
HasGuiSupport true
BabelName english
PolyglossiaName english
PolyglossiaOpts "variant=american"
QuoteStyle english
Encoding iso8859-15
LangCode en_US
@ -543,7 +549,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
@ -555,7 +561,7 @@ Language ngerman
HasGuiSupport true
BabelName ngerman
PolyglossiaName german
PolyglossiaOpts "babelshorthands=true"
PolyglossiaOpts "variant=german,spelling=new,babelshorthands=true"
QuoteStyle german
Encoding iso8859-15
LangCode de_DE
@ -569,7 +575,7 @@ Language german-ch
GuiName "German (Switzerland)"
BabelName nswissgerman
PolyglossiaName german
PolyglossiaOpts "variant=swiss,babelshorthands=true"
PolyglossiaOpts "variant=swiss,spelling=new,babelshorthands=true"
QuoteStyle danish
Encoding iso8859-15
LangCode de_CH
@ -593,6 +599,7 @@ Language greek
HasGuiSupport true
BabelName greek
PolyglossiaName greek
PolyglossiaOpts "variant=monotonic"
QuoteStyle french
Encoding iso8859-7
InternalEncoding true
@ -890,10 +897,12 @@ End
# Currently not supported (file format change!)
# Russian orthography from the Petrine orthographic reforms of
# 1708 to the 1917 orthographic reform
# Note: If this is enabled, russian needs to get
# PolyglossiaOpts "spelling=modern"
# Language oldrussian
# GuiName "Russian (Petrine orthography)"
# PolyglossiaName russian
# PolyglossiaOpts spelling=old
# PolyglossiaOpts "spelling=old"
# LangCode ru_petr1708
# End
@ -989,6 +998,7 @@ Language serbian
HasGuiSupport true
BabelName serbianc
PolyglossiaName serbian
PolyglossiaOpts "script=cyrillic"
QuoteStyle german
Encoding utf8
FontEncoding T2A
@ -1000,7 +1010,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

View File

@ -2182,14 +2182,17 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
os << "[" << from_ascii(language->polyglossiaOpts()) << "]";
os << "{" << 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;
os << "\\setotherlanguage";
if (!mit->second.empty())
os << "[" << from_ascii(mit->second) << "]";
os << "{" << from_ascii(mit->first) << "}\n";
os << "{" << from_ascii(*mit) << "}\n";
}
}

View File

@ -793,15 +793,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;
}

View File

@ -131,7 +131,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;
///