@@ -112,20 +112,6 @@ $endif$
112112$if(geometry)$
113113\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
114114$endif$
115−$if(lang)$
116−\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
117− \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
118−$if(babel-newcommands)$
119− $babel-newcommands$
120−$endif$
121−\else
122− \usepackage{polyglossia}
123− \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
124−$for(polyglossia-otherlangs)$
125− \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
126−$endfor$
127−\fi
128−$endif$
129115$if(natbib)$
130116\usepackage{natbib}
131117\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
@@ -191,6 +177,21 @@ $else$
191177\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
192178\fi
193179$endif$
180+$if(lang)$
181+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
182+ \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
183+$if(babel-newcommands)$
184+ $babel-newcommands$
185+$endif$
186+\else
187+ % load polyglossia as late as possible as it *could* call bidi if RTL lang (e.g. Hebrew or Arabic)
188+ \usepackage{polyglossia}
189+ \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}
190+$for(polyglossia-otherlangs)$
191+ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}
192+$endfor$
193+\fi
194+$endif$
194195$if(dir)$
195196\ifxetex
196197 % load bidi as late as possible as it modifies e.g. graphicx