&& !data.par_language->polyglossiaOpts().empty())
os << "["
<< from_ascii(data.par_language->polyglossiaOpts())
&& !data.par_language->polyglossiaOpts().empty())
os << "["
<< from_ascii(data.par_language->polyglossiaOpts())
// This is for debugging purpose at the end.
pit_type const par_begin = pit;
for (; pit < runparams.par_end; ++pit) {
// This is for debugging purpose at the end.
pit_type const par_begin = pit;
for (; pit < runparams.par_end; ++pit) {
ParagraphList::const_iterator par = paragraphs.constIterator(pit);
// check first if this is an higher depth paragraph.
ParagraphList::const_iterator par = paragraphs.constIterator(pit);
// check first if this is an higher depth paragraph.
// be two for Standard paragraphs that are depth-increment'ed to be
// output correctly. However, tables can also be paragraphs so
// don't adjust them.
// be two for Standard paragraphs that are depth-increment'ed to be
// output correctly. However, tables can also be paragraphs so
// don't adjust them.
// language paragraph should appear within an \L or \R (in addition
// to, outside of, the normal language switch commands).
// This behavior is not correct for ArabTeX, though.
// language paragraph should appear within an \L or \R (in addition
// to, outside of, the normal language switch commands).
// This behavior is not correct for ArabTeX, though.
switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
switch (style.latextype) {
case LATEX_ITEM_ENVIRONMENT:
case LATEX_LIST_ENVIRONMENT:
// Closing the language is needed for the last paragraph; it is also
// needed if we're within an \L or \R that we may have opened above (not
// necessarily in this paragraph) and are about to close.
// Closing the language is needed for the last paragraph; it is also
// needed if we're within an \L or \R that we may have opened above (not
// necessarily in this paragraph) and are about to close.
|| (runparams.isLastPar && par_language->babel() != outer_language->babel()));
if (closing_rtl_ltr_environment
|| (runparams.isLastPar && par_language->babel() != outer_language->babel()));
if (closing_rtl_ltr_environment
- || (runparams.isLastPar && par_language->babel() != outer_language->babel())) {
+ || (runparams.isLastPar
+ && ((!use_polyglossia && par_language->babel() != outer_language->babel())
+ || (use_polyglossia && par_language->polyglossia() != outer_language->polyglossia())))) {
// Since \selectlanguage write the language to the aux file,
// we need to reset the language at the end of footnote or
// float.
// Since \selectlanguage write the language to the aux file,
// we need to reset the language at the end of footnote or
// float.
? getPolyglossiaEnvName(current_language)
: current_language->babel();
if (!current_lang.empty()) {
? getPolyglossiaEnvName(current_language)
: current_language->babel();
if (!current_lang.empty()) {
// if this is a CJK-paragraph and the next isn't, close CJK
// also if the next paragraph is a multilingual environment (because of nesting)
// if this is a CJK-paragraph and the next isn't, close CJK
// also if the next paragraph is a multilingual environment (because of nesting)