error handling if language is changed
If I compile a simple document say using english as language:
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\begin{document}
blub
\end{document}
and then switch from english to e.g. brazil the remaining \selectlanguage in the aux-file triggers tons of error and then hangs. See below.
Could this please be improved? I know that I can delete all auxiliary files first, but it slows down testing and debugging a lot if you have to do that all the time. A similar test with babel gives no error at all but only a warning about the unknown language.
! Critical Package polyglossia Error: The language english is not loaded. You
(polyglossia) should load it.
Type <return> to continue.
...
l.2 \selectlanguage *{english}
?
! Package polyglossia Error: Unknown direction .
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
! Undefined control sequence.
<argument> \setnonlatin
l.2 \selectlanguage *{english}
?
! Package etoolbox Error: \rmfamily undefined.
See the etoolbox package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
! Package etoolbox Error: \sffamily undefined.
See the etoolbox package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
! Package etoolbox Error: \ttfamily undefined.
See the etoolbox package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
Package polyglossia Warning: \@font@rm is not defined on input line 2.
Package polyglossia Warning: \@language is not defined on input line 2.
! Package polyglossia Error: language is not loaded. Please load it before usi
ng it..
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
! Package polyglossia Error: Could not retrieve key frenchspacing for language
"".
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
The property list \polyglossia@langsetup contains the pairs (without outer
braces):
> {latex/script} => {latin}
> {latex/lcscript} => {latin}
> {latex/scripttag} => {}
> {latex/language} => {Latex}
> {latex/langtag} => {ENG}
> {latex/bcp47} => {}
> {latex/hyphennames} => {english}
> {latex/direction} => {LR}
> {latex/hyphenmins} => {2,3}
> {latex/frenchspacing} => {false}
> {latex/indentfirst} => {false}
> {latex/fontsetup} => {true}
> {latex/envname} => {latex}
> {latex/babelname} => {latex}
> {latex/localnumeral} => {polyglossia@C@localnumeral}
> {latex/Localnumeral} => {polyglossia@C@localnumeral}
> {latex/DefineCommandsCmd} => {use_none:n}
> {portuguese/script} => {latin}
> {portuguese/lcscript} => {latin}
> {portuguese/scripttag} => {}
> {portuguese/language} => {Portuguese}
> {portuguese/langtag} => {PTG}
> {portuguese/bcp47} => {pt-BR}
> {portuguese/hyphennames} => {portuges,portuguese}
> {portuguese/direction} => {LR}
> {portuguese/hyphenmins} => {2,3}
> {portuguese/frenchspacing} => {false}
> {portuguese/indentfirst} => {false}
> {portuguese/fontsetup} => {true}
> {portuguese/envname} => {portuguese}
> {portuguese/babelname} => {brazil}
> {portuguese/localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/Localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/DefineCommandsCmd} => {xpg_define_language_commands:e}.
<recently read> }
l.2 \selectlanguage *{english}
?
! Package polyglossia Error: Could not retrieve key direction for language "".
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
The property list \polyglossia@langsetup contains the pairs (without outer
braces):
> {latex/script} => {latin}
> {latex/lcscript} => {latin}
> {latex/scripttag} => {}
> {latex/language} => {Latex}
> {latex/langtag} => {ENG}
> {latex/bcp47} => {}
> {latex/hyphennames} => {english}
> {latex/direction} => {LR}
> {latex/hyphenmins} => {2,3}
> {latex/frenchspacing} => {false}
> {latex/indentfirst} => {false}
> {latex/fontsetup} => {true}
> {latex/envname} => {latex}
> {latex/babelname} => {latex}
> {latex/localnumeral} => {polyglossia@C@localnumeral}
> {latex/Localnumeral} => {polyglossia@C@localnumeral}
> {latex/DefineCommandsCmd} => {use_none:n}
> {portuguese/script} => {latin}
> {portuguese/lcscript} => {latin}
> {portuguese/scripttag} => {}
> {portuguese/language} => {Portuguese}
> {portuguese/langtag} => {PTG}
> {portuguese/bcp47} => {pt-BR}
> {portuguese/hyphennames} => {portuges,portuguese}
> {portuguese/direction} => {LR}
> {portuguese/hyphenmins} => {2,3}
> {portuguese/frenchspacing} => {false}
> {portuguese/indentfirst} => {false}
> {portuguese/fontsetup} => {true}
> {portuguese/envname} => {portuguese}
> {portuguese/babelname} => {brazil}
> {portuguese/localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/Localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/DefineCommandsCmd} => {xpg_define_language_commands:e}.
<recently read> }
l.2 \selectlanguage *{english}
?
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
! Package polyglossia Error: Could not retrieve key indentfirst for language ""
.
See the polyglossia package documentation for explanation.
Type H <return> for immediate help.
...
l.2 \selectlanguage *{english}
?
The property list \polyglossia@langsetup contains the pairs (without outer
braces):
> {latex/script} => {latin}
> {latex/lcscript} => {latin}
> {latex/scripttag} => {}
> {latex/language} => {Latex}
> {latex/langtag} => {ENG}
> {latex/bcp47} => {}
> {latex/hyphennames} => {english}
> {latex/direction} => {LR}
> {latex/hyphenmins} => {2,3}
> {latex/frenchspacing} => {false}
> {latex/indentfirst} => {false}
> {latex/fontsetup} => {true}
> {latex/envname} => {latex}
> {latex/babelname} => {latex}
> {latex/localnumeral} => {polyglossia@C@localnumeral}
> {latex/Localnumeral} => {polyglossia@C@localnumeral}
> {latex/DefineCommandsCmd} => {use_none:n}
> {portuguese/script} => {latin}
> {portuguese/lcscript} => {latin}
> {portuguese/scripttag} => {}
> {portuguese/language} => {Portuguese}
> {portuguese/langtag} => {PTG}
> {portuguese/bcp47} => {pt-BR}
> {portuguese/hyphennames} => {portuges,portuguese}
> {portuguese/direction} => {LR}
> {portuguese/hyphenmins} => {2,3}
> {portuguese/frenchspacing} => {false}
> {portuguese/indentfirst} => {false}
> {portuguese/fontsetup} => {true}
> {portuguese/envname} => {portuguese}
> {portuguese/babelname} => {brazil}
> {portuguese/localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/Localnumeral} => {polyglossia@C@localnumeral}
> {portuguese/DefineCommandsCmd} => {xpg_define_language_commands:e}.
<recently read> }
l.2 \selectlanguage *{english}
?
Fixed. We now use a special \xselectlanguage command in the aux file that does only warn, not error.
well that resolves the problem in the aux. But if one uses an unknown language in the document polyglossia gets also into the error frenzy and then hangs:
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{german}
\begin{document}
aaa
\selectlanguage{french}
bbb
\end{document}
I don't understand it. It does detect that the language is not declared. Then why does it nevertheless try to set it up? It should be trivial to change \__xpg_msg_if_lang_not_loaded:n to a proper test that aborts in this case.
Sure, but that's not the issue you reported. I'll have a look.
We bail out early now.