texlive[62940] Master/texmf-dist: polyglossia (27mar22)

commits+karl at tug.org commits+karl at tug.org
Wed Apr 6 00:10:53 CEST 2022


Revision: 62940
          http://tug.org/svn/texlive?view=revision&revision=62940
Author:   karl
Date:     2022-04-06 00:10:52 +0200 (Wed, 06 Apr 2022)
Log Message:
-----------
polyglossia (27mar22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/polyglossia/README.md
    trunk/Master/texmf-dist/doc/latex/polyglossia/example-arabic.pdf
    trunk/Master/texmf-dist/doc/latex/polyglossia/example-korean.pdf
    trunk/Master/texmf-dist/doc/latex/polyglossia/example-thai.pdf
    trunk/Master/texmf-dist/doc/latex/polyglossia/examples.pdf
    trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.pdf
    trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.tex
    trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty

Removed Paths:
-------------
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polyglossia/README.md	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/doc/latex/polyglossia/README.md	2022-04-05 22:10:52 UTC (rev 62940)
@@ -1,4 +1,4 @@
-# THE POLYGLOSSIA PACKAGE v1.51
+# THE POLYGLOSSIA PACKAGE v1.54
 ## Multilingual typesetting with XeLaTeX and LuaLaTeX
 
 This package provides an alternative to Babel for users of XeLaTeX and LuaLaTeX.
@@ -26,8 +26,8 @@
 
 # LICENCE
 
-Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2021 Arthur Reutenauer,
-Copyright (c) 2019-2021 Bastien Roucariès, 2019-2021 Jürgen Spitzmüller
+Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2022 Arthur Reutenauer,
+Copyright (c) 2019-2022 Bastien Roucariès, 2019-2022 Jürgen Spitzmüller
 
 Except where otherwise noted, Polyglossia is placed under the terms of the MIT licence
 (https://opensource.org/licenses/MIT).

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/example-arabic.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/example-korean.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/example-thai.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/examples.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.tex	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.tex	2022-04-05 22:10:52 UTC (rev 62940)
@@ -1,7 +1,7 @@
 % !TeX spellcheck = en_US
 % !TeX TS-program = xelatex
 \documentclass[11pt]{ltxdoc}
-\usepackage{color}
+\usepackage{xcolor}
 \usepackage{xspace,fancyvrb,longtable,booktabs}
 \usepackage[neverdecrease]{paralist}
 \usepackage[format=hang,labelfont=bf,labelsep=period]{caption}
@@ -129,7 +129,7 @@
 \color{xpgblue}Polyglossia: Modern multilingual typesetting with \XeLaTeX\ and \LuaLaTeX}
 \author{\TA{François Charette} \and \TA{Arthur Reutenauer}\thanks{Current maintainer}
 	    \and \TA{Bastien Roucariès} \and \TA{Jürgen Spitzmüller}}
-\date{\filedate \qquad \fileversion\\
+\date{\filedate \qquad \fileversion\thanks{Please report bugs to \url{http://github.com/reutenauer/polyglossia/issues}}\\
 \footnotesize (\textsc{pdf} file generated on \today)}
 
 \maketitle
@@ -302,11 +302,9 @@
 british            & english    & variant=british                     \\
 canadian           & english    & variant=canadian                    \\
 canadien           & french     & variant=canadian                    \\
-classiclatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.classic}).}
-                   & latin      & variant=classic                     \\
+classiclatin       & latin      & variant=classic                     \\
 farsi              & persian    &                                     \\
-ecclesiasticlatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.ecclesiastic}).}
-                   & latin      & variant=ecclesiastic                \\
+ecclesiasticlatin  & latin      & variant=ecclesiastic                \\
 friulan            & friulian   &                                     \\
 german\footnote{Due to the name conflict only available in \pkg{polyglossia} as \emph{germanb} (which is a \pkg{babel} synonym).}
                    & german     & spelling=old                        \\
@@ -314,8 +312,7 @@
 kurmanji           & kurdish    & variant=kurmanji                    \\
 lowersorbian       & sorbian    & variant=lower                       \\
 magyar             & hungarian  &                                     \\
-medievallatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.medieval}).}
-                   & latin      & variant=medieval                    \\
+medievallatin      & latin      & variant=medieval                    \\
 naustrian          & german     & variant=austrian                    \\
 newzealand         & english    & variant=newzealand                  \\
 ngerman            & german     & variant=german [\emph{default}]     \\
@@ -334,7 +331,7 @@
 \bottomrule
 \end{tabular}
 \end{minipage}
-	
+
 \end{table}
 
 For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{1.46} (for the few justified
@@ -831,7 +828,7 @@
 \paragraph*{Commands:}
 	\begin{itemize}
 	\item \Cmd\abjad outputs Arabic \textit{abjad} numbers according to the Mashriq varieties.
-	      Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.	
+	      Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.
 	\item \Cmd\abjadmaghribi outputs Arabic \textit{abjad} numbers according to the Maghrib varieties.
 	       Example: ¦\abjadmaghribi{1863}¦ yields \textarabic{\abjadmaghribi{1863}}.
 	\item \Cmd\abjadalph\new{1.50} steps through the Arabic alphabet, thus it can only be used up to 28.
@@ -947,17 +944,17 @@
 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
 		            at the breakpoints preset in the hyphenation patterns is still allowed.
 	\end{shorthands}
-	Furthermore, the following shorthands generate easy access to Croatian digraphs (ligatures):
+	Furthermore, the following shorthands generate easy access to Croatian digraphs:
 	\begin{shorthands}
-		\item[¦"dz¦] Generates the ligature \charifavailable{01C6}{dž}\ if the font provides it. If not, the
-		             two characters are output separately. Also available for ¦"Dz¦ (\charifavailable{01C5}{Dž})
-		             and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
-		\item[¦"lj¦] Generates the ligature \charifavailable{01C9}{lj}\ if the font provides it. If not, the
-		             two characters are output separately. Also available for ¦"Lj¦ (\charifavailable{01C8}{Lj})
-		             and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
-		\item[¦"nj¦] Generates the ligature \charifavailable{01CC}{nj}\ if the font provides it. If not, the
-		             two characters are output separately. Also available for ¦"Nj¦ (\charifavailable{01CB}{Nj})
-		             and ¦"NJ¦ (\charifavailable{01CA}{NJ}).
+		\item[¦"dz¦] Generates the digraph \charifavailable{01C6}{dž}\ if the font provides it. If not,
+		             the two consecutive glyphs are output mimicking the digraph. Also available for
+		             ¦"Dz¦ (\charifavailable{01C5}{Dž}) and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
+		\item[¦"lj¦] Generates the digraph \charifavailable{01C9}{lj}\ if the font provides it. If not,
+		             the two consecutive glyphs are output mimicking the digraph. Also available for
+		             ¦"Lj¦ (\charifavailable{01C8}{Lj}) and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
+		\item[¦"nj¦] Generates the digraph \charifavailable{01CC}{nj}\ if the font provides it. If not,
+		             the two consecutive glyphs are output mimicking the digraph. Also available for
+		             ¦"Nj¦ (\charifavailable{01CB}{Nj}) and ¦"NJ¦ (\charifavailable{01CA}{NJ}).
 	\end{shorthands}
 	
 	Finally, there are also four shorthands for quotation marks:
@@ -967,19 +964,21 @@
 		\item[¦">¦] for Croatian left guillemets (»).
 		\item[¦"<¦] for Croatian right guillemets («).
 	\end{shorthands}
-	\item \xpgboolkeyfalse[1.47]{disableligatures}
-		If this is \xpgvalue{true}, all Croatian ligatures (for digraphs such as
-		\charifavailable{01C6}{dž}) will be replaced by single characters. This can
-		be useful if the ligatures on your font are broken (if the font does not
-		have them, they are automatically replaced).
+	\item \xpgboolkeyfalse[1.47]{disabledigraphs}[Up to version 1.53, the option was
+		called \xpgvalue{disableligatures}. The old option is kept for backwards compatibility,
+		but the use is discouraged.] If this is \xpgvalue{true}, all Croatian digraphs
+		(such as \charifavailable{01C6}{dž}) will be replaced by the two consecutive letters,
+		which is the most common way of typesetting them in Croatian. This can be useful if
+		the Unicode digraphs in your font are broken (if the font does not have them,
+		they are automatically mimicked by the two consecutive glyphs).
 	\item \xpgboolkeytrue[1.53]{localalph}
 		If \xpgvalue{true}, alphanumeric counters will use a locally established version which excludes
 		the characters \meta{q}, \meta{w}, \meta{x} and \meta{y} from alphabetic counting.
 		Obviously this limits the counting range to 22.
     \item \xpgboolkeytrue[1.51]{splithyphens}
-	    According to Croatian typesetting conventions, if a word with a hard hyphen (such as \emph{je-li})
-	    is hyphenated at this hyphen, a second hyphenation character is to be inserted at the beginning
-	    of the line that follows the hyphenation (\emph{je-/-li}).
+	    According to Croatian typesetting conventions, if a word with a hard hyphen (such as
+	    \emph{hrvatsko-engleski}) is hyphenated at this hyphen, a second hyphenation character is to be
+	    inserted at the beginning of the line that follows the hyphenation (\emph{hrvatsko-/-engleski}).
 	    By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
 	    loaded to achieve this).
 	    Set this option to ¦false¦ to disable the feature.
@@ -1067,6 +1066,13 @@
         \item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
                   hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
 		\end{shorthands}
+  \item \xpgboolkeyfalse[1.54]{schoolhyphens}
+	    If this is set to true, alternative (experimental) hyphenation patterns are used rather than the
+	    default Finnish patterns. These patterns (called `School Hyphenation') are more basic in that
+	    they do not contain hyphenation exceptions for compound words since these result in simple words
+	    not being hyphenated at points where this would be valid. The backdrop of the  `School' patterns
+	    is that compound words might be hyphenated incorrectly.
+	    See \url{https://github.com/hyphenation/basic-finnish} for details.
 \end{itemize}
 
 \subsection{french}\label{french}
@@ -1498,16 +1504,22 @@
 				\item[¦=A¦] for Ā (A with macron), also available for Ē, Ī, Ō, Ū, V̄, and Ȳ.
 					Note that a macron above the letter V is only displayed if your font
 					supports the Unicode character ¦0304¦ (\emph{combining macron}).
-				\item[¦=ae¦] for a͞e (ae diphthong with macron), also available for a͞u, e͞u,
-					and o͞e. Note that macrons above diphthongs are only displayed if your font
-					supports the Unicode character ¦035E¦ (\emph{combining double
+				\item[¦=ae¦] for a͞e (ae diphthong with macron, for the ¦classic¦ and
+					the ¦modern¦ variant) or ǣ (ae ligature with macron, for the ¦medieval¦
+					and the ¦ecclesiastic¦ variant), respectively; also available for a͞u,
+					e͞u, and o͞e/œ̄. Note that macrons above diphthongs are only displayed if
+					your font supports the Unicode character ¦035E¦ (\emph{combining double
 					macron}).
-				\item[¦=Ae¦] for A͞e (Ae diphthong with macron), also available for A͞u, E͞u,
-					and O͞e.
-				\item[¦=AE¦] for A͞E (AE diphthong with macron), also available for A͞U, E͞U,
-					and O͞E.
+				\item[¦=Ae¦] for A͞e (Ae diphthong with macron, for the ¦classic¦ and
+					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
+					and the ¦ecclesiastic¦ variant), respectively; also available for A͞u,
+					E͞u, and O͞e/Œ̄.
+				\item[¦=AE¦] for A͞E (AE diphthong with macron, for the ¦classic¦ and
+					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
+					and the ¦ecclesiastic¦ variant), respectively; also available for A͞U,
+					E͞U, and O͞E/Œ̄.
 				\item[¦\textasciicircum a¦] for ă (a with breve), also available for ĕ, ĭ,
-					ŏ, ŭ, and y̆.  Note that a breve above the letter y is only displayed if
+					ŏ, ŭ, and y̆. Note that a breve above the letter y is only displayed if
 					your font supports the Unicode character ¦0306¦ (\emph{combining
 					breve}).
 				\item[¦\textasciicircum A¦] Ă (A with breve), also available for Ĕ, Ĭ, Ŏ,
@@ -1613,6 +1625,32 @@
 \paragraph*{Options:}
 \begin{itemize}
 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
+	\item \xpgboolkeyfalse[1.54]{babelshorthands}
+		If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
+		of Portuguese words are activated.
+		\begin{shorthands}
+			\item[¦"|¦] disables a ligature at this position.
+			\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
+			of the next line when hyphenated, as common in Portuguese typesetting
+			(also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
+			for hyphenation at the other points preset in the hyphenation patterns.
+			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+			cases where the hyphen should stick at the following syllable.
+			\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
+			in the hyphenation patterns (as opposed to \cmd\-).
+			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+			\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
+			at the breakpoints preset in the hyphenation patterns is still allowed.
+			\item[¦"<¦] for French left guillemets («).
+			\item[¦">¦] for French right guillemets (»).
+		\end{shorthands}
+    \item \xpgboolkeytrue[1.54]{splithyphens}
+		According to Portuguese typesetting conventions, if a word with a hard hyphen (such as
+		\emph{pára-brisas}) is hyphenated at this hyphen, a second hyphenation character is to be
+		inserted at the beginning of the line that follows the hyphenation (\emph{pára-/-brisas}).
+		By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
+		loaded to achieve this).
+		Set this option to ¦false¦ to disable the feature.
 \end{itemize}
 
 \subsection{russian}\label{russian}
@@ -1710,6 +1748,13 @@
 \paragraph*{Options:}
 	\begin{itemize}
 	\item \xpgchoicekey{script}{\xpgpresetvalue{Cyrillic} or \xpgvalue{Latin}}
+	\item \xpgboolkeytrue[1.54]{splithyphens}
+			According to Serbian typesetting conventions, if a word with a hard hyphen (such as
+			\emph{калцијум-карбонат}) is hyphenated at this hyphen, a second hyphenation character is to be
+			inserted at the beginning of the line that follows the hyphenation (\emph{калцијум-/-карбонат}).
+			By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
+			loaded to achieve this).
+			Set this option to ¦false¦ to disable the feature.
 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
           Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
           \begin{itemize}
@@ -1742,7 +1787,8 @@
 		\begin{shorthands}
         \item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
                     of the next line when hyphenated, as common in Slovak typesetting
-		            (only needed with ¦splithyphens=false¦).
+		            (also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
+		            for hyphenation at the other points preset in the hyphenation patterns.
         \item[¦"|¦] disables a ligature at this position.
         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
                     cases where the hyphen should stick at the following syllable.
@@ -1982,11 +2028,11 @@
 	           (such as, in the case of English, ¦\def\chaptername{Chapter}¦)
 	\item \Cmd{\date\meta{lang}} stores definitions of date formats (usually redefinitions
 	           of \cmd\today, in some cases also definitions of additional date commands)
-	\item \Cmd{\blockextras\meta{lang}} stores macros that are to be executed when the language
+	\item \Cmd{\blockextras@\meta{lang}} stores macros that are to be executed when the language
               \meta{lang} is activated via \cmd\selectlanguage\ command or the \meta{lang} environment
-	\item \Cmd{\inlineextras\meta{lang}} stores macros that are to be executed when the language
+	\item \Cmd{\inlineextras@\meta{lang}} stores macros that are to be executed when the language
 	          \meta{lang} is activated locally via \cmd\text\meta{lang} command
-	\item \Cmd{\noextras\meta{lang}} stores macros that are to be executed when the language
+	\item \Cmd{\noextras@\meta{lang}} stores macros that are to be executed when the language
 	          \meta{lang} is closed
 \end{itemize}
 %
@@ -2337,6 +2383,48 @@
 \section{Revision history}
 
 \bgroup\footnotesize
+\subsection*{1.54 (27-03-2022)}
+
+\subsubsection*{New features}
+\begin{itemize}
+	\item New option \xpgoption{splithyphens} for Serbian (\TXI{496}) and Portuguese (\TXI{534}).
+	\item Add \xpgoption{babelshorthands} to Portuguese.
+	\item Add \xpgoption{schoolhyphens} option to Finnish (\TXI{525}).
+\end{itemize}
+
+\subsubsection*{Interface and defaults changes}
+\begin{itemize}
+	\item Rename \xpgoption{disableligatures} to \xpgoption{disabledigraphs} for Croatian (\TXI{497}, \TXP{500}).
+	\item Fix output with \xpgoption{numerals=cyrillic-alph} (part of \TXI{503}).
+	\item Standardize February and November in Indonesian according to the Great Dictionary of the Indonesian Language
+	      of the Language Center (\emph{Kamus Besar Bahasa Indonesia}) (\TXP{526}).
+\end{itemize}
+
+\subsubsection*{Bug fixes}
+\begin{itemize}
+	\item Fix robustification of font family switches (\TXI{428}).
+	\item Preserve font family switches across languages (\TXI{519}).
+	\item Fix \TeX\ dash ligatures with \xpgoption{splithyphens} (\TXI{502}).
+	\item Prevent \emph{missing hyphenmins value} \LaTeX\ error with unknown languages (\TXI{513}).
+	\item Fix global \xpgoption{babelshorthands}, \xpgoption{localmarks} and \xpgoption{verbose}
+	      options (\TXI{515}).
+	\item Fix Latin shorthands (\TXI{516}).
+	\item Remove spurious space in Bosnian date (\TXP{528}).
+	\item Fix \cmd\languagevariant\ and \cmd\mainlanguagevariant\ macros (\TXI{530}, \TXI{531}).
+	\item Make \cmd\iflanguageloaded\ and friends work in preamble (\TXI{532}).
+	\item Fix deactivation of shorthands (\TXI{320}).
+	\item Fix deactivation of numerals.
+	\item Update deprecated \LaTeX\ hooks (\TXI{523}).
+	\item Fix \xpgoption{luatexrenderer} option which was not considered appropriately (\TXI{533}).
+	\item Turn warning about \texttt{totalhyphenmin} to info, which is more appropriate (\TXI{111}).
+\end{itemize}
+
+\subsubsection*{Documentation improvements}
+\begin{itemize}
+	\item Document in this manual where to report bugs (\TXI{512}).
+\end{itemize}
+
+
 \subsection*{1.53 (12-04-2021)}
 
 \subsubsection*{New features}
@@ -2569,12 +2657,13 @@
       change of behavior should you have used one of these options without value (\TXI{363}).
       Concerned are the following options:
       \begin{itemize}
-	   \item ¦babelshorthands¦ in language Belarusian, Mongolian, Ukrainian, and Russian
-             (now ¦babelshorthands¦ equals ¦babelshorthand=true¦, no longer ¦babelshorthands=false¦).
-	   \item ¦localalph¦ in language Slovenian (¦localalph¦ now equals ¦localalph=true¦).
-	   \item ¦latesthyphen¦ in language German (¦latesthyphen¦ now equals ¦latesthyphen=true¦).
-	   \item ¦fullyear¦ in package \pkg{hebrewcal} (¦fullyear¦ now equals ¦fullyear=true¦).
+	   \item \xpgoption{babelshorthands} in language Belarusian, Mongolian, Ukrainian, and Russian
+             (now \xpgoption{babelshorthands} equals \xpgoption{babelshorthand=true}, no longer \xpgoption{babelshorthands=false}).
+	   \item \xpgoption{localalph} in language Slovenian (\xpgoption{localalph} now equals \xpgoption{localalph=true}).
+	   \item \xpgoption{fullyear} in package \pkg{hebrewcal} (\xpgoption{fullyear} now equals \xpgoption{fullyear=true}).
       \end{itemize}
+\item The option \xpgoption{latesthyphen} in language German is deprecated. \XeTeX\ and \LuaTeX\ nowadays
+      always use the latest German hyphens.
 \item The command ¦\setlanguagealias*¦ (introduced in v1.46) does no longer define
       dedicated alias environments.
 \item The babelnames for Latin variants have been corrected to ¦classiclatin¦, ¦ecclesiasticlatin¦
@@ -3129,7 +3218,7 @@
 Many thanks to all the people who have contributed bugfixes and new features to \pkg{polyglossia}
 since we took over.
 In alphabetical order: \TA{Ignas Anikevicius}, \TA{Sina Ahmadi}, \TA{Wouter Bolsterlee}, \TA{Christian Buhtz},
-\TA{Zgarbul Andrey}, \TA{Oleg Domanov}, \TA{Philipp Gesang}, \TA{Kevin Godby}, \TA{Enrico Gregorio},
+\TA{Zgarbul Andrey}, \TA{Oleg Domanov}, user \TA{fakhriaunur}, \TA{Philipp Gesang}, \TA{Kevin Godby}, \TA{Enrico Gregorio},
 \TA{Khaled Hosny}, \TA{Najib Idrissi}, user \TA{julroy67}, \TA{Dohyun Kim}, \TA{Phil Kime}, \TA{Mike Kroutikov},
 \TA{Ivan Kokan}, \TA{Caleb Maclennan}, \TA{José Mancera}, \TA{Miquel Ortega}, \TA{Yevgen Pogribnyi}, \TA{Will Robertson},
 \TA{Maïeul Rouquette}, \TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg}, \TA{Philipp Stephani}, \TA{Niranjan Tambe},

Modified: trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx	2022-04-05 22:10:52 UTC (rev 62940)
@@ -8,7 +8,7 @@
 \iffalse
 %</internal>
 %<*README>
-# THE POLYGLOSSIA PACKAGE v1.51
+# THE POLYGLOSSIA PACKAGE v1.54
 ## Multilingual typesetting with XeLaTeX and LuaLaTeX
 
 This package provides an alternative to Babel for users of XeLaTeX and LuaLaTeX.
@@ -36,8 +36,8 @@
 
 # LICENCE
 
-Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2021 Arthur Reutenauer,
-Copyright (c) 2019-2021 Bastien Roucariès, 2019-2021 Jürgen Spitzmüller
+Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2022 Arthur Reutenauer,
+Copyright (c) 2019-2022 Bastien Roucariès, 2019-2022 Jürgen Spitzmüller
 
 Except where otherwise noted, Polyglossia is placed under the terms of the MIT licence
 (https://opensource.org/licenses/MIT).
@@ -66,10 +66,10 @@
 
   The polyglossia package         
   (C) 2008–2010 François Charette    
-  (C) 2011–2021 Arthur Reutenauer
+  (C) 2011–2022 Arthur Reutenauer
   (C) 2013 Elie Roux
   (C) 2019 Bastien Roucariès
-  (C) 2019–2021 Jürgen Spitzmüller
+  (C) 2019–2022 Jürgen Spitzmüller
   License information appended
 
 
@@ -76,7 +76,7 @@
 \endpreamble
 \postamble
 
- Copyright (C) 2021 by Arthur Reutenauer <arthur 'dot' reutenauer 'at' normalesup 'dot' org> 
+ Copyright (C) 2022 by Arthur Reutenauer <arthur 'dot' reutenauer 'at' normalesup 'dot' org> 
 
  This work may be distributed and/or modified under the
  conditions of the LaTeX Project Public License, either version 1.3
@@ -273,7 +273,6 @@
 \generate{\file{gloss-la-x-medieval.ldf}{\from{polyglossia.dtx}{gloss-la-x-medieval.ldf}}}
 \generate{\file{gloss-la.ldf}{\from{polyglossia.dtx}{gloss-la.ldf}}}
 \generate{\file{gloss-lao.ldf}{\from{polyglossia.dtx}{gloss-lao.ldf}}}
-\generate{\file{gloss-latex.ldf}{\from{polyglossia.dtx}{gloss-latex.ldf}}}
 \generate{\file{gloss-latin.ldf}{\from{polyglossia.dtx}{gloss-latin.ldf}}}
 \generate{\file{gloss-latinclassic.ldf}{\from{polyglossia.dtx}{gloss-latinclassic.ldf}}}
 \generate{\file{gloss-latinecclesiastic.ldf}{\from{polyglossia.dtx}{gloss-latinecclesiastic.ldf}}}
@@ -373,7 +372,7 @@
 % !TeX spellcheck = en_US
 % !TeX TS-program = xelatex
 \documentclass[11pt]{ltxdoc}
-\usepackage{color}
+\usepackage{xcolor}
 \usepackage{xspace,fancyvrb,longtable,booktabs}
 \usepackage[neverdecrease]{paralist}
 \usepackage[format=hang,labelfont=bf,labelsep=period]{caption}
@@ -512,7 +511,7 @@
 % \color{xpgblue}Polyglossia: Modern multilingual typesetting with \XeLaTeX\ and \LuaLaTeX}
 % \author{\TA{François Charette} \and \TA{Arthur Reutenauer}\thanks{Current maintainer}
 % 	    \and \TA{Bastien Roucariès} \and \TA{Jürgen Spitzmüller}}
-% \date{\filedate \qquad \fileversion\\
+% \date{\filedate \qquad \fileversion\thanks{Please report bugs to \url{http://github.com/reutenauer/polyglossia/issues}}\\
 % \footnotesize (\textsc{pdf} file generated on \today)}
 % 
 % \maketitle
@@ -685,11 +684,9 @@
 % british            & english    & variant=british                     \\
 % canadian           & english    & variant=canadian                    \\
 % canadien           & french     & variant=canadian                    \\
-% classiclatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.classic}).}
-%                    & latin      & variant=classic                     \\
+% classiclatin       & latin      & variant=classic                     \\
 % farsi              & persian    &                                     \\
-% ecclesiasticlatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.ecclesiastic}).}
-%                    & latin      & variant=ecclesiastic                \\
+% ecclesiasticlatin  & latin      & variant=ecclesiastic                \\
 % friulan            & friulian   &                                     \\
 % german\footnote{Due to the name conflict only available in \pkg{polyglossia} as \emph{germanb} (which is a \pkg{babel} synonym).}
 %                    & german     & spelling=old                        \\
@@ -697,8 +694,7 @@
 % kurmanji           & kurdish    & variant=kurmanji                    \\
 % lowersorbian       & sorbian    & variant=lower                       \\
 % magyar             & hungarian  &                                     \\
-% medievallatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.medieval}).}
-%                    & latin      & variant=medieval                    \\
+% medievallatin      & latin      & variant=medieval                    \\
 % naustrian          & german     & variant=austrian                    \\
 % newzealand         & english    & variant=newzealand                  \\
 % ngerman            & german     & variant=german [\emph{default}]     \\
@@ -717,7 +713,7 @@
 % \bottomrule
 % \end{tabular}
 % \end{minipage}
-% 	
+% 
 % \end{table}
 % 
 % For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{1.46} (for the few justified
@@ -1214,7 +1210,7 @@
 % \paragraph*{Commands:}
 % 	\begin{itemize}
 % 	\item \Cmd\abjad outputs Arabic \textit{abjad} numbers according to the Mashriq varieties.
-% 	      Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.	
+% 	      Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.
 % 	\item \Cmd\abjadmaghribi outputs Arabic \textit{abjad} numbers according to the Maghrib varieties.
 % 	       Example: ¦\abjadmaghribi{1863}¦ yields \textarabic{\abjadmaghribi{1863}}.
 % 	\item \Cmd\abjadalph\new{1.50} steps through the Arabic alphabet, thus it can only be used up to 28.
@@ -1330,17 +1326,17 @@
 % 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
 % 		            at the breakpoints preset in the hyphenation patterns is still allowed.
 % 	\end{shorthands}
-% 	Furthermore, the following shorthands generate easy access to Croatian digraphs (ligatures):
+% 	Furthermore, the following shorthands generate easy access to Croatian digraphs:
 % 	\begin{shorthands}
-% 		\item[¦"dz¦] Generates the ligature \charifavailable{01C6}{dž}\ if the font provides it. If not, the
-% 		             two characters are output separately. Also available for ¦"Dz¦ (\charifavailable{01C5}{Dž})
-% 		             and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
-% 		\item[¦"lj¦] Generates the ligature \charifavailable{01C9}{lj}\ if the font provides it. If not, the
-% 		             two characters are output separately. Also available for ¦"Lj¦ (\charifavailable{01C8}{Lj})
-% 		             and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
-% 		\item[¦"nj¦] Generates the ligature \charifavailable{01CC}{nj}\ if the font provides it. If not, the
-% 		             two characters are output separately. Also available for ¦"Nj¦ (\charifavailable{01CB}{Nj})
-% 		             and ¦"NJ¦ (\charifavailable{01CA}{NJ}).
+% 		\item[¦"dz¦] Generates the digraph \charifavailable{01C6}{dž}\ if the font provides it. If not,
+% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
+% 		             ¦"Dz¦ (\charifavailable{01C5}{Dž}) and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
+% 		\item[¦"lj¦] Generates the digraph \charifavailable{01C9}{lj}\ if the font provides it. If not,
+% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
+% 		             ¦"Lj¦ (\charifavailable{01C8}{Lj}) and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
+% 		\item[¦"nj¦] Generates the digraph \charifavailable{01CC}{nj}\ if the font provides it. If not,
+% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
+% 		             ¦"Nj¦ (\charifavailable{01CB}{Nj}) and ¦"NJ¦ (\charifavailable{01CA}{NJ}).
 % 	\end{shorthands}
 % 	
 % 	Finally, there are also four shorthands for quotation marks:
@@ -1350,19 +1346,21 @@
 % 		\item[¦">¦] for Croatian left guillemets (»).
 % 		\item[¦"<¦] for Croatian right guillemets («).
 % 	\end{shorthands}
-% 	\item \xpgboolkeyfalse[1.47]{disableligatures}
-% 		If this is \xpgvalue{true}, all Croatian ligatures (for digraphs such as
-% 		\charifavailable{01C6}{dž}) will be replaced by single characters. This can
-% 		be useful if the ligatures on your font are broken (if the font does not
-% 		have them, they are automatically replaced).
+% 	\item \xpgboolkeyfalse[1.47]{disabledigraphs}[Up to version 1.53, the option was
+% 		called \xpgvalue{disableligatures}. The old option is kept for backwards compatibility,
+% 		but the use is discouraged.] If this is \xpgvalue{true}, all Croatian digraphs
+% 		(such as \charifavailable{01C6}{dž}) will be replaced by the two consecutive letters,
+% 		which is the most common way of typesetting them in Croatian. This can be useful if
+% 		the Unicode digraphs in your font are broken (if the font does not have them,
+% 		they are automatically mimicked by the two consecutive glyphs).
 % 	\item \xpgboolkeytrue[1.53]{localalph}
 % 		If \xpgvalue{true}, alphanumeric counters will use a locally established version which excludes
 % 		the characters \meta{q}, \meta{w}, \meta{x} and \meta{y} from alphabetic counting.
 % 		Obviously this limits the counting range to 22.
 %     \item \xpgboolkeytrue[1.51]{splithyphens}
-% 	    According to Croatian typesetting conventions, if a word with a hard hyphen (such as \emph{je-li})
-% 	    is hyphenated at this hyphen, a second hyphenation character is to be inserted at the beginning
-% 	    of the line that follows the hyphenation (\emph{je-/-li}).
+% 	    According to Croatian typesetting conventions, if a word with a hard hyphen (such as
+% 	    \emph{hrvatsko-engleski}) is hyphenated at this hyphen, a second hyphenation character is to be
+% 	    inserted at the beginning of the line that follows the hyphenation (\emph{hrvatsko-/-engleski}).
 % 	    By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
 % 	    loaded to achieve this).
 % 	    Set this option to ¦false¦ to disable the feature.
@@ -1450,6 +1448,13 @@
 %         \item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
 %                   hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
 % 		\end{shorthands}
+%   \item \xpgboolkeyfalse[1.54]{schoolhyphens}
+% 	    If this is set to true, alternative (experimental) hyphenation patterns are used rather than the
+% 	    default Finnish patterns. These patterns (called `School Hyphenation') are more basic in that
+% 	    they do not contain hyphenation exceptions for compound words since these result in simple words
+% 	    not being hyphenated at points where this would be valid. The backdrop of the  `School' patterns
+% 	    is that compound words might be hyphenated incorrectly.
+% 	    See \url{https://github.com/hyphenation/basic-finnish} for details.
 % \end{itemize}
 % 
 % \subsection{french}\label{french}
@@ -1881,16 +1886,22 @@
 % 				\item[¦=A¦] for Ā (A with macron), also available for Ē, Ī, Ō, Ū, V̄, and Ȳ.
 % 					Note that a macron above the letter V is only displayed if your font
 % 					supports the Unicode character ¦0304¦ (\emph{combining macron}).
-% 				\item[¦=ae¦] for a͞e (ae diphthong with macron), also available for a͞u, e͞u,
-% 					and o͞e. Note that macrons above diphthongs are only displayed if your font
-% 					supports the Unicode character ¦035E¦ (\emph{combining double
+% 				\item[¦=ae¦] for a͞e (ae diphthong with macron, for the ¦classic¦ and
+% 					the ¦modern¦ variant) or ǣ (ae ligature with macron, for the ¦medieval¦
+% 					and the ¦ecclesiastic¦ variant), respectively; also available for a͞u,
+% 					e͞u, and o͞e/œ̄. Note that macrons above diphthongs are only displayed if
+% 					your font supports the Unicode character ¦035E¦ (\emph{combining double
 % 					macron}).
-% 				\item[¦=Ae¦] for A͞e (Ae diphthong with macron), also available for A͞u, E͞u,
-% 					and O͞e.
-% 				\item[¦=AE¦] for A͞E (AE diphthong with macron), also available for A͞U, E͞U,
-% 					and O͞E.
+% 				\item[¦=Ae¦] for A͞e (Ae diphthong with macron, for the ¦classic¦ and
+% 					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
+% 					and the ¦ecclesiastic¦ variant), respectively; also available for A͞u,
+% 					E͞u, and O͞e/Œ̄.
+% 				\item[¦=AE¦] for A͞E (AE diphthong with macron, for the ¦classic¦ and
+% 					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
+% 					and the ¦ecclesiastic¦ variant), respectively; also available for A͞U,
+% 					E͞U, and O͞E/Œ̄.
 % 				\item[¦\textasciicircum a¦] for ă (a with breve), also available for ĕ, ĭ,
-% 					ŏ, ŭ, and y̆.  Note that a breve above the letter y is only displayed if
+% 					ŏ, ŭ, and y̆. Note that a breve above the letter y is only displayed if
 % 					your font supports the Unicode character ¦0306¦ (\emph{combining
 % 					breve}).
 % 				\item[¦\textasciicircum A¦] Ă (A with breve), also available for Ĕ, Ĭ, Ŏ,
@@ -1996,6 +2007,32 @@
 % \paragraph*{Options:}
 % \begin{itemize}
 % 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
+% 	\item \xpgboolkeyfalse[1.54]{babelshorthands}
+% 		If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
+% 		of Portuguese words are activated.
+% 		\begin{shorthands}
+% 			\item[¦"|¦] disables a ligature at this position.
+% 			\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
+% 			of the next line when hyphenated, as common in Portuguese typesetting
+% 			(also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
+% 			for hyphenation at the other points preset in the hyphenation patterns.
+% 			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+% 			cases where the hyphen should stick at the following syllable.
+% 			\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
+% 			in the hyphenation patterns (as opposed to \cmd\-).
+% 			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+% 			\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
+% 			at the breakpoints preset in the hyphenation patterns is still allowed.
+% 			\item[¦"<¦] for French left guillemets («).
+% 			\item[¦">¦] for French right guillemets (»).
+% 		\end{shorthands}
+%     \item \xpgboolkeytrue[1.54]{splithyphens}
+% 		According to Portuguese typesetting conventions, if a word with a hard hyphen (such as
+% 		\emph{pára-brisas}) is hyphenated at this hyphen, a second hyphenation character is to be
+% 		inserted at the beginning of the line that follows the hyphenation (\emph{pára-/-brisas}).
+% 		By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
+% 		loaded to achieve this).
+% 		Set this option to ¦false¦ to disable the feature.
 % \end{itemize}
 % 
 % \subsection{russian}\label{russian}
@@ -2093,6 +2130,13 @@
 % \paragraph*{Options:}
 % 	\begin{itemize}
 % 	\item \xpgchoicekey{script}{\xpgpresetvalue{Cyrillic} or \xpgvalue{Latin}}
+% 	\item \xpgboolkeytrue[1.54]{splithyphens}
+% 			According to Serbian typesetting conventions, if a word with a hard hyphen (such as
+% 			\emph{калцијум-карбонат}) is hyphenated at this hyphen, a second hyphenation character is to be
+% 			inserted at the beginning of the line that follows the hyphenation (\emph{калцијум-/-карбонат}).
+% 			By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
+% 			loaded to achieve this).
+% 			Set this option to ¦false¦ to disable the feature.
 % 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
 %           Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
 %           \begin{itemize}
@@ -2125,7 +2169,8 @@
 % 		\begin{shorthands}
 %         \item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
 %                     of the next line when hyphenated, as common in Slovak typesetting
-% 		            (only needed with ¦splithyphens=false¦).
+% 		            (also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
+% 		            for hyphenation at the other points preset in the hyphenation patterns.
 %         \item[¦"|¦] disables a ligature at this position.
 %         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 %                     cases where the hyphen should stick at the following syllable.
@@ -2365,11 +2410,11 @@
 % 	           (such as, in the case of English, ¦\def\chaptername{Chapter}¦)
 % 	\item \Cmd{\date\meta{lang}} stores definitions of date formats (usually redefinitions
 % 	           of \cmd\today, in some cases also definitions of additional date commands)
-% 	\item \Cmd{\blockextras\meta{lang}} stores macros that are to be executed when the language
+% 	\item \Cmd{\blockextras@\meta{lang}} stores macros that are to be executed when the language
 %               \meta{lang} is activated via \cmd\selectlanguage\ command or the \meta{lang} environment
-% 	\item \Cmd{\inlineextras\meta{lang}} stores macros that are to be executed when the language
+% 	\item \Cmd{\inlineextras@\meta{lang}} stores macros that are to be executed when the language
 % 	          \meta{lang} is activated locally via \cmd\text\meta{lang} command
-% 	\item \Cmd{\noextras\meta{lang}} stores macros that are to be executed when the language
+% 	\item \Cmd{\noextras@\meta{lang}} stores macros that are to be executed when the language
 % 	          \meta{lang} is closed
 % \end{itemize}
 % ^^A
@@ -2720,6 +2765,48 @@
 % \section{Revision history}
 % 
 % \bgroup\footnotesize
+% \subsection*{1.54 (27-03-2022)}
+% 
+% \subsubsection*{New features}
+% \begin{itemize}
+% 	\item New option \xpgoption{splithyphens} for Serbian (\TXI{496}) and Portuguese (\TXI{534}).
+% 	\item Add \xpgoption{babelshorthands} to Portuguese.
+% 	\item Add \xpgoption{schoolhyphens} option to Finnish (\TXI{525}).
+% \end{itemize}
+% 
+% \subsubsection*{Interface and defaults changes}
+% \begin{itemize}
+% 	\item Rename \xpgoption{disableligatures} to \xpgoption{disabledigraphs} for Croatian (\TXI{497}, \TXP{500}).
+% 	\item Fix output with \xpgoption{numerals=cyrillic-alph} (part of \TXI{503}).
+% 	\item Standardize February and November in Indonesian according to the Great Dictionary of the Indonesian Language
+% 	      of the Language Center (\emph{Kamus Besar Bahasa Indonesia}) (\TXP{526}).
+% \end{itemize}
+% 
+% \subsubsection*{Bug fixes}
+% \begin{itemize}
+% 	\item Fix robustification of font family switches (\TXI{428}).
+% 	\item Preserve font family switches across languages (\TXI{519}).
+% 	\item Fix \TeX\ dash ligatures with \xpgoption{splithyphens} (\TXI{502}).
+% 	\item Prevent \emph{missing hyphenmins value} \LaTeX\ error with unknown languages (\TXI{513}).
+% 	\item Fix global \xpgoption{babelshorthands}, \xpgoption{localmarks} and \xpgoption{verbose}
+% 	      options (\TXI{515}).
+% 	\item Fix Latin shorthands (\TXI{516}).
+% 	\item Remove spurious space in Bosnian date (\TXP{528}).
+% 	\item Fix \cmd\languagevariant\ and \cmd\mainlanguagevariant\ macros (\TXI{530}, \TXI{531}).
+% 	\item Make \cmd\iflanguageloaded\ and friends work in preamble (\TXI{532}).
+% 	\item Fix deactivation of shorthands (\TXI{320}).
+% 	\item Fix deactivation of numerals.
+% 	\item Update deprecated \LaTeX\ hooks (\TXI{523}).
+% 	\item Fix \xpgoption{luatexrenderer} option which was not considered appropriately (\TXI{533}).
+% 	\item Turn warning about \texttt{totalhyphenmin} to info, which is more appropriate (\TXI{111}).
+% \end{itemize}
+% 
+% \subsubsection*{Documentation improvements}
+% \begin{itemize}
+% 	\item Document in this manual where to report bugs (\TXI{512}).
+% \end{itemize}
+% 
+% 
 % \subsection*{1.53 (12-04-2021)}
 % 
 % \subsubsection*{New features}
@@ -2952,12 +3039,13 @@
 %       change of behavior should you have used one of these options without value (\TXI{363}).
 %       Concerned are the following options:
 %       \begin{itemize}
-% 	   \item ¦babelshorthands¦ in language Belarusian, Mongolian, Ukrainian, and Russian
-%              (now ¦babelshorthands¦ equals ¦babelshorthand=true¦, no longer ¦babelshorthands=false¦).
-% 	   \item ¦localalph¦ in language Slovenian (¦localalph¦ now equals ¦localalph=true¦).
-% 	   \item ¦latesthyphen¦ in language German (¦latesthyphen¦ now equals ¦latesthyphen=true¦).
-% 	   \item ¦fullyear¦ in package \pkg{hebrewcal} (¦fullyear¦ now equals ¦fullyear=true¦).
+% 	   \item \xpgoption{babelshorthands} in language Belarusian, Mongolian, Ukrainian, and Russian
+%              (now \xpgoption{babelshorthands} equals \xpgoption{babelshorthand=true}, no longer \xpgoption{babelshorthands=false}).
+% 	   \item \xpgoption{localalph} in language Slovenian (\xpgoption{localalph} now equals \xpgoption{localalph=true}).
+% 	   \item \xpgoption{fullyear} in package \pkg{hebrewcal} (\xpgoption{fullyear} now equals \xpgoption{fullyear=true}).
 %       \end{itemize}
+% \item The option \xpgoption{latesthyphen} in language German is deprecated. \XeTeX\ and \LuaTeX\ nowadays
+%       always use the latest German hyphens.
 % \item The command ¦\setlanguagealias*¦ (introduced in v1.46) does no longer define
 %       dedicated alias environments.
 % \item The babelnames for Latin variants have been corrected to ¦classiclatin¦, ¦ecclesiasticlatin¦
@@ -3512,7 +3600,7 @@
 % Many thanks to all the people who have contributed bugfixes and new features to \pkg{polyglossia}
 % since we took over.
 % In alphabetical order: \TA{Ignas Anikevicius}, \TA{Sina Ahmadi}, \TA{Wouter Bolsterlee}, \TA{Christian Buhtz},
-% \TA{Zgarbul Andrey}, \TA{Oleg Domanov}, \TA{Philipp Gesang}, \TA{Kevin Godby}, \TA{Enrico Gregorio},
+% \TA{Zgarbul Andrey}, \TA{Oleg Domanov}, user \TA{fakhriaunur}, \TA{Philipp Gesang}, \TA{Kevin Godby}, \TA{Enrico Gregorio},
 % \TA{Khaled Hosny}, \TA{Najib Idrissi}, user \TA{julroy67}, \TA{Dohyun Kim}, \TA{Phil Kime}, \TA{Mike Kroutikov},
 % \TA{Ivan Kokan}, \TA{Caleb Maclennan}, \TA{José Mancera}, \TA{Miquel Ortega}, \TA{Yevgen Pogribnyi}, \TA{Will Robertson},
 % \TA{Maïeul Rouquette}, \TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg}, \TA{Philipp Stephani}, \TA{Niranjan Tambe},
@@ -3543,7 +3631,7 @@
 % \subsection{polyglossia.sty}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{polyglossia}[2021/04/12 v1.53
+\ProvidesPackage{polyglossia}[2022/03/27 v1.54
   Modern multilingual typesetting with XeLaTeX and LuaLaTeX]
 \RequirePackage{etoolbox}
 \RequirePackage{makecmds}
@@ -3560,27 +3648,45 @@
 
 % Execute code #3 if package #1 has been loaded already, else
 % add to package hook #2
-\newcommand\xpg at at@package[3]{%
-    \@ifpackageloaded{#1}{#3}{\AddToHook{#2}{#3}}%
+\cs_new_nopar:Nn \__xpg_at_package_hook:nnn{
+  \@ifpackageloaded{#1}{#3}{\AddToHook{#2}{#3}}%
 }
 
+% safe according to expl3 bug #960
+\cs_generate_variant:Nn \prop_item:Nn { Ne, Nf, No, Nx }
+\cs_generate_variant:Nn \clist_set:Nn { Ne, Nf, No, Nx }
+\cs_generate_variant:Nn \clist_gput_right:Nn {Ne}
+\cs_generate_variant:Nn  \prop_get:NnN {NeN}
+\cs_generate_variant:Nn  \prop_gput:Nnn {Nne, Nee, Nen}
+\cs_generate_variant:Nn  \cs_gset:Npn {Npe}
+\cs_generate_variant:Nn  \cs_new:Nn {Ne}
+\cs_generate_variant:Nn  \cs_new_nopar:Nn {Ne}
+\cs_generate_variant:Nn  \cs_gset_nopar:Npn {Npe}
+\cs_generate_variant:Nn  \cs_gset_nopar:Npn {cpe}
+\cs_generate_variant:Nn  \tl_set:Nn {Ne}
+\cs_generate_variant:Nn  \str_foldcase:n {e}
+\prg_generate_conditional_variant:Nnn \file_if_exist:n {e} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \tl_if_blank:n {e} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \clist_if_in:Nn {Ne} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \prop_if_in:Nn {Ne} {TF, T, F, p}
 % correct a bug in tracklang
-\xpg at at@package{tracklang}{file/after/tracklang.sty}{%
+\__xpg_at_package_hook:nnn{tracklang}{file/tracklang.sty/after}{%
   \@ifpackagelater{tracklang}{2019/08/30}{}{\global\def\AddTrackedLangage{\AddTrackedLanguage}}
 }
 
-
 %% This is for compatibility with Babel-aware package:
 \def\languageshorthands#1{\relax} %this is for scrlttr2 class
 \def\bbl at cs#1{\csname bbl@#1\endcsname}%
 \AtEndPreamble{\let\bbl at set@language\xpg at set@language at aux} %for biblatex
 \AtEndPreamble{\let\bbl at main@language\xpg at main@language} %for biblatex
-\providecommand\texorpdfstring[2]{#1}% dummy command if hyperref is not loaded
+\AtEndPreamble{
+  \providecommand\texorpdfstring[2]{#1}% dummy command if hyperref is not loaded
+}
 
-\ifluatex
+\sys_if_engine_luatex:T{
   \RequirePackage{luatexbase} % already included by fontspec, but needed here
   \RequireLuaModule{polyglossia}
-\fi
+}
 
 % Which version of XeTeX do we use? What is the boudary class? 4095 or 255
 \@ifundefined{e at alloc@intercharclass at top}
@@ -3588,10 +3694,16 @@
   {\let\xpg at boundaryclass=\e at alloc@intercharclass at top}
 
 % Useful for getting list of loaded languages and variants. Like babel's bbl at loaded
-\let\xpg at loaded\@empty% list of loaded languages (polyglossia name)
-\let\xpg at vloaded\@empty% list of loaded variants
-\let\xpg at bloaded\@empty% list of loaded languages (babel name)
-\let\xpg at bcp@loaded\@empty% list of loaded languages (bcp-47 id)
+% all language loaded
+\seq_new:N \__xpg_langs_loaded
+% list of loaded languages (polyglossia name)
+\clist_new:N \xpg at loaded
+% list of loaded variants
+\clist_new:N \xpg at vloaded
+% list of loaded languages (babel name)
+\clist_new:N \xpg at bloaded
+% list of loaded languages (bcp-47 id)
+\clist_new:N \xpg at bcp@loaded
 
 % counter in latin
 \def\latinalph#1{\expandafter\latin at alph\csname c@#1\endcsname}
@@ -3661,26 +3773,38 @@
 % error out if lang is not loaded
 \cs_new_nopar:Nn \polyglossia at error@iflangnotloaded:n
 {
-  \cs_if_exist:cF{#1 at loaded}
+  \seq_if_in:NxF \__xpg_langs_loaded {#1}
   {
     \xpg at error{language~ #1~ is~ not~ loaded.~ Please~ load~ it~ before~ using~ it.}
   }
 }
 
+\msg_new:nnn { polyglossia } { languagenotloaded }
+{
+  The~ language~ #1~ is~ not~ loaded.~ You~ should~ load~ it.
+}
+\msg_redirect_name:nnn { polyglossia } { languagenotloaded } { critical }
 
-% error do not use directly the gloss file
-\msg_new:nnn { polyglossia } { directloadgloss }
+\cs_new_nopar:Nn \__xpg_msg_if_lang_not_loaded:n
 {
-  You~ should~ not~ load~ directly~ the~ gloss~ file~ using~ `\string\usepackage'.
-  You~ must~ use~ `\string\setotherlanguage\{#1\}' or  `\string\setmainlanguage\{#1\}'.
+  \tl_if_blank:eT {\xpg_alias_base_lang:n{#1}}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#1}
+  }
 }
-\msg_redirect_name:nnn { polyglossia } { directloadgloss } { critical }
+% 
 
 %% use macro if defined, else warn that it is not
-\def\csuse at warn#1{%
-   \ifcsundef{#1}{\xpg at warning{ \expandafter\string\csname #1\endcsname\space is~ not~ defined}}%
-   {\csname #1\endcsname}}
+\cs_new_nopar:Nn \__xpg_use_or_warn:N
+{
+  \cs_if_exist_use:NF {#1}
+  {
+    \xpg at warning {  \tl_to_str:N {#1} ~ is~ not~ defined }
+  }
+}
+\cs_generate_variant:Nn \__xpg_use_or_warn:N {c}
 
+
 %% ensure directionality if bidi is loaded, else ignore
 \def\@@ensure at dir#1{\ifcsundef{@ensure at dir}{#1}{\@ensure at dir{#1}}}
 \def\@@ensure at maindir#1{\ifcsundef{@ensure at maindir}{#1}{\@ensure at maindir{#1}}}
@@ -3697,66 +3821,94 @@
   }
 }
 
+% if #1 is LR run #2 else #3
+\prg_set_conditional:Nnn \__xpg_if_LR_str:n {p, T, F, TF}
+{
+  \str_case_e:nnF{#1}{
+    {LR}{\prg_return_true:}
+    {RL}{\prg_return_false:}
+  }
+  {
+    \xpg at error{Unknown~ direction~#1}
+    \prg_return_false:
+  }
+}
+\prg_generate_conditional_variant:Nnn \__xpg_if_LR_str:n {e} {p, T, F, TF}
+
 % (lua)bidi commands to change directionality for paragraphs
 % and inline text.
 % overwritten with correct package
 \cs_new_nopar:Nn{\polyglossia at setpardirection:n}{%
-  \str_case_e:nnTF{#1}{%
-       {LR}{\relax}%
-       {RL}{\xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}}%
-     }%
-     {}%
-     {\xpg at error{Unknown~ language~ direction~ #1 ~(base~ wrapper)}}%
+  \__xpg_if_LR_str:nF {#1}
+  {
+    \xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
+  }
 }
 \cs_new_nopar:Nn{\polyglossia at settextdirection:n}{%
-  \str_case_e:nnTF{#1}{%
-       {LR}{\relax}%
-       {RL}{\xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}}%
-     }%
-     {}%
-     {\xpg at error{Unknown~ language~ direction~ #1 ~(base~ wrapper)}}%
+  \__xpg_if_LR_str:nF {#1}
+  {
+    \xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
+  }
 }
-\xpg at at@package{bidi}{package/after/bidi}{%
+\__xpg_at_package_hook:nnn{bidi}{package/bidi/after}{%
   \ExplSyntaxOn%
   \cs_gset_nopar:Nn{\polyglossia at setpardirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\setLR}%
-        {RL}{\setRL}%
-      }%
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(bidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \setLR%
+    }%
+    {%
+      \setRL%
+    }%
   }%
   \cs_gset_nopar:Nn{\polyglossia at settextdirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\LRE}%
-        {RL}{\RLE}%
-      }%
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(bidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \LRE%
+    }%
+    {%
+      \RLE%
+    }%
   }%
   \ExplSyntaxOff%
 }
-\xpg at at@package{luabidi}{package/after/luabidi}{%
+\__xpg_at_package_hook:nnn{luabidi}{package/luabidi/after}{%
   \ExplSyntaxOn%
   \cs_gset_nopar:Nn{\polyglossia at setpardirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\setLR}%
-        {RL}{\setRL}%
-      }
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(luabidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \setLR%
+    }%
+    {%
+      \setRL%
+    }%
   }%
   \cs_gset_nopar:Nn{\polyglossia at settextdirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\LRE}%
-        {RL}{\RLE}%
-      }
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(luabidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \LRE%
+    }%
+    {%
+      \RLE%
+    }%
   }%
   \ExplSyntaxOff%
 }
 
+% emulate \RTLmain
+\cs_new_nopar:Nn \__xpg_setRTLmain: {}
+\str_case_e:nnF{\c_sys_engine_str}{%
+  {luatex}{\cs_gset:Nn \__xpg_setRTLmain: {\setRTLmain}}
+  {xetex}{\cs_gset:Nn \__xpg_setRTLmain: {\@RTLmaintrue\setnonlatin}}
+}
+{
+  \cs_gset:Nn \__xpg_setRTLmain:
+  {
+    \xpg at warning{You’re~ running a~ TeX~ engine~ that~ is~ not~ LuaTeX~ or~ XeTeX.\MessageBreak
+      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
+  }
+}
+
 %% compatibility with babel
 \let\addto\gappto% gappto is defined in etoolbox
 
@@ -3792,6 +3944,8 @@
   %% TODO? \toggletrue{#1 at setup@done}%
   % reinit \do
   \def\do##1{\setotherlanguage{##1}}%
+  % register base alias
+  \xpg_language_alias { #1 } { #1 }
 }
 
 % Adjust language key setting after initial setup
@@ -3804,7 +3958,7 @@
 
 % setup hyphennames from a str list of hyphen
 \cs_new:Nn \polyglossia_setup_hyphen:n {
-  \exp_args:Nne \clist_set:Nn{\l_tmpa_clist}{\prop_item:Nn \polyglossia at langsetup {#1 / hyphennames}}
+  \clist_set:Ne{\l_tmpa_clist}{\prop_item:Nn \polyglossia at langsetup {#1 / hyphennames}}
   \providebool{havehyphen}
   \boolfalse{havehyphen}
   % for each hyphen in the set until we find one that works
@@ -3811,7 +3965,7 @@
   \clist_map_inline:Nn \l_tmpa_clist {
     \ifbool{havehyphen}{}{%
        % check if language hyphenname is defined
-       \polyglossia at check@ifdefined:NF{#1}{%
+      \__xpg_check_if_exist_l@:NF{#1}{%
           % if not, first consider nohyphenation
           \str_if_eq:nnTF{##1}{nohyphenation}
             {%
@@ -3828,7 +3982,7 @@
                       \xpg at set@hyphenation at patterns{##1}
                       \global\booltrue{havehyphen}
                   }%
-               }{}%
+                }{}%
            }%
        }%
     }%
@@ -3847,7 +4001,7 @@
     \polyglossia at setup@language at patterns{#1}%
   }%
   % setup hyphenmins
-  \exp_args:NNe \clist_set:Nn \l_tmpa_clist
+  \clist_set:Ne \l_tmpa_clist
     { \prop_item:Nn \polyglossia at langsetup {#1 / hyphenmins} }
   \cs_if_eq:cNF {l@#1} \l at nohyphenation
     {
@@ -4053,7 +4207,14 @@
             \prop_gput:Nnn{\polyglossia at langsetup}{#1/Localnumeral}{##1}
          },
     #1 / Localnumeral.value_required:n = true,
-    #1 / Localnumeral.initial:n = {polyglossia at C@localnumeral}
+    #1 / Localnumeral.initial:n = {polyglossia at C@localnumeral},
+    % environment define command (by default create the environment)
+    #1 / DefineCommandsCmd
+       .code:n = {\prop_gput:Nnn{\polyglossia at langsetup}{#1/DefineCommandsCmd}{##1}},
+    #1 / DefineCommandsCmd
+       .value_required:n = true,
+    #1 / DefineCommandsCmd
+      .initial:n = {xpg_define_language_commands:e}
   }
 }
 
@@ -4297,7 +4458,10 @@
       }
 }
 
-\AtEndDocument{\prop_log:N{\polyglossia at langsetup}}
+\AtEndDocument{
+  \prop_log:N{\polyglossia at langsetup}
+  \prop_log:N{\__xpg_alias}
+}
 \def\xpg at lastlanguage{0}%
 
 \providebool{xpg at hyphenation@disabled}%
@@ -4454,7 +4618,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{rm}%
+  }%
   \csgdef{#1 at font@sf}{%
     \cs_if_exist_use:cF{#1fontsf}%
       {
@@ -4475,7 +4641,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{sf}%
+  }%
   \csgdef{#1 at font@tt}{%
     \cs_if_exist_use:cF{#1fonttt}%
       {
@@ -4496,7 +4664,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{tt}%
+  }%
   \endgroup
 }
 
@@ -4552,21 +4722,29 @@
 \newXeTeXintercharclass\xpg at normalclass %TODO
 }{}
 
-\ifxetex
 %% when no patterns are available, we use \l at nohyphenation, assigned to 255
 %%  (suggestion by Enrico Gregorio)
-  \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=255 }{}
-\else\ifluatex
-  \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=\directlua{
-    tex.sprint(polyglossia.newloader_loaded_languages.nohyphenation)}\relax
-  }{}
-\fi\fi
+\str_case_e:nn{\c_sys_engine_str}{
+  {luatex}
+    {
+      \@ifundefined{l at nohyphenation}
+        {\chardef\l at nohyphenation=\directlua{
+           tex.sprint(polyglossia.newloader_loaded_languages.nohyphenation)}\relax
+        }
+        {}
+    }
+  {xetex}
+    {
+      \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=255 }{}
+    }
+}
 
+
 %we call this macro when a gloss file is not found for a given language
 \def\xpg at nogloss#1{%
    \xpg at warning{File~ gloss-#1.ldf~ does~ not~ exist!\MessageBreak
    I~ will~ nevertheless~ try~ to~ use~ hyphenation~ patterns~ for~ #1.}%
-  \PolyglossiaSetup{#1}{hyphenmins,hyphennames={#1},fontsetup=true}%
+  \PolyglossiaSetup{#1}{hyphenmins={2,3},hyphennames={#1},fontsetup=true}%
   % the above amounts to:
   %\ifcsundef{l@#1}%
   %  {\expandafter\adddialect\csname l@#1\endcsname\l at nohyphenation\relax}%
@@ -4583,40 +4761,105 @@
   \catcode`\@=\xpg at saved@at at catcode%
 }
 
+%% Load a lde file
+\cs_new_nopar:Nn \__xpg_gloss_ext: {lde}
+\cs_new_nopar:Ne \__xpg_saved_ at pkgextension: {\@pkgextension}
+
+\msg_new:nnn { polyglossia } { directloadgloss }
+{
+  You~ should~ not~ load~ directly~ the~ gloss~ file. ~
+  You~ must~ use~ `\string\setotherlanguage\{#1\}' or  `\string\setmainlanguage\{#1\}'.
+}
+\msg_redirect_name:nnn { polyglossia } { directloadgloss } { critical }
+\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension_error}{m m m m}
+{
+  \msg_critical:nn { polyglossia } { directloadgloss }
+}
+% ProvideExplPackage but for language file
+\cs_new_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
+\cs_new_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
+\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension}{m m m m}
+{
+  \__xpg_saved_ProvidesExplPackage{#1}{#2}{#3}{#4}
+  \cs_gset_eq:NN \@pkgextension \__xpg_saved_ at pkgextension:
+  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
+}
+
+
+% wrapper for loading a gle file
+\NewDocumentCommand{\RequireLanguageDefinitionExtension}{O{} m}
+{
+  \cs_gset_eq:NN \__xpg_saved_ at pkgextension: \@pkgextension
+  \cs_gset_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
+  \cs_gset_eq:NN \@pkgextension \__xpg_gloss_ext:
+  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension
+  \RequirePackage[#1]{gloss-#2}
+  % be paranoiac restore
+  \cs_gset_eq:NN \@pkgextension \__xpg_saved_ at pkgextension:
+  \cs_gset_eq:NN \__xpg_ProvidesLanguageDefinitionExtension_error \ProvideLanguageDefinitionExtension
+}
+
 % try to load a language file
 \cs_new:Nn \polyglossia_load_lang_definition:nn {
-  \file_if_exist:nTF{gloss-#2.ldf}
+  \file_if_exist:eTF{gloss-#2.lde}
   {
-    % Temporarily force catcode of ~ to 13 since babelsh.def
-    % requires it. This is needed particularly with LaTeX3
-    % packages which force \ExplSyntaxOn (#425)
-    \protected\edef\xpg at restore@tilde at catcode{\catcode 126 = \the\catcode 126\relax}
-    \catcode 126 = 13
-    \xpg at input{gloss-#2.ldf}
+    \RequireLanguageDefinitionExtension[#1]{#2}
     \setkeys{#2}{#1}
-    % restore former ~ catcode
-    \xpg at restore@tilde at catcode
   }
   {
-    \xpg at nogloss{#2}
+    \file_if_exist:nTF{gloss-#2.ldf}
+    {
+      % Temporarily force catcode of ~ to 13 since babelsh.def
+      % requires it. This is needed particularly with LaTeX3
+      % packages which force \ExplSyntaxOn (#425)
+      \protected\edef\xpg at restore@tilde at catcode{\catcode 126 = \the\catcode 126\relax}
+      \catcode 126 = 13
+      \xpg at input{gloss-#2.ldf}
+      \setkeys{#2}{#1}
+      % restore former ~ catcode
+      \xpg at restore@tilde at catcode
+    }
+    {
+      \xpg at nogloss{#2}
+    }
   }
 }
+\cs_generate_variant:Nn \polyglossia_load_lang_definition:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 % load a master language from an alias file
 \newcommand*\xpg at load@master at language[1] {
-   \xpg at input{gloss-#1.ldf}
-   \ifcsundef{#1 at loaded}%
-   {
-     \exp_args:Nx\polyglossia at define@language at cmd:n{#1}%
-   }{}
-   \polyglossia at register@language:nn{}{#1}%
-   \csgdef{#1 at loaded}{}%
+  \file_if_exist:eTF{gloss-#1.lde}
+  {
+    \RequireLanguageDefinitionExtension{#1}
+  }
+  {
+    \xpg at input{gloss-#1.ldf}
+  }
+  \seq_if_in:NxF \__xpg_langs_loaded {#1}
+  {
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1} {
+      \use:c{\prop_item:Nn{\polyglossia at langsetup}
+                          {#1/DefineCommandsCmd}}
+                          {#1}
+      }
+  }
+  \polyglossia at register@language:nn{}{#1}%
+  \seq_gput_right:Nn \__xpg_langs_loaded {#1}
 }
 
+\prop_new:N \__xpg_alias
 
-% define environment and command
-\cs_new:Nn \polyglossia at define@language at cmd:n {
-  \ifcsundef{#1 at alias@lang}{%
+% define environment and command if not alias
+\cs_new:Nn \xpg_define_language_commands:n {
+  \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1}
+  {
     \exp_args:Ne
     \newenvironment {\prop_item:Nn{\polyglossia at langsetup}{#1/envname}} [1] []
     {
@@ -4627,130 +4870,213 @@
     }%
     \exp_args:Nc \newcommand {text#1} [2][]
     {%
-      \xpg at textlanguage[##1]{#1}{##2}%
+      \__xpg_textlanguage:een{##1}{#1}{##2}%
     }%
-  }{}
+  }
 }
+\cs_generate_variant:Nn \xpg_define_language_commands:n {e}
 
+\AtBeginDocument{
+  \prop_log:N{\__xpg_alias}
+}
+
+% resolve alias property #1 lang #2 item
+\cs_new:Nn \xpg_alias_prop_item:nn {
+  \prop_if_in:NeTF \__xpg_alias {#1/#2}
+  {
+    \prop_item:Ne \__xpg_alias {#1/#2}
+  }
+  {
+    \prop_if_in:NeTF \__xpg_alias {#1/target}
+    {
+      % target to self fall back to language table
+      \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
+      {
+        \prop_item:Nn{\polyglossia at langsetup} {#1/#2}
+      }
+      % load alias by recursion
+      {
+        \xpg_alias_prop_item:ee { \prop_item:Ne \__xpg_alias {#1/target} } {#2}
+      }
+    }
+    {
+      % empty
+    }
+  }
+}
+\cs_generate_variant:Nn \xpg_alias_prop_item:nn {en, ne, ee}
+
+% add option #2 to list of option of language #1
+\cs_new:Nn \xpg_alias_add_to_option_i:nn
+{
+  \tl_if_blank:eTF {#2}
+  {
+    \xpg_alias_prop_item:nn {#1}{options}
+  }
+  {
+    \tl_if_blank:eTF { \xpg_alias_prop_item:nn {#1}{options} }
+    {
+      #2
+    }
+    {
+      \xpg_alias_prop_item:nn {#1}{options},#2
+    }
+  }
+}
+
+
+% get base language
+\cs_new:Nn \xpg_alias_base_lang:n {
+  \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
+  {
+    #1
+  }
+  {
+    \xpg_alias_base_lang:n {  \prop_item:Ne \__xpg_alias {#1/target} }
+  }
+}
+\cs_generate_variant:Nn \xpg_alias_base_lang:n {e}
+
+\keys_define:nn { polyglossia/alias }
+{
+  % babelname\l_tmpa_prop
+  babelname .prop_put:N = \__xpg_language_alias_prop,
+  % bcp47
+  bcp47 .prop_put:N = \__xpg_language_alias_prop,
+  % variant
+  variant .prop_put:N = \__xpg_language_alias_prop,
+}
+
+
+
 % provide way to define alias environment and command
+% #1 () variant
+% #2 [] option (not yet without variant and bcp47 name)
+% #3 language
+% #4 () babel name
+% #5 [] bcp47 name
+% #6 alias
+\DeclareDocumentCommand \xpg_language_alias { D(){} O{} m D(){} O{} m}
+{
+  \prop_gremove:Nn \__xpg_alias {#6/target}
+  \prop_gremove:Nn \__xpg_alias {#6/options}
+  \prop_gremove:Nn \__xpg_alias {#6/bcp47}
+  \prop_gremove:Nn \__xpg_alias {#6/babelname}
+  \prop_gremove:Nn \__xpg_alias {#6/variant}
+  \prop_gput:Nee \__xpg_alias {#6/target} {#3}
+  \tl_if_blank:eF {#1}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/variant} {#1}
+  }
+  \tl_if_blank:eF {#5}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/bcp47} {#5}
+  }
+  \tl_if_blank:eF {#4}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/babelname} {#1}
+  }
+  \tl_if_blank:eF {#2}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/options} {#2}
+  }
+}
+
+
+% provide way to define alias environment and command
 % \setlanguagealias[<options>]{<language>}{<alias>}
 \DeclareDocumentCommand \setlanguagealias {s O{} m m}
 {
   % The starred version does not define commands and environments
   \IfBooleanF {#1}
+  {
+    \exp_args:Nc \providecommand {text#4} [2][] {}
+    \exp_args:Nc \renewcommand {text#4} [2][]
     {
-     \ifcsundef{#4 at alias@lang}{%
-       \exp_args:Ne
-       \newenvironment {#4}
-       {
-         \begin{otherlanguage}[#2]{#3}
-       }%
-       {
-         \end{otherlanguage}
-       }%
-       \exp_args:Nc \newcommand {text#4} [2][]
-       {%
-         \xpg at textlanguage[#2,##1]{#3}{##2}%
-       }%
-     }{%
-       \exp_args:Ne
-       \renewenvironment {#4}
-       {
-         \begin{otherlanguage}[#2]{#3}
-       }%
-       {
-         \end{otherlanguage}
-       }%
-       \exp_args:Nc \renewcommand {text#4} [2][]
-       {%
-         \xpg at textlanguage[#2,##1]{#3}{##2}%
-       }%
-     }%
+      \__xpg_textlanguage:een{##1}{#4}{##2}
+    }
+    \exp_args:Nc \providecommand {#4} {}
+    \exp_args:Ne  \renewenvironment {#4}
+    {
+      \begin{otherlanguage}{#4}
+    }
+    {
+      \end{otherlanguage}
+    }
   }%
-  \csgdef{#4 at alias@lang}{#3}%
-  \tl_if_blank:nF {#2} {\csgdef{#4 at alias@opts}{#2}}%
+  \tl_clear_new:N \__xpg_alias_option_tl
+  \prop_clear_new:N \__xpg_language_alias_prop
+  \keys_set_known:nnN{polyglossia/alias} {#2} \__xpg_alias_option_tl
+  \xpg_language_alias
+    (\prop_item:Nn \__xpg_language_alias_prop {variant})
+    % TODO not yet [\__xpg_alias_option_tl]
+    [#2]
+    {#3}
+    (\prop_item:Nn \__xpg_language_alias_prop {babelname})
+    [\prop_item:Nn \__xpg_language_alias_prop {bcp47}]
+    {#4}
 }
 
 \cs_new:Nn \polyglossia at register@language:nn {
-   % register polyglossia language name
-   \ifcsundef{#2 at registered}{%
-       \global\edef\xpg at loaded{%
-           \ifx\xpg at loaded\@empty\else\xpg at loaded,\fi #2%
-        }%
-   }{}
-   \csgdef{#2 at registered}{}%
-   \tl_if_blank:nF {#1}{%
-      % Register the language options
-      \polyglossia at set@lang at options:nn {#2} {#1}%
-   }%
-   % register babelname
-   \def\xpg at tmp@babelname{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}}%
-   \ifcsundef{\csname xpg at tmp@babelname\endcsname @bbl at registered}{%
-       \global\edef\xpg at bloaded{%
-           \ifx\xpg at bloaded\@empty\else\xpg at bloaded,\fi\xpg at tmp@babelname}%
-   }{}%
-   \csgdef{\csname xpg at tmp@babelname\endcsname @bbl at registered}{}%
-   % register BCP-47 ID
-   \def\xpg at tmp@bcpname{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
-   \ifcsundef{\csname xpg at tmp@bcpname\endcsname @bcp at registered}{%
-       \global\edef\xpg at bcp@loaded{%
-           \ifx\xpg at bcp@loaded\@empty\else\xpg at bcp@loaded,\fi\xpg at tmp@bcpname}%
-   }{}%
-   \csgdef{\csname xpg at tmp@bcpname\endcsname @bcp at registered}{}%
+  \clist_if_in:NeF \xpg at loaded {#2}{
+    \clist_gput_right:Ne \xpg at loaded {#2}
+  }
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at set@langvariant}
+  % register babelname
+  \prop_get:NeN \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
+  \clist_if_in:NeF \xpg at bloaded {\l_tmpa_tl}{
+    \clist_gput_right:Ne \xpg at bloaded {\l_tmpa_tl}
+  }
+  % register BCP-47 ID
+  \prop_get:NeN \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
+  \clist_if_in:NeF \xpg at bcp@loaded {\l_tmpa_tl}{
+    \clist_gput_right:Ne \xpg at bcp@loaded {\l_tmpa_tl}
+  }
 }
 
-
 \newcommand{\setdefaultlanguage}[2][]{%
   % latex is an internal language, so do not record
-  \ifstrequal{#2}{latex}{}{%
-     % register polyglossia language name
-     \ifcsundef{#2 at registered}{%
-       \global\edef\xpg at loaded{%
-           \ifx\xpg at loaded\@empty\else\xpg at loaded,\fi #2%
-        }%
-     }{}%
-     \csgdef{#2 at registered}{}%
-  }%
-  \ifcsundef{#2 at loaded}%
+  \str_if_eq:eeF{#2}{latex}
   {
-    \polyglossia_load_lang_definition:nn{#1}{#2}
-    % define environment and command (except for internal latex language)
-    \ifstrequal{#2}{latex}{}{%
-      \exp_args:Nx\polyglossia at define@language at cmd:n{#2}
-    }%
-    \csgdef{#2 at loaded}{}%
+    \clist_if_in:NeF \xpg at loaded {\xpg_alias_base_lang:n{##2}}{
+      \clist_gput_right:Ne \xpg at loaded {\xpg_alias_base_lang:n{##2}}
+    }
   }
+  \seq_if_in:NxF \__xpg_langs_loaded {#2}
   {
-    \relax
+    \polyglossia_load_lang_definition:nn{#1}{#2}
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
+       \use:c{\prop_item:Nn{\polyglossia at langsetup}
+            {#2/DefineCommandsCmd}}
+            {#2}
+    }
+    \seq_gput_right:Nn \__xpg_langs_loaded {#2}
   }
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia_load_lang_definition:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-       \exp_args:Nxx \polyglossia at set@default at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       \polyglossia at set@default at language:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    \polyglossia at set@default at language:nn {#1} {#2}%
-  }%
+  \polyglossia at set@default at language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+    {\xpg_alias_base_lang:n{#2}}%
 }
 
+
 \cs_new:Nn \polyglossia at set@default at language:nn
 {
   \gdef\xpg at main@language{#2}%
-  \tl_if_blank:nTF {#1}{\gdef\mainlanguagevariant{}}{%
+  \tl_if_blank:nTF {#1}
+  {
+    \cs_gset_nopar:Npn \mainlanguagevariant {}
+  }
+  {%
      % Register the language options
-     \polyglossia at set@lang at options:nn {#2} {#1}%
+     \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at main@langvariant}%
   }%
   \csgdef{#2 at gvar}{\mainlanguagevariant}%
   %% The following settings are for the default language and script
   % this tells bidi.sty or luabidi.sty that the document is RTL
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}{%
-    \str_case_e:nnF{\c_sys_engine_str}{%
-      {luatex}{\setRTLmain}
-      {xetex}{\@RTLmaintrue\setnonlatin}
-    }{}%
-  }{}%
+  \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+  {
+    \__xpg_setRTLmain:
+  }
   \cs_gset_nopar:Nn \polyglossia at AtBeginDocument@selectlanguage: {
     \selectbackgroundlanguage{#2}
     \selectlanguage[#1]{#2}%
@@ -4757,27 +5083,30 @@
   }
   \xpg at info{Default~ language~ is~ #2}%
   \polyglossia at set@language at name[#1]{#2}%
-  \def\mainlanguagename{#2}
+
+  \cs_gset_nopar:Npn \mainlanguagename {#2}
   % Store babelname of main language (for external packages such as biblatex)
-  \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
-      { \edef\mainbabelname{\l_tmpa_tl} }
+  \cs_gset_nopar:Npe \mainbabelname { \prop_item:Nn  \polyglossia at langsetup {#2/babelname} }
   % Store babelname of current language (for external packages such as biblatex)
-  \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
-      { \edef\babelname{\l_tmpa_tl}% 
-        \cs_gset_eq:cc{#2 at gbabelname}{babelname}%
-      }
+  \cs_gset_eq:NN \babelname \mainbabelname
+  \cs_gset_eq:cc{#2 at gbabelname}{babelname}%
   % Store BCP-47 id of main language
-  \prop_get:NxNT \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
-      { \csedef{mainbcp47id}{\l_tmpa_tl} }
-  % Store BCP-47 id of current language
-  \prop_get:NxNT \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
-      { \csedef{bcp47id}{\l_tmpa_tl}% 
-        \cs_gset_eq:cc{#2 at gbcp47id}{bcp47id}%
-      }
-  \ifluatex %
-  \directlua{polyglossia.set_default_language('\luatexluaescapestring{\string#2}')}%
-  \fi %
+  \cs_gset_nopar:cpe {mainbcp47id} { \prop_item:Nn  \polyglossia at langsetup {#2/bcp47} }
+  \cs_gset_eq:cc {bcp47id} {mainbcp47id}
+  \cs_gset_eq:cc{#2 at gbcp47id}{bcp47id}
+
+ \sys_if_engine_luatex:T
+   {
+     \directlua{polyglossia.set_default_language('\luatexluaescapestring{\string#2}')}%
+   }
 }
+\cs_generate_variant:Nn\polyglossia at set@default at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 \let\setmainlanguage=\setdefaultlanguage
 
@@ -4785,12 +5114,11 @@
 % Currently supported: bcp-47
 \DeclareDocumentCommand \languageid {m}
 {
-    \str_case:nnTF {#1}
+    \str_case:nnF {#1}
       {
         {bcp-47}    { \csuse{bcp47id} }
         {bcp47}     { \csuse{bcp47id} }
       }
-      {}
       {
         \xpg at error{Invalid~ \string\languageid\space argument:~ #1}
       }
@@ -4800,25 +5128,26 @@
 % Currently supported: bcp-47
 \DeclareDocumentCommand \mainlanguageid {m}
 {
-    \str_case:nnTF {#1}
+    \str_case:nnF {#1}
       {
         {bcp-47}    { \csuse{mainbcp47id} }
         {bcp47}     { \csuse{mainbcp47id} }
       }
-      {}
       {
         \xpg at error{Invalid~ \string\mainlanguageid\space argument:~ #1}
       }
 }
-
-\def\mainbabelname{}%
-\def\mainlanguagevariant{}%
+% main babel name
+\cs_new_nopar:Npn \mainlanguagename {}
+\cs_new_nopar:Npn \mainbabelname {}
+\cs_new_nopar:cpn {mainbcp47id} {}
+\cs_new_nopar:Npn \mainlanguagevariant {}%
 % Store main language variant for external packages
 \define at key{xpg at main@langvariant}{variant}{%
-  \gdef\mainlanguagevariant{#1}%
+  \cs_gset_nopar:Npn \mainlanguagevariant {#1}%
 }
 
-\def\babelname{}%
+\cs_new_nopar:Npn \babelname {}
 \def\languagevariant{}%
 % Store current language variant for external packages
 \define at key{xpg at set@langvariant}{variant}{%
@@ -4831,21 +5160,16 @@
      \ifcsundef{#2 at gvar}{\def\languagevariant{}}{\def\languagevariant{\csuse{#2 at gvar}}}
    }{%
      % Register the language options
-     \polyglossia at set@lang at options:nn {#2} {#1}%
+     \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at set@langvariant}%
+     \cs_set_eq:cc{#2 at gvar}{languagevariant}%
   }%
 }
 
 
 \newcommand*{\resetdefaultlanguage}[2][]{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at reset@default at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       polyglossia at reset@default at language:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    polyglossia at reset@default at language:nn {#1} {#2}%
-  }%
+  \polyglossia at reset@default at language:nn
+    {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+    {\xpg_alias_base_lang:n{#2}}%
 }
 
 \cs_new:Nn \polyglossia at reset@default at language:nn
@@ -4859,7 +5183,10 @@
   \cs_if_exist_use:c{noextras at bbl@\mainbabelname}%
   \csuse{init at noextras@\xpg at main@language}%
   \polyglossia at set@language at name[#1]{#2}%
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}{\@rlmaintrue\@rl at footnotetrue}{}%
+  \__xpg_if_LR_str:eF{\prop_item:Ne{\polyglossia at langsetup}{#2/direction}}
+  {
+    \@rlmaintrue\@rl at footnotetrue
+  }
   \selectlanguage[#1]{#2}%
   \selectbackgroundlanguage{#2}%
   % Store babelname of current language (for external packages such as biblatex)
@@ -4883,6 +5210,13 @@
     \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
   }%
 }
+\cs_generate_variant:Nn \polyglossia at reset@default at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 % This saves the normalfont for the latin script since we may change normalfont in other scripts
 \let\normalfontlatin=\normalfont%
@@ -4964,15 +5298,18 @@
 \def\xpg at select@fontfamily#1{%
   \def\tmp at tt{tt}\def\tmp at sf{sf}%
   \ifx\familytype\tmp at tt
-    \csuse at warn{#1 at font@tt}%
+    \__xpg_use_or_warn:c{#1 at font@tt}%
   \else\ifx\familytype\tmp at sf
-    \csuse at warn{#1 at font@sf}%
-      \else\csuse at warn{#1 at font@rm}\fi\fi}
+    \__xpg_use_or_warn:c{#1 at font@sf}%
+      \else\__xpg_use_or_warn:c{#1 at font@rm}\fi\fi}
 
 \def\xpg at set@normalfont#1{%
-  \DeclareRobustCommand\rmfamily{\csuse{#1 at font@rm}}%
-  \DeclareRobustCommand\sffamily{\csuse{#1 at font@sf}}%
-  \DeclareRobustCommand\ttfamily{\csuse{#1 at font@tt}}%
+  \letcs{\rmfamily}{#1 at font@rm}%
+  \letcs{\sffamily}{#1 at font@sf}%
+  \letcs{\ttfamily}{#1 at font@tt}%
+  \robustify\rmfamily%
+  \robustify\sffamily%
+  \robustify\ttfamily%
   \gdef\normalfont{\protect\xpg at select@fontfamily{#1}%
                    \fontseries{\seriesdefault}\selectfont%
                    \fontshape{\shapedefault}
@@ -4991,14 +5328,10 @@
     \@afterindentfalse%
 }
 
-\newcommand*{\selectbackgroundlanguage}[1]{%
-  \ifcsdef{#1 at alias@lang}{%
-     \polyglossia at select@background at language:n {\csuse{#1 at alias@lang}}%
-  }{%
-     \polyglossia at select@background at language:n {#1}%
-  }%
+\cs_new_nopar:Npn \selectbackgroundlanguage #1
+{%
+  \polyglossia at select@background at language:n {\xpg_alias_base_lang:n{#1}}
 }
-
 \cs_new:Nn \polyglossia at select@background at language:n
 {
   \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/lcscript}}{latin}
@@ -5006,26 +5339,23 @@
                    {\xpg at set@normalfont{#1}}%
   \csuse{#1 at globalnumbers}%
 }
-
-\newcommand{\setotherlanguage}[2][]{%
-  \ifcsundef{#2 at loaded}
+\cs_generate_variant:Nn \polyglossia at select@background at language:n {e}
+%  Declare secondary language #2 with language options #1
+\DeclareDocumentCommand \setotherlanguage { O{} m }
+{
+  \seq_if_in:NxF \__xpg_langs_loaded {#2}
   {
-    \polyglossia_load_lang_definition:nn{#1}{#2}
-    % define environment and command
-    \exp_args:Nx\polyglossia at define@language at cmd:n{#2}
-    \ifcsdef{#2 at alias@lang}{%
-       \ifcsdef{#2 at alias@opts}{%
-         \exp_args:Nxx \polyglossia_load_lang_definition:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-         \exp_args:Nxx \polyglossia at set@other at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-       }{%
-         \polyglossia at set@other at language:nn {#1} {\csuse{#2 at alias@lang}}%
-       }%
-    }{%
-      \polyglossia at set@other at language:nn {#1} {#2}%
-    }%
-    \csgdef{#2 at loaded}{}%
+    \polyglossia_load_lang_definition:ee {#1} {#2}%
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
+       \use:c{\prop_item:Nn{\polyglossia at langsetup}
+             {#2/DefineCommandsCmd}}
+             {#2}
+    }
+    \polyglossia at set@other at language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+      {\xpg_alias_base_lang:n{#2}}%
+    \seq_gput_right:Nn \__xpg_langs_loaded {#2}
   }
-  {}
 }
 
 \cs_new:Nn \polyglossia at set@other at language:nn
@@ -5033,16 +5363,23 @@
   \polyglossia at register@language:nn{#1}{#2}%
   % If a variant is set, store it.
   \gdef\otherlanguagevariant{}
-  \tl_if_blank:nTF {#1}{}{%
-    % Register the language options
-    \polyglossia at set@lang at options:nn {#2} {#1}%
-  }%
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at other@langvariant}%
+
   \csgdef{#2 at gvar}{\otherlanguagevariant}%
   \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
     { \xdef\otherlanguagebabelname{\l_tmpa_tl} }
   \cs_gset_eq:cc{#2 at gbabelname}{otherlanguagebabelname}%
 }
+\cs_generate_variant:Nn  \polyglossia at set@other at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
+
 % Store main language variant for external packages
 \define at key{xpg at other@langvariant}{variant}{%
   \gdef\otherlanguagevariant{#1}%
@@ -5071,15 +5408,7 @@
 % where \text<alias> would cause clashes
 % (e.g., \textit)
 \newcommand\textlang[3][]{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \xpg at textlanguage[\csuse{#2 at alias@opts},#1]{\csuse{#2 at alias@lang}}{#3}%
-     }{%
-       \xpg at textlanguage[#1]{\csuse{#2 at alias@lang}}{#3}%
-     }%
-  }{%
-    \xpg at textlanguage[#1]{#2}{#3}%
-  }%
+  \__xpg_textlanguage:een {#1} {#2} {#3}
 }%
 
 % Alias to {<lang>}, but more suitable
@@ -5122,6 +5451,8 @@
 
 % joint code of \foreignlanguage, otherlanguage*
 % and \text<lang>
+% #1 option
+% #2 language
 \newcommand{\xpg at otherlanguage}[2][]
 {%
   \polyglossia at error@iflangnotloaded:n{#2}
@@ -5137,67 +5468,91 @@
 }
 
 \renewcommand{\foreignlanguage}[3][]
-{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at foreignlanguage:nnn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}} {#3}%
-     }{%
-       \polyglossia at foreignlanguage:nnn {#1} {\csuse{#2 at alias@lang}} {#3}%
-     }%
-  }{%
-    \polyglossia at foreignlanguage:nnn {#1} {#2} {#3}%
-  }%
+{
+  \__xpg_foreignlanguage:eeen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
 }
 
-\cs_new:Nn \polyglossia at foreignlanguage:nnn
+% internal wrapper for foreing language
+% #1 option
+% #2 alias
+% #3 base lang
+% #3 text
+\cs_new:Nn \__xpg_foreignlanguage:nnnn
 {
-   \polyglossia at error@iflangnotloaded:n{#2}
-   \bgroup
-   \xpg at otherlanguage[#1]{#2}%
-   \polyglossia at lang@settextdirection:nn{#2}{#3}%
-   \egroup
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \group_begin:
+    \xpg at otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#4}%
+    \polyglossia at lang@settextdirection:nn{#3}{#4}%
+  \group_end:
 }
+\cs_generate_variant:Nn \__xpg_foreignlanguage:nnn {een}
 
+
 % otherlanguage* is the environment equivalent of \foreignlanguage
 \expandafter\providecommand\csname otherlanguage*\endcsname{}
 
 \renewenvironment{otherlanguage*}[2][]
 {%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at otherlanguage:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       \polyglossia at otherlanguage:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    \polyglossia at otherlanguage:nn {#1} {#2}%
-  }%
+  \__xpg_otherlanguage:eee {#1} {#2} {\xpg_alias_base_lang:n{#2}}
 }
-{\egroup}
+{\group_end:}
 
-\cs_new:Nn \polyglossia at otherlanguage:nn
+% internal wrapper
+% #1 option
+% #2 alias
+% #3 base lang
+\cs_new:Nn \__xpg_otherlanguage:nnn
 {
-  \xpg at otherlanguage[#1]{#2}%
-  \polyglossia at lang@settextdirection:nn{#2}\bgroup%
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \xpg at otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#3}%
+  \polyglossia at lang@settextdirection:nn{#3}\group_begin:%
 }
+\cs_generate_variant:Nn \__xpg_otherlanguage:nnn {
+  eee
+}
 
 % use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
 % except that dates are localized.
-\newcommand\xpg at textlanguage[3][]{%
-  \polyglossia at error@iflangnotloaded:n{#2}
-   \bgroup
-   \xpg at otherlanguage[#1]{#2}%
-   \csuse{date#2}%
-   % This is a hook for external packages which want to access variants
-   % via babelname (such as biblatex)
-   \cs_if_exist_use:c{date at bbl@\babelname}%
-   \polyglossia at lang@settextdirection:nn{#2}{#3}%
-   \egroup
+% #1: option
+% #2: alias
+% #3: text
+\cs_new:Nn \__xpg_textlanguage:nnn
+{
+  \__xpg_textlanguage:nnen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
+}
+\cs_generate_variant:Nn \__xpg_textlanguage:nnn {een}
+
+% use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
+% except that dates are localized.
+% #1: option
+% #2: alias
+% #3: base language
+% #4: text
+\cs_new:Nn \__xpg_textlanguage:nnnn
+{
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \group_begin:
+    \xpg at otherlanguage[#1]{#3}%
+    \csuse{date#3}%
+    % This is a hook for external packages which want to access variants
+    % via babelname (such as biblatex)
+    \cs_if_exist_use:c{date at bbl@\babelname}%
+    \polyglossia at lang@settextdirection:nn{#3}{#4}%
+  \group_end:
   % Reset the language's/script's font families
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}}{latin}{}{\resetfontlatin}%
+  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#3/lcscript}}{latin}{}{\resetfontlatin}%
 }
+\cs_generate_variant:Nn \__xpg_textlanguage:nnnn {nnen}
 
-
 % Define language-specific hyphenation exceptions
 \newcommand\pghyphenation[3][]{
   \bgroup
@@ -5219,51 +5574,52 @@
   \let\emp at langname\@undefined}
 
 \DeclareDocumentCommand \selectlanguage {s O{} m}
-{%
-  \ifcsdef{#3 at alias@lang}{%
-     \ifcsdef{#3 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at select@language:nnn {#1} {\csuse{#3 at alias@opts},#2} {\csuse{#3 at alias@lang}}%
-     }{%
-       \polyglossia at select@language:nnn {#1} {#2} {\csuse{#3 at alias@lang}}%
-     }%
-  }{%
-     \polyglossia at error@iflangnotloaded:n{#3}%
-     \polyglossia at select@language:nnn {#1} {#2} {#3}%
-  }
+{
+  \__xpg_msg_if_lang_not_loaded:n {#3}
+  \polyglossia at select@language:nee {#1}
+    {\xpg_alias_add_to_option_i:nn{#3}{#2}}
+    {\xpg_alias_base_lang:n{#3}}
 }
 
 \cs_new:Nn \polyglossia at select@language:nnn
 {
   \IfBooleanF {#1}
-    {
-      \cs_set_nopar:Npx \xpg at pop@language { \exp_not:N \xpg at pop@language at i {#2} {#3} }
-      \group_insert_after:N \xpg at pop@language
-    }
-  \tl_if_blank:nTF {#2}{}{%
-    % Register the language options
-    \polyglossia at set@lang at options:nn {#3} {#2}%
-   }%
-   % The starred variant does not write to the aux
-   \IfBooleanTF#1{%
-     \xpg at set@language at nonaux[#2]{#3}%
-   }{%
-     \xpg at set@language at aux[#2]{#3}%
-   }%
-   \ifluatex%
-     \directlua{polyglossia.select_language('\luatexluaescapestring{\string#3}',
-                     \the\csname l@#3\endcsname)}%
-   \fi%
+  {
+    \cs_set_nopar:Npx \xpg at pop@language { \exp_not:N \xpg at pop@language at i {#2} {#3} }
+    \group_insert_after:N \xpg at pop@language
+  }
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#3} {#2} {@xpg at set@langvariant}%
+  % The starred variant does not write to the aux
+  \IfBooleanTF#1{%
+    \xpg at set@language at nonaux[#2]{#3}%
+  }
+  {%
+    \xpg at set@language at aux[#2]{#3}%
+  }%
+  \sys_if_engine_luatex:T
+  {
+    \directlua{polyglossia.select_language('\luatexluaescapestring{\string#3}',
+      \the\csname l@#3\endcsname)}%
+  }
   \polyglossia at register@language:nn{#2}{#3}%
 }
+\cs_generate_variant:Nn \polyglossia at select@language:nnn {
+ nee, nne
+}
 
 
-\cs_new:Nn \polyglossia at set@lang at options:nn
-{  
+% set lang option #2 for lang #1
+\cs_new:Nn \polyglossia at set@lang at options:nnn
+{
+  \tl_if_blank:nF {#2}
+  {
     % If the optional argument sets a value for the key “variant”, copy it to xpg at langvariant
     \clist_map_inline:nn { #2 } {%
-        \xpg at parsevariantkeyvalue##1=@xpg at langvariant:#1\relax
+      \xpg at parsevariantkeyvalue##1=#3:#1\relax
     }%
     \exp_args:Nne \setkeys{#1}{#2}%
+  }
 }
 
 % Initialize default language options, so that
@@ -5270,7 +5626,7 @@
 % \iflanguageoption has the info it needs also
 % for default settings
 \newcommand*\xpg at initialize@gloss at options[2]{%
-   \polyglossia at set@lang at options:nn {#1} {#2}%
+   \polyglossia at set@lang at options:nnn {#1} {#2} {@xpg at set@langvariant}%
 }
 
 % Record synonymous keyvals such as variant=us and variant=american
@@ -5320,16 +5676,16 @@
 {
   \prop_get:cnNTF {xpg at current@options@#1} {#2} \l_tmpa_tl
      {
-        \exp_args:Nee \str_if_eq:NNTF{\l_tmpa_tl}{#3}
+       \str_if_eq:eeTF{\l_tmpa_tl}{#3}
           {\prg_return_true:}
           {
             \prop_get:cnNTF {xpg at alias@keyvals@#1@#3} {#2} \l_tmpb_tl
                {
-                \exp_args:Nne \clist_set:Nn{\l_tmpa_clist}{\l_tmpb_tl}
+                \clist_set:Ne{\l_tmpa_clist}{\l_tmpb_tl}
                 \providetoggle{xpgvalfound}
                 \togglefalse{xpgvalfound}
                 \clist_map_inline:Nn \l_tmpa_clist {
-                   \exp_args:Nee \str_if_eq:NNT{##1}{\l_tmpa_tl}
+                   \str_if_eq:eeT{##1}{\l_tmpa_tl}
                       { \toggletrue{xpgvalfound} }
                 }
                 \iftoggle{xpgvalfound}{\prg_return_true:}{\prg_return_false:}
@@ -5352,39 +5708,39 @@
 
 % Append any variant to csv list of variants
 \define at key{xpg at langvariant}{variant}{%
-  \edef\xpg at vloaded{#1\ifx\xpg at vloaded\@empty\else,\xpg at vloaded\fi}%
-}
-
-\prg_set_conditional:Npnn \polyglossia at check@if at lang@loaded:N #1 { p , T , F , TF }{
-  \cs_if_exist:cTF{#1}{
-     \prg_return_true:
-  }{
-    \prg_return_false:
+  \clist_if_in:NeF \xpg at vloaded {#1}{
+    \clist_gput_right:Ne \xpg at vloaded {#1}
   }
 }
 
 % Test if language is loaded
 \newcommand*\iflanguageloaded[3]{%
-  \polyglossia at check@if at lang@loaded:NTF{#1 at loaded}{#2}{#3}%
+   \AddToHook{begindocument/end}{%
+     \clist_if_in:NeTF \xpg at loaded{#1}{#2}{#3}%
+   }%
 }
 
 % Same for babellanguage is loaded
 \newcommand*\ifbabellanguageloaded[3]{%
-  \polyglossia at check@if at lang@loaded:NTF{#1 at bbl@loaded}{#2}{#3}%
+  \AddToHook{begindocument/end}{%
+     \clist_if_in:NeTF \xpg at bloaded{#1}{#2}{#3}%
+  }%
 }
 
 % Same for languageid
 \DeclareDocumentCommand \iflanguageidloaded {mmmm}
 {
+  \AddToHook{begindocument/end}{%
     \str_case:nnTF {#1}
       {
-        {bcp-47}    { \polyglossia at check@if at lang@loaded:NTF{#2 at bcp@loaded}{#3}{#4} }
-        {bcp47}     { \polyglossia at check@if at lang@loaded:NTF{#2 at bcp@loaded}{#3}{#4} }
+        {bcp-47}    { \clist_if_in:NeTF \xpg at bcp@loaded{#2}{#3}{#4} }
+        {bcp47}     { \clist_if_in:NeTF \xpg at bcp@loaded{#2}{#3}{#4} }
       }
       {}
       {
         \xpg at error{Invalid~ \string\iflanguageidloaded\space argument:~ #1}
       }
+   }%
 }
 
 % Check if the current font has a given glyph
@@ -5403,8 +5759,10 @@
            }
   }
   {
-    \xpg at warning{You’re running a TeX engine that is not LuaTeX or XeTeX.\MessageBreak
-                 That is almost guaranteed to cause problems.}
+    \xpg at warning{You’re ~ running ~ a ~ TeX engine ~ that ~ is ~
+      not ~ LuaTeX ~ or ~ XeTeX.\MessageBreak
+      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
+    \prg_return_false:
   }
 }
 
@@ -5446,6 +5804,11 @@
    }%
    \@select at language[#1]{#2}%
     % Write to the aux
+   \xpg at set@language at only@aux[#1]{#2}%
+}
+
+\newcommand*{\xpg at set@language at only@aux}[2][]{%
+    % Write to the aux
    \if at filesw%
       \ifx#1\\\\%
           \protected at write\@auxout{}{\protect\selectlanguage*{#2}}%
@@ -5477,45 +5840,8 @@
   }{}%
 }
 
-% Open a group in the aux file. This is to keep
-% nested language options local (see #320).
-% In bidi tables, the opening/closing needs to be swapped (see #354)
-\newcommand*{\xpg at set@group at aux}{%
-   \if at filesw%
-      \ifbool{xpg at inbiditable}{%
-        \protected at write\@auxout{}{\egroup}%
-        \addtocontents{toc}{\egroup}%
-        \addtocontents{lof}{\egroup}%
-        \addtocontents{lot}{\egroup}%
-      }{%
-        \protected at write\@auxout{}{\bgroup}%
-        \addtocontents{toc}{\bgroup}%
-        \addtocontents{lof}{\bgroup}%
-        \addtocontents{lot}{\bgroup}%
-      }%
-    \fi
-}
-
-% Close the group in the aux file.
-% In bidi RTL tables, the opening/closing needs
-% to be swapped (see #354).
-\newcommand*{\xpg at unset@group at aux}{%
-   \if at filesw%
-      \ifbool{xpg at inbiditable}{%
-        \protected at write\@auxout{}{\bgroup}%
-        \addtocontents{toc}{\bgroup}%
-        \addtocontents{lof}{\bgroup}%
-        \addtocontents{lot}{\bgroup}%
-      }{%
-        \protected at write\@auxout{}{\egroup}%
-        \addtocontents{toc}{\egroup}%
-        \addtocontents{lof}{\egroup}%
-        \addtocontents{lot}{\egroup}%
-      }%
-    \fi
-}
-
-\prg_set_conditional:Npnn \polyglossia at check@ifdefined:N #1 { p , T , F , TF }{
+% check if language is defined
+\prg_set_conditional:Npnn \__xpg_check_if_exist_l@:N #1 { p , T , F , TF }{
   \cs_if_exist:cTF {l@#1}
     {
       \cs_if_eq:cNTF {l@#1} \l at nohyphenation
@@ -5537,21 +5863,22 @@
 \def\polyglossia at luatex@load at lang#1{%
   % if \l@#1 is not properly defined, call lua function newloader(#1),
   % and assign the returned number to \l@#1
-  \polyglossia at check@ifdefined:NF {#1}
-    {
-      \expandafter\chardef\csname l@#1\endcsname=
-        \directlua{ tex.sprint(polyglossia.newloader'#1') }\relax
-    }
+  \__xpg_check_if_exist_l@:NF {#1}
+  {
+    \expandafter\chardef\csname l@#1\endcsname=
+    \directlua{ tex.sprint(polyglossia.newloader'#1') }\relax
+  }
 }
 
 % This check is also used by biblatex, so don't
 % rename silently.
 \newcommand\xpg at ifdefined[3]{%
-    % With luatex, we first need to define \l@#1.
-    \ifluatex
-      \polyglossia at luatex@load at lang{#1}%
-    \fi
-    \polyglossia at check@ifdefined:NTF{#1}{#2}{#3}%
+  % With luatex, we first need to define \l@#1.
+  \sys_if_engine_luatex:T
+  {
+    \polyglossia at luatex@load at lang{#1}%
+  }
+  \__xpg_check_if_exist_l@:NTF{#1}{#2}{#3}%
 }%
 
 % Set \bbl at hyphendata@\the\language, which is (lua)babel's
@@ -5558,27 +5885,32 @@
 % hyphenation pattern hook
 % FIXME Clarifiy why/when this is needed.
 \newcommand*\xpg at set@bbl at hyphendata[1]{%
-    \ifluatex%
-        \ifcsdef{bbl at hyphendata@#1}{}{%
-            \global\@namedef{bbl at hyphendata@\the\language}{}%
-        }%
-    \fi% 
+  \sys_if_engine_luatex:T
+  {
+    \ifcsdef{bbl at hyphendata@#1}{}{%
+      \global\@namedef{bbl at hyphendata@\the\language}{}%
+    }%
+  }
 }
 
 % Set hyphenation patterns for a given language. This does the right
 % thing both for XeTeX and LuaTeX
 \newcommand*\xpg at set@hyphenation at patterns[1]{%
-  \ifluatex
-    \polyglossia at luatex@load at lang{#1}%
-    \language=\csname l@#1\endcsname
-  \else
-    \ifxetex
-      \language=\csname l@#1\endcsname
-    \else
+  \str_case_e:nnF{\c_sys_engine_str}{
+      {luatex}
+        {
+          \polyglossia at luatex@load at lang{#1}%
+          \language=\csname l@#1\endcsname
+        }
+      {xetex}
+        {
+          \language=\csname l@#1\endcsname
+        }
+    }
+    {
       \xpg at warning{You’re~running~a~TeX~engine~that~is~not~LuaTeX~or~XeTeX.\MessageBreak
         That~is~almost~guaranteed~to~cause~problems.}%
-    \fi
-  \fi
+    }
 }
 
 
@@ -5615,38 +5947,46 @@
 % Hook for external packages such as biblatex
 \def\polyglossia at language@switched{}
 
-\def\noextrascurrent#1{%
-   \csuse{noextras@#1}%
-   % This is a hook for external packages which want to access variants
-   % via babelname (such as biblatex)
-   \cs_if_exist_use:c{noextras at bbl@\babelname}
+% remove all custumization for language #1
+\cs_new:Npn \noextrascurrent #1
+{%
+  \cs_if_exist_use:c{noextras@#1}%
+  % This is a hook for external packages which want to access variants
+  % via babelname (such as biblatex)
+  \cs_if_exist_use:c{noextras at bbl@\babelname}
 }
 
 % Common code for `\select at language' and `\foreignlanguage'.
 \newcommand{\select@@language}[2][]{%
   % disable the extras and number settings of the previous language
-  \ifcsundef{languagename}{}{%
-     \noextrascurrent{\languagename}%
-     \csuse{no\languagename @numbers}%
-     \ifxetex
-        \str_if_eq:eeTF{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-            {%
-               \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}%
-                  {}% RTL -> RTL
-                  {\setlatin}% RTL -> LTR
-            }{%
-               \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}%
-                  {\setnonlatin}% LTR -> RTL
-                  {}% LTR -> LTR
-           }%
-     \fi
+  \cs_if_exist:cT{languagename}
+  {%
+    \noextrascurrent{\languagename}%
+    \cs_if_exist_use:c{no\languagename @numbers}%
+    \sys_if_engine_xetex:T{
+      \__xpg_if_LR_str:eTF{\prop_item:Ne{\polyglossia at langsetup}{\languagename/direction}}
+      {
+        \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+          {\setnonlatin}% LTR -> RTL
+      }%
+      {%
+        \__xpg_if_LR_str:eT{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+          {\setlatin}% RTL -> LTR
+      }
+    }
   }%
   \polyglossia at set@language at name[#1]{#2}%
   % Set the language's/script's font families
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}}{latin}{\resetfontlatin}{\xpg at set@normalfont{#2}}%
+  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}} {latin}
+  {
+    \resetfontlatin
+  }
+  {
+    \xpg at set@normalfont{#2}
+  }%
   \xpg at select@fontfamily{#2}%
-  \csuse at warn{#2 at language}%
-  \csuse{#2 at numbers}%
+  \__xpg_use_or_warn:c{#2 at language}%
+  \cs_if_exist_use:c{#2 at numbers}%
   \use at localhyphenmins[#1]{#2}%
   \polyglossia at lang@frenchspacing:n{#2}
 }
@@ -5656,24 +5996,48 @@
 
 \provideenvironment{otherlanguage}{}{}
 
-\newbool{xpg at noset@groups}
+%
+% Keep track of the active (nested) languages and options
+%
+\clist_new:N \l_xpg_lang_stack
+
+\cs_new:Nn \polyglossia at stack@language:nn
+{
+  \clist_push:Nn \l_xpg_lang_stack {#1:#2}
+}
+
+\cs_generate_variant:Nn \seq_set_split:Nnn {Nnx}
+
+\cs_new:Nn \polyglossia at unstack@language:n
+{
+  \clist_gpop:NNTF \l_xpg_lang_stack \l_tmpa_tl {
+     % Stored format = options:language => split:
+     \seq_set_split:Nnx \l_tmpa_seq {:} \l_tmpa_tl
+     \seq_get_left:NN \l_tmpa_seq \l_tmpb_tl
+     \seq_get_right:NN \l_tmpa_seq \l_tmpc_tl
+     % Execute passed command with language and maybe options
+     \tl_if_empty:NTF \l_tmpb_tl {\cs_if_exist_use:c{#1}{\l_tmpc_tl}}
+                                 {\cs_if_exist_use:c{#1}[\l_tmpb_tl]{\l_tmpc_tl}}
+  }
+  {}
+}
+
 \renewenvironment{otherlanguage}[2][]
 {%
-  % We usually embrace the switch in groups to keep the changes local.
-  % We cannot do this if an LTR environmet starts in an RTL paragraph,
-  % as bidi interferes here badly with its directionality smartness.
-  \ifxetex
-    \str_if_eq:eeT{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-       {%
-        \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/direction}}{RL}%
-           {}% RTL -> RTL
-           {\ifvmode\else\booltrue{xpg at noset@groups}\fi}% RTL -> LTR
-       }%
-  \fi%
-  \ifbool{xpg at noset@groups}{}{\xpg at set@group at aux}%
+  % Get real current options (incl. defaults)
+  \clist_clear_new:N \l_xpg_current_options
+  \prop_map_inline:cn {xpg at current@options@#2}
+  {
+      \clist_put_right:Nn \l_xpg_current_options {##1=##2}
+  }
+  % Store current options and language on stack
+  \polyglossia at stack@language:nn{\clist_use:Nn \l_xpg_current_options {,}}{#2}%
   \selectlanguage[#1]{#2}%
 }
-{\ifbool{xpg at noset@groups}{}{\xpg at unset@group at aux}}
+{%
+   % restore previous language in aux file and remove closed one from stack
+   \polyglossia at unstack@language:n{xpg at set@language at only@aux}%
+}
 
 \newcommand{\setlocalhyphenmins}[3]{%
    \xpg at ifdefined{#1}{%
@@ -5690,14 +6054,8 @@
 % \setlanghyphenmins[options]{lang}{l}{r}
 \newcommand*\setlanghyphenmins[4][]{%
   % Check for real language name and options
-  \edef\xpg at tmp@lang{#2}%
-  \edef\xpg at tmp@opts{#1}%
-  \ifcsdef{#2 at alias@lang}{%
-     \edef\xpg at tmp@lang{\csuse{#2 at alias@lang}}%
-     \ifcsdef{#2 at alias@opts}{%
-       \edef\xpg at tmp@opts{\csuse{#2 at alias@opts},#1}%
-     }{}%
-  }{}%
+  \edef\xpg at tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
+  \edef\xpg at tmp@lang{\xpg_alias_base_lang:n{#2}}
   \bgroup
   \polyglossia at error@iflangnotloaded:n{\xpg at tmp@lang}
   \exp_args:Nne \setkeys{\xpg at tmp@lang}{\xpg at tmp@opts}%
@@ -5704,12 +6062,12 @@
   % Store BCP-47 id of language
   \tl_if_blank:nTF {\xpg at tmp@opts}{%
     \ifcsundef{\csname xpg at tmp@lang\endcsname @gbcp47id}{%
-       \csedef{tmp at bcp47id}{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
+       \csedef{tmp at bcp47id}{\prop_item:Ne{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
     }{%
        \csedef{tmp at bcp47id}{\csuse{#2 at gbcp47id}}%
     }%
   }{%
-    \csedef{tmp at bcp47id}{\exp_args:Nne \prop_item:Nn{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
+    \csedef{tmp at bcp47id}{\prop_item:Ne{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
   }%
   \xpg at warning{id: \csuse{tmp at bcp47id}}%
   \csgdef{\csname tmp at bcp47id\endcsname @hyphenmins}{{#3}{#4}}%
@@ -5741,15 +6099,15 @@
       \edef\tmpa{\csuse{\csname tmp at bcp47id\endcsname @hyphenmins}}%
       \expandafter\expandafter\expandafter\set at hyphenmins\tmpa\relax%
    }
-   \ifluatex
+   \sys_if_engine_luatex:T{
      % Set \totalhyphenmin if specified
      \prop_get:NxNTF \polyglossia at langsetup {#2/totalhyphenmin} \l_tmpa_tl
      {
-        \xpg at warning{totalhyphenmin: '\l_tmpa_tl'}
+        \xpg at info{totalhyphenmin: '\l_tmpa_tl'}
         \expandafter\hyphenationmin \l_tmpa_tl%
      }%
      {}%
-   \fi
+   }
 }
 
 % Babel previously compiled in hyphenrules into the kernel (via hyphen.cfg)
@@ -5761,37 +6119,17 @@
 % supports language options and aliases.
 \renewenvironment{hyphenrules}[2][]
 {%
-  % We usually embrace the switch in groups to keep the changes local.
-  % We cannot do this if an LTR environmet starts in an RTL paragraph,
-  % as bidi interferes here badly with its directionality smartness.
-  \ifxetex
-    \str_if_eq:eeT{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-       {%
-        \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/direction}}{RL}%
-           {}% RTL -> RTL
-           {\ifvmode\else\booltrue{xpg at noset@groups}\fi}% RTL -> LTR
-       }%
-  \fi%
-  \ifbool{xpg at noset@groups}{}{\xpg at set@group at aux}%
   % Check for real language name and options
-  \edef\xpg at tmp@lang{#2}%
-  \edef\xpg at tmp@opts{#1}%
-  \ifcsdef{#2 at alias@lang}{%
-     \edef\xpg at tmp@lang{\csuse{#2 at alias@lang}}%
-     \ifcsdef{#2 at alias@opts}{%
-       \edef\xpg at tmp@opts{\csuse{#2 at alias@opts},#1}%
-     }{}%
-  }{}%
-  \tl_if_blank:nF {\xpg at tmp@opts}{%
-     % Register the language options
-     \polyglossia at set@lang at options:nn {\xpg at tmp@lang} {\xpg at tmp@opts}%
-  }%
+  \edef\xpg at tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
+  \edef\xpg at tmp@lang{\xpg_alias_base_lang:n{#2}}
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {\xpg at tmp@lang} {\xpg at tmp@opts} {@xpg at set@langvariant}%
   % Now switch patterns
-  \csuse at warn{\csuse{xpg at tmp@lang}@language}%
+  \__xpg_use_or_warn:c{\use:c{xpg at tmp@lang}@language}%
   % And activate hyphenmins
   \use at localhyphenmins[\xpg at tmp@opts]{\xpg at tmp@lang}%
 }
-{\ifbool{xpg at noset@groups}{}{\xpg at unset@group at aux}}
+{}
 
 \AtEndPreamble{%
    \@ifpackageloaded{bidi}{%
@@ -5846,15 +6184,15 @@
 
 % Set the LuaTeX renderer. As opposed to fontspec, we use Harfbuzz by default.
 % This can be changed via the luatexrenderer package option.
-\ifluatex
-  \exp_args:Nee \str_if_eq:nnF{\l_polyglossia_luatex_renderer}{none}
-     {
-         \xpg at info{Setting~ LuaTeX~ font~ renderer~ to~ \l_polyglossia_luatex_renderer}
-         \exp_args:Nee \defaultfontfeatures{Renderer=\l_polyglossia_luatex_renderer}
-     }
-\fi
+\sys_if_engine_luatex:T{
+  \str_if_eq:eeF{\l_polyglossia_luatex_renderer}{none}
+  {
+    \xpg at info{Setting~ LuaTeX~ font~ renderer~ to~ \l_polyglossia_luatex_renderer}
+    \exp_args:Ne \defaultfontfeatures{Renderer=\l_polyglossia_luatex_renderer}
+  }
+}
 
-\bool_if:nTF \l_polyglossia_verbose_bool {} {
+\bool_if:nF \l_polyglossia_verbose_bool {
    \gdef\@latex at info#1{\relax}% no latex info
    \gdef\@font at info#1{\relax}% no latex font info
    \gdef\@font at warning#1{\relax}% no latex font warnings
@@ -5862,9 +6200,9 @@
    \gdef\xpg at info#1{\relax}% no polyglossia info
 }
 
-\bool_if:nTF \l_polyglossia_localmarks_bool {
+\bool_if:nT \l_polyglossia_localmarks_bool {
   \polyglossia at enable@local at marks:
-}{}
+}
 
 % compatibility
 \newif\ifsystem at babelshorthands
@@ -9247,11 +9585,11 @@
 }
 
 \def\blockextras at afrikaans{%
-  \ifafrikaans at babelshorthands\afrikaans at shorthands\fi%
+  \ifafrikaans at babelshorthands\afrikaans at shorthands\else\noafrikaans at shorthands\fi%
 }
 
 \def\inlineextras at afrikaans{%
-  \ifafrikaans at babelshorthands\afrikaans at shorthands\fi%
+  \ifafrikaans at babelshorthands\afrikaans at shorthands\else\noafrikaans at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -9855,9 +10193,10 @@
     \fi%
  \fi}}
 
+% Use \providecommand here as the ldf file might
+% be reloaded via aeb (BCP).
+\providecommand{\arabicnumerals}[2]{\arabicnumber{#2}}
 
-\newcommand{\arabicnumerals}[2]{\arabicnumber{#2}}
-
 \def\arabicnumber#1{%
   \ifeastern at numerals
     \@ensure at dir{\arabicdigits{\number#1}}%
@@ -10666,8 +11005,10 @@
   \csuse{datebelarusian@\belarusian at spelling}%
 }
 
-\newcommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
-\newcommand{\Belarusiannumerals}[2]{\Belarusiannumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via be-tarask (BCP).
+\providecommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
+\providecommand{\Belarusiannumerals}[2]{\Belarusiannumber{#2}}
 
 \def\belarusiannumber#1{%
   \ifcyrillic at numerals
@@ -10743,12 +11084,12 @@
 }
 
 \def\blockextras at belarusian{%
-   \ifcyrillic at numerals\belarusian at numbers\fi%
-   \ifbelarusian at babelshorthands\belarusian at shorthands\fi%
+   \ifcyrillic at numerals\belarusian at numbers\else\nobelarusian at numbers\fi%
+   \ifbelarusian at babelshorthands\belarusian at shorthands\else\nobelarusian at shorthands\fi%
 }
 
 \def\inlineextras at belarusian{%
-   \ifbelarusian at babelshorthands\belarusian at shorthands\fi%
+   \ifbelarusian at babelshorthands\belarusian at shorthands\else\nobelarusian at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -10988,7 +11329,7 @@
   \def\today{\number\day.~\ifcase\month\or
     januar\or februar\or mart\or april\or maj\or
     juni\or juli\or august\or septembar\or oktobar\or novembar\or
-    decembar\fi \space \number\year.~}%
+    decembar\fi \space \number\year.}%
 }
 
 %    \end{macrocode}
@@ -11457,11 +11798,11 @@
 }
 
 \def\blockextras at catalan{%
-   \ifcatalan at babelshorthands\catalan at shorthands\fi%
+   \ifcatalan at babelshorthands\catalan at shorthands\else\nocatalan at shorthands\fi%
 }
 
 \def\inlineextras at catalan{%
-   \ifcatalan at babelshorthands\catalan at shorthands\fi%
+   \ifcatalan at babelshorthands\catalan at shorthands\else\nocatalan at shorthands\fi%
 }
 %    \end{macrocode}
 % \iffalse
@@ -11603,14 +11944,25 @@
 
 \define at boolkey{croatian}[croatian@]{babelshorthands}[true]{}
 
-\define at boolkey{croatian}[croatian@]{disableligatures}[true]{}
+\define at boolkey{croatian}[croatian@]{disabledigraphs}[true]{}
 
+% Alias kept for backwards compatibility. Please do not remove
+\define at boolkey{croatian}[croatian@]{disableligatures}[true]{%
+   \xpg at warning{The option disableligatures is deprected.\MessageBreak
+                Please use disabledigraphs instead}%
+   \ifcroatian at disableligatures
+      \croatian at disabledigraphstrue
+   \else
+      \croatian at disabledigraphsfalse
+   \fi
+}
+
 \define at boolkey{croatian}[croatian@]{splithyphens}[true]{}
 
 \define at boolkey{croatian}[croatian@]{localalph}[true]{}
 
 % Register default options
-\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disableligatures=false,
+\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disabledigraphs=false,
                                         splithyphens=true,localalph=true}
 
 \ifsystem at babelshorthands
@@ -11626,6 +11978,14 @@
 }{}
 
 \def\croatian@@splhyphen#1{%
+  \def\croatian at sh@tmp{%
+       \if\croatian at sh@next-#1%
+       \else\expandafter\croatian@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\croatian at sh@next\croatian at sh@tmp%
+}
+
+\def\croatian@@@splhyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -11655,12 +12015,12 @@
   \declare at shorthand{croatian}{"'}{”}%
   \declare at shorthand{croatian}{"<}{«}%
   \declare at shorthand{croatian}{">}{»}%
-  \declare at shorthand{croatian}{"D}{\xpg at hr@lig{D}}%
-  \declare at shorthand{croatian}{"d}{\xpg at hr@lig{d}}%
-  \declare at shorthand{croatian}{"L}{\xpg at hr@lig{L}}%
-  \declare at shorthand{croatian}{"l}{\xpg at hr@lig{l}}%
-  \declare at shorthand{croatian}{"N}{\xpg at hr@lig{N}}%
-  \declare at shorthand{croatian}{"n}{\xpg at hr@lig{n}}%
+  \declare at shorthand{croatian}{"D}{\xpg at hr@digraph{D}}%
+  \declare at shorthand{croatian}{"d}{\xpg at hr@digraph{d}}%
+  \declare at shorthand{croatian}{"L}{\xpg at hr@digraph{L}}%
+  \declare at shorthand{croatian}{"l}{\xpg at hr@digraph{l}}%
+  \declare at shorthand{croatian}{"N}{\xpg at hr@digraph{N}}%
+  \declare at shorthand{croatian}{"n}{\xpg at hr@digraph{n}}%
 }
 
 \def\nocroatian at shorthands{%
@@ -11693,24 +12053,24 @@
     \fi%
 }
 
-\newcommand*\hr at charifavailable[2]{%
-   \ifcroatian at disableligatures
-     \bgroup#2\egroup%
-   \else
-     \charifavailable{#1}{#2}%
+\newcommand*\hr at charifavailable[3]{%
+   \ifcroatian at disabledigraphs% no notion of digraphs at all
+     \bgroup#3\egroup%
+   \else% digraph...
+     \charifavailable{#1}{#2}% ... either a Unicode original or a mimic of one
    \fi%
 }
 
-% Provide croatian ligatures if available in current font
-\def\xpg at hr@lig#1#2{%
+% Provide croatian digraphs if available in current font
+\def\xpg at hr@digraph#1#2{%
  \bgroup%
   % 1. DŽ, Dž and dž
   \ifx#1D%
     \ifx#2Z\relax%
-       \hr at charifavailable{01C4}{DŽ}%
+       \hr at charifavailable{01C4}{D\nobreak Ž}{DŽ}%
     \else%
        \ifx#2z\relax
-          \hr at charifavailable{01C5}{Dž}%
+          \hr at charifavailable{01C5}{D\nobreak ž}{Dž}%
        \else
            D#2%
        \fi%
@@ -11718,7 +12078,7 @@
   \fi%
   \ifx#1d%
     \ifx#2z\relax
-       \hr at charifavailable{01C6}{dž}%
+       \hr at charifavailable{01C6}{d\nobreak ž}{dž}%
     \else
        d#2%
     \fi%
@@ -11726,10 +12086,10 @@
   % 2. LJ, Lj and lj
   \ifx#1L%
     \ifx#2J\relax%
-       \hr at charifavailable{01C7}{LJ}%
+       \hr at charifavailable{01C7}{L\nobreak J}{LJ}%
     \else%
        \ifx#2j\relax
-          \hr at charifavailable{01C8}{Lj}%
+          \hr at charifavailable{01C8}{L\nobreak j}{Lj}%
        \else
            L#2%
        \fi%
@@ -11737,7 +12097,7 @@
   \fi%
   \ifx#1l%
     \ifx#2j\relax
-       \hr at charifavailable{01C9}{lj}%
+       \hr at charifavailable{01C9}{l\nobreak j}{lj}%
     \else
        l#2%
     \fi%
@@ -11745,10 +12105,10 @@
   % 2. NJ, Nj and nj
   \ifx#1N%
     \ifx#2J\relax%
-       \hr at charifavailable{01CA}{NJ}%
+       \hr at charifavailable{01CA}{N\nobreak J}{NJ}%
     \else%
        \ifx#2j\relax
-          \hr at charifavailable{01CB}{Nj}%
+          \hr at charifavailable{01CB}{N\nobreak j}{Nj}%
        \else
            N#2%
        \fi%
@@ -11756,7 +12116,7 @@
   \fi%
   \ifx#1n%
     \ifx#2j\relax
-       \hr at charifavailable{01CC}{nj}%
+       \hr at charifavailable{01CC}{n\nobreak j}{nj}%
     \else
        n#2%
     \fi%
@@ -11769,7 +12129,7 @@
   \def\refname{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
-  \def\chaptername{Poglav\hr at charifavailable{01C9}{lj}e}%
+  \def\chaptername{Poglav\xpg at hr@digraph{l}{j}e}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Popis slika}%
@@ -11790,9 +12150,9 @@
 
 \def\datecroatian{%
   \def\today{\number\day.~\ifcase\month\or
-    siječ\hr at charifavailable{01CC}{nj}a\or ve\hr at charifavailable{01C9}{lj}ače\or
-    ožujka\or trav\hr at charifavailable{01CC}{nj}a\or svib\hr at charifavailable{01CC}{nj}a\or
-    lip\hr at charifavailable{01CC}{nj}a\or srp\hr at charifavailable{01CC}{nj}a\or
+    siječ\xpg at hr@digraph{n}{j}a\or ve\xpg at hr@digraph{l}{j}ače\or
+    ožujka\or trav\xpg at hr@digraph{n}{j}a\or svib\xpg at hr@digraph{n}{j}a\or
+    lip\xpg at hr@digraph{n}{j}a\or srp\xpg at hr@digraph{n}{j}a\or
     kolovoza\or rujna\or listopada\or studenoga\or prosinca\fi \space \number\year.}%
 }
 
@@ -11815,13 +12175,13 @@
 }
 
 \def\blockextras at croatian{%
-  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+  \ifcroatian at babelshorthands\croatian at shorthands\else\nocroatian at shorthands\fi%
   \ifcroatian at splithyphens\croatian at hyphens\else\nocroatian at hyphens\fi%
   \ifcroatian at localalph\let\alph\croatian at alph\let\Alph\croatian at Alph\fi%
 }
 
 \def\inlineextras at croatian{%
-  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+  \ifcroatian at babelshorthands\croatian at shorthands\else\nocroatian at shorthands\fi%
   \ifcroatian at splithyphens\croatian at hyphens\else\nocroatian at hyphens\fi%
   \ifcroatian at localalph\let\alph\croatian at alph\let\Alph\croatian at Alph\fi%
 }
@@ -11904,7 +12264,15 @@
   \shorthandoff{"}%
 }{}
 
-\def\cs@@splithyphen#1{%
+\def\czech@@splithyphen#1{%
+  \def\czech at sh@tmp{%
+       \if\czech at sh@next-#1%
+       \else\expandafter\czech@@@splithyphen{#1}\fi%
+     }%
+     \futurelet\czech at sh@next\czech at sh@tmp%
+}
+
+\def\czech@@@splithyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -11913,14 +12281,14 @@
   \fi%
 }
 
-\def\cs at splithyphen{%
-  \cs@@splithyphen{-}%
+\def\czech at splithyphen{%
+  \czech@@splithyphen{-}%
 }
 
 \def\czech at shorthands{%
   \bbl at activate{"}%
   \def\language at group{czech}%
-  \declare at shorthand{czech}{"=}{\cs at splithyphen}%
+  \declare at shorthand{czech}{"=}{\czech at splithyphen}%
   \declare at shorthand{czech}{"`}{„}%
   \declare at shorthand{czech}{"'}{“}%
   \declare at shorthand{czech}{"<}{«}%
@@ -11957,9 +12325,9 @@
     \else
       \XeTeXinterchartokenstate=1
       \XeTeXcharclass `\- \czech at hyphen
-      \XeTeXinterchartoks \z@ \czech at hyphen = {\cs@@splithyphen}% "-" -> "\cs@@splithyphen-"
+      \XeTeXinterchartoks \z@ \czech at hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
       % necessary if used together with vlna:
-      \XeTeXinterchartoks \czech at nonsyllabicpreposition \czech at hyphen = {\cs@@splithyphen}% "-" -> "\cs@@splithyphen-"
+      \XeTeXinterchartoks \czech at nonsyllabicpreposition \czech at hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
     \fi%
 }
 
@@ -12091,13 +12459,13 @@
 }
 
 \def\blockextras at czech{%
-  \ifczech at babelshorthands\czech at shorthands\fi%
+  \ifczech at babelshorthands\czech at shorthands\else\noczech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
   \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }
 
 \def\inlineextras at czech{%
-  \ifczech at babelshorthands\czech at shorthands\fi%
+  \ifczech at babelshorthands\czech at shorthands\else\noczech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
   \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }
@@ -12642,11 +13010,11 @@
 }
 
 \def\blockextras at dutch{%
-  \ifdutch at babelshorthands\dutch at shorthands\fi%
+  \ifdutch at babelshorthands\dutch at shorthands\else\nodutch at shorthands\fi%
 }
 
 \def\inlineextras at dutch{%
-  \ifdutch at babelshorthands\dutch at shorthands\fi%
+  \ifdutch at babelshorthands\dutch at shorthands\else\nodutch at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -12819,19 +13187,20 @@
 }
 
 % BCP-47 compliant aliases
-\setlanguagealias*{english}{en}
-\setlanguagealias*[variant=australian]{english}{en-AU}
-\setlanguagealias*[variant=newzealand]{english}{en-NZ}
-\setlanguagealias*[variant=us]{english}{en-US}
-\setlanguagealias*[variant=british]{english}{en-GB}
-\setlanguagealias*[variant=canadian]{english}{en-CA}
+\setlanguagealias*[bcp47=en]{english}{en}
+\setlanguagealias*[variant=australian,babelname=autralian,bcp47=en-AU]{en}{en-AU}
+\setlanguagealias*[variant=canadian,babelname=canadian,bcp47=en-CA]{en}{en-CA}
+\setlanguagealias*[variant=british,babelname=british,bcp47=en-NZ]{en}{en-GB}
+\setlanguagealias*[variant=newzealand,babelname=newzealand,bcp47=en-NZ]{en}{en-NZ}
+\setlanguagealias*[variant=us,babelname=american,bcp47=en-US]{en}{en-US}
 
+
 % Babel aliases
-\setlanguagealias[variant=us]{english}{american}
-\setlanguagealias[variant=australian]{english}{australian}
-\setlanguagealias[variant=british]{english}{british}
-\setlanguagealias[variant=canadian]{english}{canadian}
-\setlanguagealias[variant=newzealand]{english}{newzealand}
+\setlanguagealias[variant=us]{en-US}{american}
+\setlanguagealias[variant=australian]{en-AU}{australian}
+\setlanguagealias[variant=british]{en-GB}{british}
+\setlanguagealias[variant=canadian]{en-CA}{canadian}
+\setlanguagealias[variant=newzealand]{en-NZ}{newzealand}
 
 \providebool{british at hyphen}
 \providebool{english at ordinalmonthday}
@@ -12979,6 +13348,7 @@
    \def\alsoname{see also}%
    \def\proofname{Proof}%
 }
+
 \def\dateenglish{%
    \def\english at day{%
      \ifenglish at ordinalmonthday
@@ -13290,8 +13660,10 @@
 
 \define at boolkey{finnish}[finnish@]{babelshorthands}[true]{}
 
+\define at boolkey{finnish}[finnish@]{schoolhyphens}[true]{}
+
 % Register default options
-\xpg at initialize@gloss at options{finnish}{babelshorthands=false}
+\xpg at initialize@gloss at options{finnish}{babelshorthands=false,schoolhyphens=false}
 
 \ifsystem at babelshorthands
   \setkeys{finnish}{babelshorthands=true}
@@ -13345,6 +13717,21 @@
    \def\proofname{Todistus}%
    \def\glossaryname{Sanasto}%
 }
+
+\def\finnish at language{%
+  \iffinnish at schoolhyphens
+      \xpg at ifdefined{schoolfinnish}{%
+         \polyglossia at setup@language at patterns{schoolfinnish}%
+      }{%
+           \xpg at warning{Finnish 'School' hyphenation patterns (schoolfinnish) not available.\MessageBreak
+	                I will use the standard patterns for Finnish instead}%
+	   \polyglossia at setup@language at patterns{finnish}%
+     }%
+  \else
+      \polyglossia at setup@language at patterns{finnish}%
+  \fi
+}
+
 \def\datefinnish{%
    \def\today{\number\day.~\ifcase\month\or
     tammikuuta\or helmikuuta\or maaliskuuta\or huhtikuuta\or
@@ -13357,11 +13744,11 @@
 }
 
 \def\blockextras at finnish{%
-  \iffinnish at babelshorthands\finnish at shorthands\fi%
+  \iffinnish at babelshorthands\finnish at shorthands\else\nofinnish at shorthands\fi%
 }
 
 \def\inlineextras at finnish{%
-  \iffinnish at babelshorthands\finnish at shorthands\fi%
+  \iffinnish at babelshorthands\finnish at shorthands\else\nofinnish at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -14496,12 +14883,12 @@
 }
 
 \def\blockextras at georgian{%
-   \ifgeorgian at numerals\georgian at numbers\fi%
-   \ifgeorgian at babelshorthands\georgian at shorthands\fi%
+   \ifgeorgian at numerals\georgian at numbers\else\nogeorgian at numbers\fi%
+   \ifgeorgian at babelshorthands\georgian at shorthands\else\nogeorgian at shorthands\fi%
 }
 
 \def\inlineextras at georgian{%
-   \ifgeorgian at babelshorthands\georgian at shorthands\fi%
+   \ifgeorgian at babelshorthands\georgian at shorthands\else\nogeorgian at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -14664,7 +15051,7 @@
    \xpg at info{Option: German, script=\xpg at val}%
 }{\xpg at warning{Unknown German script `#1'}}
 
-% Option defunc'ed, as bot XeTeX and LuaTeX meanwhile
+% Option defunc'ed, as both XeTeX and LuaTeX meanwhile
 % use the experimental German hyphenation patterns by default.
 \define at boolkey{german}[german@]{latesthyphen}[true]{}
 
@@ -14673,7 +15060,7 @@
 \setkeys{german}{spelling,script,variant}
 
 % Register default options
-\xpg at initialize@gloss at options{german}{variant=german,spelling=new,script=latin,latesthyphen=false,babelshorthands=false}
+\xpg at initialize@gloss at options{german}{variant=german,spelling=new,script=latin,babelshorthands=false}
 % Register alias options
 \xpg at set@alias at values{german}{spelling}{new}{1996}
 \xpg at set@alias at values{german}{spelling}{old}{1901}
@@ -14829,11 +15216,11 @@
 }
 
 \def\blockextras at german{%
-  \ifgerman at babelshorthands\german at shorthands\fi%
+  \ifgerman at babelshorthands\german at shorthands\else\nogerman at shorthands\fi%
 }
 
 \def\inlineextras at german{%
-  \ifgerman at babelshorthands\german at shorthands\fi%
+  \ifgerman at babelshorthands\german at shorthands\else\nogerman at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -15144,8 +15531,10 @@
    \renewrobustcmd\anw at print{ʹ}}
 \anw at true
 
-\newcommand{\greeknumerals}[2]{\greeknumber{#2}}
-\newcommand{\Greeknumerals}[2]{\Greeknumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via politunikogreek.
+\providecommand{\greeknumerals}[2]{\greeknumber{#2}}
+\providecommand{\Greeknumerals}[2]{\Greeknumber{#2}}
 
 \protected\def\greeknumber#1{\expandafter\@greeknumber\expandafter{\number#1}}
 \def\@greeknumber#1{%
@@ -16353,12 +16742,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifitalian at babelshorthands\italian at shorthands\fi%
+   \ifitalian at babelshorthands\italian at shorthands\else\noitalian at shorthands\fi%
 }
 
 \def\inlineextras at italian{%
    \lccode\string"2019=\string"2019%
-   \ifitalian at babelshorthands\italian at shorthands\fi%
+   \ifitalian at babelshorthands\italian at shorthands\else\noitalian at shorthands\fi%
 }
 %%% CHANGES END %%%
 %    \end{macrocode}
@@ -17120,16 +17509,25 @@
   % change chapter and part headings
   \if at korean@swapheadings
     % With titlesec
-    \ifdefined\titleformat
-      \ifdefined\@part
-        \let\xpg at save@part at format\@part
-        \patchcmd{\@part}%
+    \ifcsdef{titleformat}{%
+      \ifcsdef{H at old@part}{% Hyperref
+        \let\xpg at save@part at format\H at old@part
+        \patchcmd{\H at old@part}%
                  {\partname\nobreakspace\thepart}%
                  {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                  {}%
                  {\xpg at warning{Failed to patch part for Korean}}%
-      \fi
-      \ifdefined\chapter
+      }{% not hyperref
+        \ifcsdef{@part}{%
+            \let\xpg at save@part at format\@part
+            \patchcmd{\@part}%
+                     {\partname\nobreakspace\thepart}%
+                     {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                     {}%
+                     {\xpg at warning{Failed to patch part for Korean}}%
+        }{}%
+      }
+      \ifcsdef{chapter}{%
         \titleformat\chapter[display]%
           {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
           {%
@@ -17139,15 +17537,15 @@
               \koreanTHEname\space \thechapter\space \@chapapp
             \fi
           }{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
-      \fi
-    \else % (not \ifdefined\titleformat)
+      }{}%
+    }{% (not \ifdefined\titleformat)
       % With KOMA
-      \ifdefined\sectionformat
-        \ifdefined\partformat
+      \ifcsdef{sectionformat}{%
+        \ifcsdef{partformat}{%
           \let\xpg at save@part at format\partformat
           \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
-        \fi
-        \ifdefined\chapterformat
+        }{}%
+        \ifcsdef{chapterformat}{%
           \let\xpg at save@chap at format\chapterformat
           \renewcommand*{\chapterformat}{\mbox{%
             \IfChapterUsesPrefixLine
@@ -17160,11 +17558,11 @@
             }%
             {\thechapter\autodot\enskip}%
           }}%
-        \fi
-      \else % (not \ifdefined\sectionformat)
+        }{}%
+      }{% (not \ifdefined\sectionformat)
         % With memoir
-        \ifdefined\@memptsize
-          \ifdefined\@makechapterhead
+        \ifcsdef{@memptsize}{%
+          \ifcsdef{@makechapterhead}{%
             \let\xpg at save@chap at format\@makechapterhead
             \patchcmd{\@makechapterhead}%
                      {\printchaptername \chapternamenum \printchapternum}%
@@ -17182,10 +17580,10 @@
                 \ifpatchable\printchaptername\@chapapp
                   {\chapnamefont\koreanTHEname\chapternamenum}{}}%
             \fi
-          \fi
-          \ifdefined\@part
-            \let\xpg at save@part at format\@part
-            \patchcmd{\@part}%
+          }{}%
+          \ifcsdef{H at old@part}{% Hyperref
+            \let\xpg at save@part at format\H at old@part
+            \patchcmd{\H at old@part}%
                      {\printpartname \partnamenum \printpartnum}%
                      {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
                      {}%
@@ -17193,10 +17591,22 @@
             \ifdefined\printkoreanpartthe\else
               \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
             \fi
-          \fi
-        \else % (not \ifdefined\@memptsize)
+          }{% not hyperref
+            \ifcsdef{@part}{%
+              \let\xpg at save@part at format\@part
+              \patchcmd{\@part}%
+                       {\printpartname \partnamenum \printpartnum}%
+                       {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
+                       {}%
+                       {\xpg at warning{Failed to patch part for Korean}}%
+              \ifdefined\printkoreanpartthe\else
+                \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
+              \fi
+            }{}%
+          }%
+        }{% (not \ifdefined\@memptsize)
           % With standard classes
-          \ifdefined\@makechapterhead
+          \ifcsdef{@makechapterhead}{%
             \let\xpg at save@chap at format\@makechapterhead
             \patchcmd{\@makechapterhead}%
                      {\@chapapp\space \thechapter}%
@@ -17209,23 +17619,35 @@
                      }%
                      {}%
                      {\xpg at warning{Failed to patch chapter for Korean}}%
-          \fi
-          \ifdefined\@part
-            \let\xpg at save@part at format\@part
-            \patchcmd{\@part}%
+          }{}%
+          \ifcsdef{H at old@part}{% Hyperref
+            \let\xpg at save@part at format\H at old@part
+            \patchcmd{\H at old@part}%
                      {\partname\nobreakspace\thepart}%
                      {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                      {}%
                      {\xpg at warning{Failed to patch part for Korean}}%
-          \fi % (end \ifdefined\@part)
-        \fi % (end \ifdefined\@memptsize)
-      \fi % (end \ifdefined\sectionformat)
-    \fi % (end \ifdefined\titleformat)
+          }{% not hyperref
+            \ifcsdef{@part}{%
+              \ifpatchable{\@part}%
+                   {\partname\nobreakspace\thepart}%
+                   {\let\xpg at save@part at format\@part
+                    \patchcmd{\@part}%
+                             {\partname\nobreakspace\thepart}%
+                             {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                             {}%
+                             {\ifcsdef{part}{\xpg at warning{Failed to patch part for Korean}}{}}}%
+                   {}%
+            }{}%  (end \ifdefined\@part)
+          }% (end not hyperref)
+        }% (end \ifdefined\@memptsize)
+      }% (end \ifdefined\sectionformat)
+    }% (end \ifdefined\titleformat)
   \fi % (end \if at korean@swapheadings)
   %
   % Change running headers
   \if at korean@swapheaders
-    \ifdefined\chapterformat
+    \ifcsdef{chapterformat}{%
       % With KOMA
       \let\xpg at save@chaptermark at format\chaptermarkformat
       \renewcommand*\chaptermarkformat{%
@@ -17240,8 +17662,8 @@
         {\thechapter\autodot}%
         \enskip
       }%
-    \else % (not \ifdefined\chapterformat)
-      \ifdefined\@memptsize
+    }{% (not \ifdefined\chapterformat)
+      \ifcsdef{@memptsize}{%
         % With memoir
         \let\xpg at save@chaptermark at format\chaptermark
         \patchcmd{\chaptermark}%
@@ -17254,74 +17676,85 @@
                    \fi
                  }%
                  {}%
-                 {}%
-      \else % (not \ifdefined\@memptsize)
+                 {\xpg at warning{Failed to patch chaptermark for Korean}}%
+      }{% (not \ifdefined\@memptsize)
         % With standard classes
-        \ifdefined\chaptermark
-          \let\xpg at save@chaptermark at format\chaptermark
-          \patchcmd{\chaptermark}%
-                   {\@chapapp\ \thechapter}%
-                   {%
-                     \ifx\@chapapp\korean at appendix@chapapp
-                       \appendixname\ \thechapter
-                     \else
-                       \koreanTHEname\ \thechapter\ \@chapapp
-                     \fi
-                   }%
-                   {}%
-                   {}%
-        \fi % (end \ifdefined\chaptermark)
-      \fi % (end \ifdefined\@memptsize)
-    \fi % (end \ifdefined\chapterformat)
+        \ifcsdef{chaptermark}{%
+          \ifpatchable{\chaptermark}%
+               {\@chapapp\ \thechapter}%
+               {\let\xpg at save@chaptermark at format\chaptermark
+                \patchcmd{\chaptermark}%
+                         {\@chapapp\ \thechapter}%
+                         {%
+                           \ifx\@chapapp\korean at appendix@chapapp
+                             \appendixname\ \thechapter
+                           \else
+                             \koreanTHEname\ \thechapter\ \@chapapp
+                           \fi
+                         }%
+                         {}%
+                         {\xpg at warning{Failed to patch chaptermark for Korean}}}%
+               {}%
+        }{}% (end \ifdefined\chaptermark)
+      }% (end \ifdefined\@memptsize)
+    }% (end \ifdefined\chapterformat)
   \fi % (end \if at korean@swapheaders)
 }
 
 \def\nokorean at headingsformat{%
   % Reset chapter and part heading
-  \ifdefined\titleformat
+  \ifcsdef{titleformat}{%
     % With titlesec
-    \ifdefined\xpg at save@part at format
-      \let\@part\xpg at save@part at format
-    \fi
-    \ifdefined\chapter
+    \ifcsdef{xpg at save@part at format}{%
+      \ifcsdef{H at old@part}{%
+        \let\H at old@part\xpg at save@part at format
+      }{%
+        \let\@part\xpg at save@part at format
+      }%
+    }{}%
+    \ifcsdef{chapter}{%
       \titleformat\chapter[display]%
         {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
         {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
-    \fi
-  \else % (not \ifdefined\titleformat)
-    \ifdefined\sectionformat
+    }{}%
+  }{% (not \ifdefined\titleformat)
+    \ifcsdef{sectionformat}{%
       % With KOMA
-      \ifdefined\xpg at save@part at format
+      \ifcsdef{xpg at save@part at format}{%
         \let\partformat\xpg at save@part at format
-      \fi
-      \ifdefined\xpg at save@chap at format
+      }{}%
+      \ifcsdef{xpg at save@chap at format}{%
         \let\chapterformat\xpg at save@chap at format
-      \fi
-    \else
+      }{}%
+    }{%
       % With memoir and standard classes
-      \ifdefined\xpg at save@part at format
-        \let\@part\xpg at save@part at format
-      \fi
-      \ifdefined\xpg at save@chap at format
+      \ifcsdef{xpg at save@part at format}{%
+        \ifcsdef{H at old@part}{%
+          \let\H at old@part\xpg at save@part at format
+        }{%
+          \let\@part\xpg at save@part at format
+        }%
+      }{}%
+      \ifcsdef{xpg at save@chap at format}{%
         \let\@makechapterhead\xpg at save@chap at format
-      \fi
-    \fi % (end \ifdefined\sectionformat)
-  \fi % (end \ifdefined\titleformat)
+      }{}%
+    }% (end \ifdefined\sectionformat)
+  }% (end \ifdefined\titleformat)
   %
   % Reset headers
-  \ifdefined\chaptermarkformat
+  \ifcsdef{chaptermarkformat}{%
     % With KOMA
-    \ifdefined\xpg at save@chaptermark at format
+    \ifcsdef{xpg at save@chaptermark at format}{%
       \let\chaptermarkformat\xpg at save@chaptermark at format
-    \fi
-  \else
-    \ifdefined\chaptermark
+    }{}%
+  }{%
+    \ifcsdef{chaptermark}{%
       % With memoir and standard classes
-      \ifdefined\xpg at save@chaptermark at format
+      \ifcsdef{xpg at save@chaptermark at format}{%
         \let\chaptermark\xpg at save@chaptermark at format
-      \fi
-    \fi % (end \ifdefined\chaptermark)
-  \fi % (end \ifdefined\chapterformat)
+      }{}%
+    }{}% (end \ifdefined\chaptermark)
+  }% (end \ifdefined\chapterformat)
 }
 
 \def\datekorean{%
@@ -17824,7 +18257,9 @@
   \csname datekurdish@\kurdish at variant @\kurdish at script\endcsname%
 }
 
-\newcommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via BCP.
+\providecommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}
 
 \def\kurdishnumber#1{%
   \if at western@numerals
@@ -18064,47 +18499,6 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-lao.ldf>
-%<*gloss-latex.ldf>
-% \fi
-% \clearpage
-% 
-% \subsection{gloss-latex.ldf}
-%    \begin{macrocode}
-\ProvidesFile{gloss-latex.ldf}[polyglossia: module for default language]
-
-\PolyglossiaSetup{latex}{
-  hyphennames={english},
-  hyphenmins={2,3},
-  langtag=ENG,
-  fontsetup=true,
-}
-
-\def\captionslatex{%
-   \def\prefacename{Preface}%
-   \def\refname{References}%
-   \def\abstractname{Abstract}%
-   \def\bibname{Bibliography}%
-   \def\chaptername{Chapter}%
-   \def\appendixname{Appendix}%
-   \def\contentsname{Contents}%
-   \def\listfigurename{List of Figures}%
-   \def\listtablename{List of Tables}%
-   \def\indexname{Index}%
-   \def\figurename{Figure}%
-   \def\tablename{Table}%
-   \def\partname{Part}%
-   \def\enclname{encl}%
-   \def\ccname{cc}%
-   \def\headtoname{To}%
-   \def\pagename{Page}%
-   \def\seename{see}%
-   \def\alsoname{see also}%
-   \def\proofname{Proof}%
-}
-
-%    \end{macrocode}
-% \iffalse
-%</gloss-latex.ldf>
 %<*gloss-latin.ldf>
 % \fi
 % \clearpage
@@ -18111,7 +18505,7 @@
 % 
 % \subsection{gloss-latin.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.3 2020-03-08]
+\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.4 2021-10-25]
 
 \ExplSyntaxOn
 
@@ -18140,7 +18534,7 @@
 
 \bool_new:N \l_polyglossia_latin_use_j_bool
 \bool_new:N \l_polyglossia_latin_use_v_bool
-\bool_new:N \l_polyglossia_latin_use_digraphs_bool
+\bool_new:N \l_polyglossia_latin_use_ligatures_bool
 \bool_new:N \l_polyglossia_latin_capitalize_month_bool
 
 \cs_new:Npn \polyglossia_latin_classical_character_codes:
@@ -18501,7 +18895,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_false:N \l_polyglossia_latin_use_v_bool
-    \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {classic}
@@ -18513,7 +18907,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_false:N \l_polyglossia_latin_use_v_bool
-    \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {medieval}
@@ -18525,7 +18919,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_true:N \l_polyglossia_latin_use_v_bool
-    \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {modern}
@@ -18537,7 +18931,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_true:N \l_polyglossia_latin_use_v_bool
-    \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_true:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {ecclesiastic}
@@ -18632,7 +19026,7 @@
   {
     \def \prefacename
       {
-        \bool_if:NTF \l_polyglossia_latin_use_digraphs_bool {Præfatio} {Praefatio}
+        \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool {Præfatio} {Praefatio}
       }
     \def \refname {Conspectus~librorum}
     \def \abstractname {Summarium}
@@ -18658,7 +19052,7 @@
 
 \cs_new:Npn \polyglossia_latin_month_name:
   {
-    \str_set:Nx \l_tmpa_str
+    \tl_set:Nx \l_tmpa_tl
       {
         \int_case:nn { \month }
           {
@@ -18678,10 +19072,10 @@
       }
     \bool_if:NTF \l_polyglossia_latin_capitalize_month_bool
       {
-        \tl_mixed_case:n { \l_tmpa_str }
+        \text_titlecase:n { \l_tmpa_tl }
       }
       {
-        \str_use:N \l_tmpa_str
+        \l_tmpa_tl
       }
   }
 
@@ -18830,28 +19224,28 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_digraph_shorthand:Nnn E { Æ }
+        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Æ }
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Æ }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Æ }
                     {
                       \polyglossia_latin_allow_hyphens: A
                     }
                 }
             }
-        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { æ }
+        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { æ }
                 {
                   \polyglossia_latin_allow_hyphens: a
                 }
             }
-        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { Π}
+        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { Π}
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Π}
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Π}
                     {
                       \polyglossia_latin_allow_hyphens: O
                     }
                 }
             }
-        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { œ }
+        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { œ }
                 {
                   \polyglossia_latin_allow_hyphens: o
                 }
@@ -18861,23 +19255,20 @@
         {>} { » }
       }
       {
-        \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: #1 }
+        \tl_if_single_token:nTF {#1}
           {
-            \token_if_eq_meaning:NNTF #1 \AE { \polyglossia_latin_allow_hyphens: #1 }
+            \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: }
               {
-                \token_if_eq_meaning:NNTF #1 \ae { \polyglossia_latin_allow_hyphens: #1 }
+                \polyglossia_latin_if_ligature_command:NTF #1 { \polyglossia_latin_allow_hyphens: }
                   {
-                    \token_if_eq_meaning:NNTF #1 \OE { \polyglossia_latin_allow_hyphens: #1 }
-                      {
-                        \token_if_eq_meaning:NNTF #1 \oe { \polyglossia_latin_allow_hyphens: #1 }
-                          {
-                            \token_to_str:N "
-                            #1
-                          }
-                      }
+                    \token_to_str:N "
                   }
               }
           }
+          {
+            \token_to_str:N "
+          }
+          #1
       }
   }
 
@@ -18885,22 +19276,22 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_digraph_shorthand:Nnn E { Ǽ }
+        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Ǽ }
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Ǽ } { Á }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Ǽ } { Á }
                 }
             }
-        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { ǽ } { á } }
+        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { ǽ } { á } }
         {E} { É }
         {e} { é }
         {I} { Í }
         {i} { í }
-        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { \'Π}
+        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { \'Π}
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { \'Œ } { Ó }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { \'Œ } { Ó }
                 }
             }
-        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { \'œ } { ó } }
+        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { \'œ } { ó } }
         {U} { Ú }
         {u} { ú }
         {V} { \' V } % V may be a vowel, but lowercase v is never used as a vowel.
@@ -18912,20 +19303,17 @@
         {œ} { \'œ }
       }
       {
-        \token_if_eq_meaning:NNTF #1 \AE { Ǽ }
+        \tl_if_single_token:nTF {#1}
           {
-            \token_if_eq_meaning:NNTF #1 \ae { ǽ }
+            \polyglossia_latin_if_ligature_command:NTF #1 { \' }
               {
-                \token_if_eq_meaning:NNTF #1 \OE { \'Π}
-                  {
-                    \token_if_eq_meaning:NNTF #1 \oe { \'œ }
-                      {
-                        \token_to_str:N '
-                        #1
-                      }
-                  }
+                \token_to_str:N '
               }
           }
+          {
+            \token_to_str:N '
+          }
+          #1
       }
   }
 
@@ -18933,9 +19321,9 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_diphthong_macron:NNn AE
+        {A} { \polyglossia_latin_ligature_macron:NNnn AE { Ǣ }
                 {
-                  \polyglossia_latin_diphthong_macron:NNn Ae
+                  \polyglossia_latin_ligature_macron:NNnn Ae { Ǣ }
                     {
                       \polyglossia_latin_diphthong_macron:NNn AU
                         {
@@ -18944,7 +19332,7 @@
                     }
                 }
             }
-        {a} { \polyglossia_latin_diphthong_macron:NNn ae
+        {a} { \polyglossia_latin_ligature_macron:NNnn ae { ǣ }
                 {
                   \polyglossia_latin_diphthong_macron:NNn au { ā }
                 }
@@ -18957,12 +19345,12 @@
         {e} { \polyglossia_latin_diphthong_macron:NNn eu { ē } }
         {I} { Ī }
         {i} { ī }
-        {O} { \polyglossia_latin_diphthong_macron:NNn OE
+        {O} { \polyglossia_latin_ligature_macron:NNnn OE { \=Π}
                 {
-                  \polyglossia_latin_diphthong_macron:NNn Oe { Ō }
+                  \polyglossia_latin_ligature_macron:NNnn Oe { \=Œ } { Ō }
                 }
             }
-        {o} { \polyglossia_latin_diphthong_macron:NNn oe { ō } }
+        {o} { \polyglossia_latin_ligature_macron:NNnn oe { \=œ } { ō } }
         {U} { Ū }
         {u} { ū }
         {V} { \= V } % V may be a vowel, but lowercase v is never used as a vowel.
@@ -18970,7 +19358,16 @@
         {y} { ȳ }
       }
       {
-        \token_to_str:N =
+        \tl_if_single_token:nTF {#1}
+          {
+            \polyglossia_latin_if_ligature_command:NTF #1 { \= }
+              {
+                \token_to_str:N =
+              }
+          }
+          {
+            \token_to_str:N =
+          }
         #1
       }
   }
@@ -19007,12 +19404,12 @@
     \bbl at allowhyphens
   }
 
-\cs_new:Npn \polyglossia_latin_digraph_shorthand:Nnn #1#2#3
-% #1: second letter of digraph (E or e)
-% #2: digraph character
-% #3: non-digraph code
+\cs_new:Npn \polyglossia_latin_ligature_shorthand:Nnn #1#2#3
+% #1: second letter of ligature (E or e)
+% #2: ligature character
+% #3: non-ligature code
   {
-    \bool_if:NTF \l_polyglossia_latin_use_digraphs_bool
+    \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool
       {
         \peek_meaning_remove:NTF #1 {#2} {#3}
       }
@@ -19021,14 +19418,62 @@
       }
   }
 
+\msg_new:nnn {polyglossia} {latin / no-double-macron-font}
+  {
+    The~combining~double~macron~(U+035E)~is~not~available~in~the~current~
+    font.~The~diphthong~is~typeset~without~macron~ \msg_line_context: .
+  }
+
 \cs_new:Npn \polyglossia_latin_diphthong_macron:NNn #1#2#3
 % #1: first character of diphthong
 % #2: second character of diphthong
 % #3: non-diphthong code
   {
-    \peek_meaning:NTF #2 { #1 \char "35E \relax } {#3} % U+35E: combining double macron
+    \peek_meaning:NTF #2
+      {
+        #1
+        \iffontchar \font "35E \relax % U+35E: combining double macron
+          \char "35E \relax
+        \else
+          \msg_warning:nn {polyglossia} {latin / no-double-macron-font}
+        \fi
+      }
+      {
+        #3
+      }
   }
 
+\cs_new:Npn \polyglossia_latin_ligature_macron:NNnn #1#2#3#4
+% #1: first character of diphthong
+% #2: second character of diphthong
+% #3: ligature code
+% #4: false code
+  {
+    \polyglossia_latin_ligature_shorthand:Nnn #2 {#3}
+      {
+        \polyglossia_latin_diphthong_macron:NNn #1 #2 {#4}
+      }
+  }
+
+% The following conditional tests if the argument is a ligature command (\AE,
+% \ae, \OE, or \oe).
+\prg_new_conditional:Npnn \polyglossia_latin_if_ligature_command:N #1 {TF}
+  {
+    \token_if_eq_meaning:NNTF #1 \AE { \prg_return_true: }
+      {
+        \token_if_eq_meaning:NNTF #1 \ae { \prg_return_true: }
+          {
+            \token_if_eq_meaning:NNTF #1 \OE { \prg_return_true: }
+              {
+                \token_if_eq_meaning:NNTF #1 \oe { \prg_return_true: }
+                  {
+                    \prg_return_false:
+                  }
+              }
+          }
+      }
+  }
+
 \cs_new:Npn \polyglossia_latin_no_shorthands:
   {
     \bbl at deactivate {"}
@@ -19644,8 +20089,8 @@
 
 \def\datemalay at indonesian{%
    \def\today{\number\day~\ifcase\month\or
-    Januari\or Pebruari\or Maret\or April\or Mei\or Juni\or
-    Juli\or Agustus\or September\or Oktober\or Nopember\or Desember\fi
+    Januari\or Februari\or Maret\or April\or Mei\or Juni\or
+    Juli\or Agustus\or September\or Oktober\or November\or Desember\fi
     \space \number\year}}
 
 \def\datemalay at malay{%
@@ -20170,12 +20615,12 @@
 }
 
 \def\blockextras at mongolian{%
-   \ifcyrillic at numerals\mongolian at numbers\fi%
-   \ifmongolian at babelshorthands\mongolian at shorthands\fi%
+   \ifcyrillic at numerals\mongolian at numbers\else\nomongolian at numbers\fi%
+   \ifmongolian at babelshorthands\mongolian at shorthands\else\nomongolian at shorthands\fi%
 }
 
 \def\inlineextras at mongolian{%
-   \ifmongolian at babelshorthands\mongolian at shorthands\fi%
+   \ifmongolian at babelshorthands\mongolian at shorthands\else\nomongolian at shorthands\fi%
 }
 
 %    \end{macrocode}
@@ -20676,12 +21121,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifoccitan at babelshorthands\occitan at shorthands\fi%
+   \ifoccitan at babelshorthands\occitan at shorthands\else\nooccitan at shorthands\fi%
 }
 
 \def\inlineextras at occitan{%
    \lccode\string"2019=\string"2019%
-   \ifoccitan at babelshorthands\occitan at shorthands\fi%
+   \ifoccitan at babelshorthands\occitan at shorthands\else\nooccitan at shorthands\fi%
 }
 %% Distributable under the LaTeX Project Public License,
 %% version 1.3c or higher (your choice). The latest version of
@@ -20958,12 +21403,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifpiedmontese at babelshorthands\piedmontese at shorthands\fi%
+   \ifpiedmontese at babelshorthands\piedmontese at shorthands\else\nopiedmontese at shorthands\fi%
 }
 
 \def\inlineextras at piedmontese{%
    \lccode\string"2019=\string"2019%
-   \ifpiedmontese at babelshorthands\piedmontese at shorthands\fi%
+   \ifpiedmontese at babelshorthands\piedmontese at shorthands\else\nopiedmontese at shorthands\fi%
 }
 %%% CHANGES END %%%
 %    \end{macrocode}
@@ -21082,6 +21527,10 @@
 \setlanguagealias[variant=portuguese]{portuguese}{portuges}
 \setlanguagealias[variant=brazilian]{portuguese}{brazil}
 
+\ifluatex
+  \RequirePackage{luavlna}
+\fi
+
 \def\portuguese at variant{portuges}
 \define at choicekey*+{portuguese}{variant}[\xpg at val\xpg at nr]{portuguese,brazilian}[portuguese]{%
    \ifcase\xpg at nr\relax
@@ -21098,11 +21547,92 @@
    \xpg at info{Option: portuguese, variant=\xpg at val}%
 }{\xpg at warning{Unknown portuguese variant `#1'}}
 
+\define at boolkey{portuguese}[portuguese@]{babelshorthands}[true]{}
 
+\define at boolkey{portuguese}[portuguese@]{splithyphens}[true]{}
+
 % Register default options
-\xpg at initialize@gloss at options{portuguese}{variant=portuguese}
+\xpg at initialize@gloss at options{portuguese}{variant=portuguese,
+      babelshorthands=false,
+      splithyphens=true}
 
+\ifsystem at babelshorthands
+  \setkeys{portuguese}{babelshorthands=true}
+\else
+  \setkeys{portuguese}{babelshorthands=false}
+\fi
 
+\ifcsundef{initiate at active@char}{%
+  \input{babelsh.def}%
+  \initiate at active@char{"}%
+  \shorthandoff{"}%
+}{}
+
+\def\portuguese@@splhyphen#1{%
+  \def\portuguese at sh@tmp{%
+       \if\portuguese at sh@next-#1%
+       \else\expandafter\portuguese@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\portuguese at sh@next\portuguese at sh@tmp%
+}
+
+\def\portuguese@@@splhyphen#1{%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
+}
+
+\def\portuguese at splhyphen{%
+  \portuguese@@splhyphen{-}%
+}
+
+\def\portuguese at shorthands{%
+  \bbl at activate{"}%
+  \def\language at group{portuguese}%
+  \declare at shorthand{portuguese}{"=}{\portuguese at splhyphen}%
+  \declare at shorthand{portuguese}{""}{\hskip\z at skip}%
+  \declare at shorthand{portuguese}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{portuguese}{"-}{\nobreak\-\bbl at allowhyphens}%
+  \declare at shorthand{portuguese}{"|}{%
+      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
+      \bbl at allowhyphens}{}%
+  }%
+  \declare at shorthand{portuguese}{"/}{\textormath
+    {\bbl at allowhyphens\discretionary{/}{}{/}\bbl at allowhyphens}{}}%
+  \declare at shorthand{portuguese}{"<}{«}%
+  \declare at shorthand{portuguese}{">}{»}%
+}
+
+\def\noportuguese at shorthands{%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+}
+
+\ifxetex
+  % splithyphens
+  \newXeTeXintercharclass\portuguese at hyphen % -
+\fi
+
+\def\portuguese at hyphens{%
+    \ifluatex
+      \AfterPreamble{\enablesplithyphens{portuguese}}%
+    \else
+      \XeTeXinterchartokenstate=1
+      \XeTeXcharclass `\- \portuguese at hyphen
+      \XeTeXinterchartoks \z@ \portuguese at hyphen = {\portuguese@@splhyphen}% "-" -> "\portuguese@@splhyphen-"
+    \fi%
+}
+
+\def\noportuguese at hyphens{%
+    \ifluatex
+      \AfterPreamble{\disablesplithyphens{portuguese}}%
+    \else
+      \XeTeXcharclass `\- \z@
+    \fi%
+}
+
 \def\portuguese at language{%
    \polyglossia at setup@language at patterns{\portuguese at variant}%
 }%
@@ -21177,6 +21707,21 @@
 \def\dateportuguese{%
   \csname dateportuguese@\portuguese at variant\endcsname%
 }
+
+\def\noextras at portuguese{%
+  \ifportuguese at babelshorthands\noportuguese at shorthands\fi%
+  \noportuguese at hyphens%
+}
+
+\def\blockextras at portuguese{%
+  \ifportuguese at babelshorthands\portuguese at shorthands\else\noportuguese at shorthands\fi%
+  \ifportuguese at splithyphens\portuguese at hyphens\else\noportuguese at hyphens\fi%
+}
+
+\def\inlineextras at portuguese{%
+  \ifportuguese at babelshorthands\portuguese at shorthands\else\noportuguese at shorthands\fi%
+  \ifportuguese at splithyphens\portuguese at hyphens\else\noportuguese at hyphens\fi%
+}
      
 %    \end{macrocode}
 % \iffalse
@@ -21646,12 +22191,12 @@
 
 \def\blockextras at russian{%
    \russian at capsformat%
-   \ifcyrillic at numerals\russian at numbers\fi%
-   \ifrussian at babelshorthands\russian at shorthands\fi%
+   \ifcyrillic at numerals\russian at numbers\else\norussian at numbers\fi%
+   \ifrussian at babelshorthands\russian at shorthands\else\norussian at shorthands\fi%
 }
 
 \def\inlineextras at russian{%
-   \ifrussian at babelshorthands\russian at shorthands\fi%
+   \ifrussian at babelshorthands\russian at shorthands\else\norussian at shorthands\fi%
 }
 
 %%% These lines taken from russianb.ldf, part of babel package.
@@ -21875,9 +22420,10 @@
 % Register default options
 \xpg at initialize@gloss at options{sanskrit}{script=Devanagari,numerals=Devanagari}
 
+% Use \providecommand here as the ldf file might
+% be reloaded via BCP.
+\providecommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
 
-\newcommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
-
 \def\sanskritnumber#1{%
   \ifsanskrit at devanagari@numerals
     \devanagaridigits{\number#1}%
@@ -21982,7 +22528,8 @@
   langtag=SRB,
   hyphennames={serbian},
   hyphenmins={2,2},
-  indentfirst=true,
+  frenchspacing=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
+  indentfirst=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
   fontsetup=false,
   localnumeral=serbiannumerals,
   Localnumeral=Serbiannumerals,
@@ -21998,6 +22545,10 @@
 % Babel aliases
 \setlanguagealias[script=Cyrillic]{serbian}{serbianc}
 
+\ifluatex
+  \RequirePackage{luavlna}
+\fi
+
 \newif\if at serbian@cyr
 \define at choicekey*+{serbian}{Script}[\xpg at val\xpg at nr]{cyrillic,latin}[cyrillic]{%
    \ifcase\xpg at nr\relax
@@ -22041,10 +22592,12 @@
    \xpg at info{Option: Serbian, numerals=\xpg at val}%
 }{\xpg at warning{Unknown Serbian numerals value `#1'}}
 
+\define at boolkey{serbian}[serbian@]{splithyphens}[true]{}
+
 \setkeys{serbian}{Script,numerals}
 
 % Register default options
-\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic}
+\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic,splithyphens=true}
 
 \def\captionsserbian{%
    \if at serbian@cyr\captionsserbian at cyr\else\captionsserbian at lat\fi
@@ -22125,10 +22678,11 @@
     децембар\fi \space \number\year.}%
 }
 
+% Use \providecommand here as the ldf file might
+% be reloaded via serbianc.
+\providecommand{\serbiannumerals}[2]{\serbiannumber{#2}}
+\providecommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
 
-\newcommand{\serbiannumerals}[2]{\serbiannumber{#2}}
-\newcommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
-
 \def\serbiannumber#1{%
   \ifcyrillic at numerals
     \ifcyrillic at asbuk@numerals
@@ -22172,12 +22726,65 @@
    \let\@Alph\latin at Alph
 }
 
+\def\serbian@@splhyphen#1{%
+  \def\serbian at sh@tmp{%
+       \if\serbian at sh@next-#1%
+       \else\expandafter\serbian@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\serbian at sh@next\serbian at sh@tmp%
+}
+
+\def\serbian@@@splhyphen#1{%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
+}
+
+\def\serbian at splhyphen{%
+  \serbian@@splhyphen{-}%
+}
+
+\ifxetex
+  % splithyphens
+  \newXeTeXintercharclass\serbian at hyphen % -
+  \newXeTeXintercharclass\serbian at nonsyllabicpreposition%
+\fi
+
+\def\serbian at hyphens{%
+    \ifluatex
+      \AfterPreamble{\enablesplithyphens{serbian}}%
+    \else
+      \XeTeXinterchartokenstate=1
+      \XeTeXcharclass `\- \serbian at hyphen
+      \XeTeXinterchartoks \z@ \serbian at hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
+      % necessary if used together with vlna:
+      \XeTeXinterchartoks \serbian at nonsyllabicpreposition \serbian at hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
+    \fi%
+}
+
+\def\noserbian at hyphens{%
+    \ifluatex
+      \AfterPreamble{\disablesplithyphens{serbian}}%
+    \else
+      \XeTeXcharclass `\- \z@
+    \fi%
+}
+
 \def\blockextras at serbian{%
-   \ifcyrillic at numerals\serbian at numbers\fi
+  \ifcyrillic at numerals\serbian at numbers\else\noserbian at numbers\fi%
+  \ifserbian at splithyphens\serbian at hyphens\else\noserbian at hyphens\fi%
 }
+
+\def\inlineextras at serbian{%
+  \ifserbian at splithyphens\serbian at hyphens\else\noserbian at hyphens\fi%
+}
  
 \def\noextras at serbian{%
-   \ifcyrillic at numerals\noserbian at numbers\fi
+   \ifcyrillic at numerals\noserbian at numbers\fi%
+   \noserbian at hyphens%
 }
 
 \def\Asbuk#1{\expandafter\serbian at asbuk@Alph\csname c@#1\endcsname}
@@ -22186,21 +22793,21 @@
 \def\AsbukTrad#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
 \def\asbukTrad#1{\expandafter\cyr at alph\csname c@#1\endcsname}
 
-% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30.
+% This is a poor man's cyrillic alphanumeric.
+% It just uses the alphabet and thus ends at 30.
 \def\serbian at asbuk@Alph#1{\ifcase#1\or
-   А\or Б\or В\or Г\or Д\or Е\or Ж\or
-   З\or И\or К\or Л\or М\or Н\or О\or
-   П\or Р\or С\or Т\or У\or Ф\or Х\or
-   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
+   А\or Б\or В\or Г\or Д\or Ђ\or Е\or Ж\or
+   З\or И\or Ј\or К\or Л\or Љ\or М\or Н\or
+   Њ\or О\or П\or Р\or С\or Т\or Ћ\or У\or
+   Ф\or Х\or Ц\or Ч\or Џ\or Ш%
    \else\xpg at ill@value{#1}{serbian at asbuk@Alph}\fi%
 }
 
 \def\serbian at asbuk@alph#1{\ifcase#1\or
-   а\or б\or в\or г\or д\or е\or ж\or
-   з\or и\or к\or л\or м\or н\or о\or
-   п\or р\or с\or т\or у\or ф\or х\or
-   ц\or ч\or ш\or щ\or э\or ю\or я%
+   а\or б\or в\or г\or д\or ђ\or е\or ж\or
+   з\or и\or ј\or к\or л\or љ\or м\or н\or
+   њ\or о\or п\or р\or с\or т\or ћ\or у\or
+   ф\or х\or ц\or ч\or џ\or ш%
    \else\xpg at ill@value{#1}{serbian at asbuk@alph}\fi%
 }
 
@@ -22268,6 +22875,14 @@
 }{}
 
 \def\slovak@@splhyphen#1{%
+  \def\slovak at sh@tmp{%
+       \if\slovak at sh@next-#1%
+       \else\expandafter\slovak@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\slovak at sh@next\slovak at sh@tmp%
+}
+
+\def\slovak@@@splhyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -22463,13 +23078,13 @@
 }
 
 \def\blockextras at slovak{%
-  \ifslovak at babelshorthands\slovak at shorthands\fi%
+  \ifslovak at babelshorthands\slovak at shorthands\else\noslovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
   \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }
 
 \def\inlineextras at slovak{%
-  \ifslovak at babelshorthands\slovak at shorthands\fi%
+  \ifslovak at babelshorthands\slovak at shorthands\else\noslovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
   \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }
@@ -22933,7 +23548,9 @@
   \let\tgh\relax%
 }
 
-\newcommand*\spanishoperator[2][]{%
+% Use \providecommand here as the ldf file might
+% be reloaded via babel aliases.
+\providecommand*\spanishoperator[2][]{%
   \ifx#1\\\\
     \protected at csxdef{#2}{\mathop{\operator at font #2}\nolimits}%
   \else
@@ -23590,8 +24207,10 @@
 \def\tmp at tibetan{tibetan}
 \define at key{tibetan}{numerals}[tibetan]{%
 	\def\@tmpa{#1}%
-	\ifx\@tmpa\tmp at tibetan\@tibetan at numeralstrue\else
-	  \@tibetan at numeralsfalse\fi
+	\ifx\@tmpa\tmp at tibetan\@tibetan at numeralstrue%
+	\else
+	  \@tibetan at numeralsfalse%
+	\fi%
 }
 
 \ifluatex
@@ -23600,23 +24219,23 @@
 \fi
 
 \def\tibetan at eol{%
-  \ifluatex %
-    \xpg at tibteol=1\relax %
+  \ifluatex%
+    \xpg at tibteol=1\relax%
     \directlua{polyglossia.activate_tibt_eol()}%
-  \else %
+  \else%
     \XeTeXlinebreaklocale "bo"%
     \XeTeXlinebreakskip=0pt plus 0.1em% doesn't do much, but doesn't harm I guess...
-  \fi %
+  \fi%
 }
 
 \def\notibetan at eol{%
-  \ifluatex %
-    \xpg at tibteol=0\relax %
+  \ifluatex%
+    \xpg at tibteol=0\relax%
     %\directlua{polyglossia.activate_tibt_eol()}%
-  \else %
+  \else%
     \XeTeXlinebreaklocale "en"% en? really?
     \XeTeXlinebreakskip=0pt plus 0pt%
-  \fi %
+  \fi%
 }
 
 % Register default options
@@ -23649,6 +24268,7 @@
    \def\proofname{བདེན་དཔང་།}% not sure about this one...
    \def\glossaryname{མིང་ཚིག་རེའུ་མིག།}%
 }
+
 \def\datetibetan{%   
    \def\tibetan at month{%
      \ifcase\month\or
@@ -23673,6 +24293,7 @@
 }
 
 \def\tibetandigits#1{\expandafter\@tibetan at digits #1@}
+
 \def\@tibetan at digits#1{%
   \ifx @#1% then terminate
   \else
@@ -23691,14 +24312,28 @@
   \fi}
 
 \def\@tibetanalph#1{%
-  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
-  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
- \else\xpg at ill@value{#1}{@tibetanalph}\fi}
-\def\tibetanAlph#1{\expandafter\@tibetanAlph\csname c@#1\endcsname}
+    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or
+           ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or
+           བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or
+           འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
+    \else%
+        \xpg at ill@value{#1}{@tibetanalph}%
+    \fi%
+}
+ 
+\def\tibetanAlph#1{%
+    \expandafter\@tibetanAlph\csname c@#1\endcsname%
+}
+
 \def\@tibetanAlph#1{%
-  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
-  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
- \else\xpg at ill@value{#1}{@tibetanalph}\fi}
+    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or
+          ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or བ\or མ\or ཙ\or
+           ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or
+            ས\or ཧ\or ཨ%
+    \else%
+       \xpg at ill@value{#1}{@tibetanalph}%
+    \fi%
+}
 
 \newcommand{\tibetanumerals}[2]{\tibetannumber{#2}}
 
@@ -23708,13 +24343,16 @@
      \let\@Alph\@tibetanAlph%
    \fi
 }
+
 \def\notibetan at numbers{%
   \let\@alph\latin at alph%
   \let\@Alph\latin at Alph%
 }
 
+% Store original definition
+\let\xpg at orig@arabic\@arabic
+
 \def\tibetan at globalnumbers{%
-   \let\xpg at orig@arabic\@arabic%
    \let\@arabic\tibetannumber%
    \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
 }
@@ -23725,17 +24363,31 @@
 
 \def\noextras at tibetan{%
    \notibetan at eol%
-   \ifcsname xpg at orig@baselinestretch\endcsname\renewcommand{\baselinestretch}{\xpg at orig@baselinestretch}\fi %
-   }
+   \ifcsname xpg at orig@baselinestretch\endcsname%
+       \renewcommand{\baselinestretch}{\xpg at orig@baselinestretch}%
+   \fi%
+}
 
 \def\inlineextras at tibetan{%
-   \xdef\xpg at orig@baselinestretch{\ifcsname baselinestretch\endcsname \baselinestretch \else 1\fi}%
+   \xdef\xpg at orig@baselinestretch{%
+       \ifcsname baselinestretch\endcsname
+           \baselinestretch
+        \else
+           1%
+        \fi%
+   }%
    \renewcommand{\baselinestretch}{1.2}%
    \tibetan at eol%
-   }
+}
 
 \def\blockextras at tibetan{%
-   \xdef\xpg at orig@baselinestretch{\ifcsname baselinestretch\endcsname \baselinestretch \else 1\fi}%
+   \xdef\xpg at orig@baselinestretch{%
+        \ifcsname baselinestretch\endcsname
+            \baselinestretch
+        \else
+           1%
+        \fi%
+   }%
    \renewcommand{\baselinestretch}{1.2}%
    \tibetan at eol%
 }
@@ -24134,8 +24786,8 @@
 \let\ukrainiannumeral=\ukrainiannumber
 \let\Ukrainiannumeral=\Ukrainiannumber
 
-\def\Asbuk#1{\expandafter\ukranian at asbuk@Alph\csname c@#1\endcsname}
-\def\asbuk#1{\expandafter\ukranian at asbuk@alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\ukrainian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\ukrainian at asbuk@alph\csname c@#1\endcsname}
 
 \def\AsbukTrad#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
 \def\asbukTrad#1{\expandafter\cyr at alph\csname c@#1\endcsname}
@@ -24180,12 +24832,12 @@
 
 \def\blockextras at ukrainian{%
   \ukrainian at capsformat%
-  \ifcyrillic at numerals\ukrainian at numbers\fi%
-  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifcyrillic at numerals\ukrainian at numbers\else\noukrainian at numbers\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\else\noukrainian at shorthands\fi%
 }
 
 \def\inlineextras at ukrainian{%
-  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\else\noukrainian at shorthands\fi%
 }
 
 %%% stuff from Babel

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -83,11 +83,11 @@
 }
 
 \def\blockextras at afrikaans{%
-  \ifafrikaans at babelshorthands\afrikaans at shorthands\fi%
+  \ifafrikaans at babelshorthands\afrikaans at shorthands\else\noafrikaans at shorthands\fi%
 }
 
 \def\inlineextras at afrikaans{%
-  \ifafrikaans at babelshorthands\afrikaans at shorthands\fi%
+  \ifafrikaans at babelshorthands\afrikaans at shorthands\else\noafrikaans at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -156,9 +156,10 @@
     \fi%
  \fi}}
 
+% Use \providecommand here as the ldf file might
+% be reloaded via aeb (BCP).
+\providecommand{\arabicnumerals}[2]{\arabicnumber{#2}}
 
-\newcommand{\arabicnumerals}[2]{\arabicnumber{#2}}
-
 \def\arabicnumber#1{%
   \ifeastern at numerals
     \@ensure at dir{\arabicdigits{\number#1}}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -224,8 +224,10 @@
   \csuse{datebelarusian@\belarusian at spelling}%
 }
 
-\newcommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
-\newcommand{\Belarusiannumerals}[2]{\Belarusiannumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via be-tarask (BCP).
+\providecommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
+\providecommand{\Belarusiannumerals}[2]{\Belarusiannumber{#2}}
 
 \def\belarusiannumber#1{%
   \ifcyrillic at numerals
@@ -301,12 +303,12 @@
 }
 
 \def\blockextras at belarusian{%
-   \ifcyrillic at numerals\belarusian at numbers\fi%
-   \ifbelarusian at babelshorthands\belarusian at shorthands\fi%
+   \ifcyrillic at numerals\belarusian at numbers\else\nobelarusian at numbers\fi%
+   \ifbelarusian at babelshorthands\belarusian at shorthands\else\nobelarusian at shorthands\fi%
 }
 
 \def\inlineextras at belarusian{%
-   \ifbelarusian at babelshorthands\belarusian at shorthands\fi%
+   \ifbelarusian at babelshorthands\belarusian at shorthands\else\nobelarusian at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -44,7 +44,7 @@
   \def\today{\number\day.~\ifcase\month\or
     januar\or februar\or mart\or april\or maj\or
     juni\or juli\or august\or septembar\or oktobar\or novembar\or
-    decembar\fi \space \number\year.~}%
+    decembar\fi \space \number\year.}%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -148,10 +148,10 @@
 }
 
 \def\blockextras at catalan{%
-   \ifcatalan at babelshorthands\catalan at shorthands\fi%
+   \ifcatalan at babelshorthands\catalan at shorthands\else\nocatalan at shorthands\fi%
 }
 
 \def\inlineextras at catalan{%
-   \ifcatalan at babelshorthands\catalan at shorthands\fi%
+   \ifcatalan at babelshorthands\catalan at shorthands\else\nocatalan at shorthands\fi%
 }
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -18,14 +18,25 @@
 
 \define at boolkey{croatian}[croatian@]{babelshorthands}[true]{}
 
-\define at boolkey{croatian}[croatian@]{disableligatures}[true]{}
+\define at boolkey{croatian}[croatian@]{disabledigraphs}[true]{}
 
+% Alias kept for backwards compatibility. Please do not remove
+\define at boolkey{croatian}[croatian@]{disableligatures}[true]{%
+   \xpg at warning{The option disableligatures is deprected.\MessageBreak
+                Please use disabledigraphs instead}%
+   \ifcroatian at disableligatures
+      \croatian at disabledigraphstrue
+   \else
+      \croatian at disabledigraphsfalse
+   \fi
+}
+
 \define at boolkey{croatian}[croatian@]{splithyphens}[true]{}
 
 \define at boolkey{croatian}[croatian@]{localalph}[true]{}
 
 % Register default options
-\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disableligatures=false,
+\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disabledigraphs=false,
                                         splithyphens=true,localalph=true}
 
 \ifsystem at babelshorthands
@@ -41,6 +52,14 @@
 }{}
 
 \def\croatian@@splhyphen#1{%
+  \def\croatian at sh@tmp{%
+       \if\croatian at sh@next-#1%
+       \else\expandafter\croatian@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\croatian at sh@next\croatian at sh@tmp%
+}
+
+\def\croatian@@@splhyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -70,12 +89,12 @@
   \declare at shorthand{croatian}{"'}{”}%
   \declare at shorthand{croatian}{"<}{«}%
   \declare at shorthand{croatian}{">}{»}%
-  \declare at shorthand{croatian}{"D}{\xpg at hr@lig{D}}%
-  \declare at shorthand{croatian}{"d}{\xpg at hr@lig{d}}%
-  \declare at shorthand{croatian}{"L}{\xpg at hr@lig{L}}%
-  \declare at shorthand{croatian}{"l}{\xpg at hr@lig{l}}%
-  \declare at shorthand{croatian}{"N}{\xpg at hr@lig{N}}%
-  \declare at shorthand{croatian}{"n}{\xpg at hr@lig{n}}%
+  \declare at shorthand{croatian}{"D}{\xpg at hr@digraph{D}}%
+  \declare at shorthand{croatian}{"d}{\xpg at hr@digraph{d}}%
+  \declare at shorthand{croatian}{"L}{\xpg at hr@digraph{L}}%
+  \declare at shorthand{croatian}{"l}{\xpg at hr@digraph{l}}%
+  \declare at shorthand{croatian}{"N}{\xpg at hr@digraph{N}}%
+  \declare at shorthand{croatian}{"n}{\xpg at hr@digraph{n}}%
 }
 
 \def\nocroatian at shorthands{%
@@ -108,24 +127,24 @@
     \fi%
 }
 
-\newcommand*\hr at charifavailable[2]{%
-   \ifcroatian at disableligatures
-     \bgroup#2\egroup%
-   \else
-     \charifavailable{#1}{#2}%
+\newcommand*\hr at charifavailable[3]{%
+   \ifcroatian at disabledigraphs% no notion of digraphs at all
+     \bgroup#3\egroup%
+   \else% digraph...
+     \charifavailable{#1}{#2}% ... either a Unicode original or a mimic of one
    \fi%
 }
 
-% Provide croatian ligatures if available in current font
-\def\xpg at hr@lig#1#2{%
+% Provide croatian digraphs if available in current font
+\def\xpg at hr@digraph#1#2{%
  \bgroup%
   % 1. DŽ, Dž and dž
   \ifx#1D%
     \ifx#2Z\relax%
-       \hr at charifavailable{01C4}{DŽ}%
+       \hr at charifavailable{01C4}{D\nobreak Ž}{DŽ}%
     \else%
        \ifx#2z\relax
-          \hr at charifavailable{01C5}{Dž}%
+          \hr at charifavailable{01C5}{D\nobreak ž}{Dž}%
        \else
            D#2%
        \fi%
@@ -133,7 +152,7 @@
   \fi%
   \ifx#1d%
     \ifx#2z\relax
-       \hr at charifavailable{01C6}{dž}%
+       \hr at charifavailable{01C6}{d\nobreak ž}{dž}%
     \else
        d#2%
     \fi%
@@ -141,10 +160,10 @@
   % 2. LJ, Lj and lj
   \ifx#1L%
     \ifx#2J\relax%
-       \hr at charifavailable{01C7}{LJ}%
+       \hr at charifavailable{01C7}{L\nobreak J}{LJ}%
     \else%
        \ifx#2j\relax
-          \hr at charifavailable{01C8}{Lj}%
+          \hr at charifavailable{01C8}{L\nobreak j}{Lj}%
        \else
            L#2%
        \fi%
@@ -152,7 +171,7 @@
   \fi%
   \ifx#1l%
     \ifx#2j\relax
-       \hr at charifavailable{01C9}{lj}%
+       \hr at charifavailable{01C9}{l\nobreak j}{lj}%
     \else
        l#2%
     \fi%
@@ -160,10 +179,10 @@
   % 2. NJ, Nj and nj
   \ifx#1N%
     \ifx#2J\relax%
-       \hr at charifavailable{01CA}{NJ}%
+       \hr at charifavailable{01CA}{N\nobreak J}{NJ}%
     \else%
        \ifx#2j\relax
-          \hr at charifavailable{01CB}{Nj}%
+          \hr at charifavailable{01CB}{N\nobreak j}{Nj}%
        \else
            N#2%
        \fi%
@@ -171,7 +190,7 @@
   \fi%
   \ifx#1n%
     \ifx#2j\relax
-       \hr at charifavailable{01CC}{nj}%
+       \hr at charifavailable{01CC}{n\nobreak j}{nj}%
     \else
        n#2%
     \fi%
@@ -184,7 +203,7 @@
   \def\refname{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
-  \def\chaptername{Poglav\hr at charifavailable{01C9}{lj}e}%
+  \def\chaptername{Poglav\xpg at hr@digraph{l}{j}e}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Popis slika}%
@@ -205,9 +224,9 @@
 
 \def\datecroatian{%
   \def\today{\number\day.~\ifcase\month\or
-    siječ\hr at charifavailable{01CC}{nj}a\or ve\hr at charifavailable{01C9}{lj}ače\or
-    ožujka\or trav\hr at charifavailable{01CC}{nj}a\or svib\hr at charifavailable{01CC}{nj}a\or
-    lip\hr at charifavailable{01CC}{nj}a\or srp\hr at charifavailable{01CC}{nj}a\or
+    siječ\xpg at hr@digraph{n}{j}a\or ve\xpg at hr@digraph{l}{j}ače\or
+    ožujka\or trav\xpg at hr@digraph{n}{j}a\or svib\xpg at hr@digraph{n}{j}a\or
+    lip\xpg at hr@digraph{n}{j}a\or srp\xpg at hr@digraph{n}{j}a\or
     kolovoza\or rujna\or listopada\or studenoga\or prosinca\fi \space \number\year.}%
 }
 
@@ -230,13 +249,13 @@
 }
 
 \def\blockextras at croatian{%
-  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+  \ifcroatian at babelshorthands\croatian at shorthands\else\nocroatian at shorthands\fi%
   \ifcroatian at splithyphens\croatian at hyphens\else\nocroatian at hyphens\fi%
   \ifcroatian at localalph\let\alph\croatian at alph\let\Alph\croatian at Alph\fi%
 }
 
 \def\inlineextras at croatian{%
-  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+  \ifcroatian at babelshorthands\croatian at shorthands\else\nocroatian at shorthands\fi%
   \ifcroatian at splithyphens\croatian at hyphens\else\nocroatian at hyphens\fi%
   \ifcroatian at localalph\let\alph\croatian at alph\let\Alph\croatian at Alph\fi%
 }

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -37,7 +37,15 @@
   \shorthandoff{"}%
 }{}
 
-\def\cs@@splithyphen#1{%
+\def\czech@@splithyphen#1{%
+  \def\czech at sh@tmp{%
+       \if\czech at sh@next-#1%
+       \else\expandafter\czech@@@splithyphen{#1}\fi%
+     }%
+     \futurelet\czech at sh@next\czech at sh@tmp%
+}
+
+\def\czech@@@splithyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -46,14 +54,14 @@
   \fi%
 }
 
-\def\cs at splithyphen{%
-  \cs@@splithyphen{-}%
+\def\czech at splithyphen{%
+  \czech@@splithyphen{-}%
 }
 
 \def\czech at shorthands{%
   \bbl at activate{"}%
   \def\language at group{czech}%
-  \declare at shorthand{czech}{"=}{\cs at splithyphen}%
+  \declare at shorthand{czech}{"=}{\czech at splithyphen}%
   \declare at shorthand{czech}{"`}{„}%
   \declare at shorthand{czech}{"'}{“}%
   \declare at shorthand{czech}{"<}{«}%
@@ -90,9 +98,9 @@
     \else
       \XeTeXinterchartokenstate=1
       \XeTeXcharclass `\- \czech at hyphen
-      \XeTeXinterchartoks \z@ \czech at hyphen = {\cs@@splithyphen}% "-" -> "\cs@@splithyphen-"
+      \XeTeXinterchartoks \z@ \czech at hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
       % necessary if used together with vlna:
-      \XeTeXinterchartoks \czech at nonsyllabicpreposition \czech at hyphen = {\cs@@splithyphen}% "-" -> "\cs@@splithyphen-"
+      \XeTeXinterchartoks \czech at nonsyllabicpreposition \czech at hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
     \fi%
 }
 
@@ -224,13 +232,13 @@
 }
 
 \def\blockextras at czech{%
-  \ifczech at babelshorthands\czech at shorthands\fi%
+  \ifczech at babelshorthands\czech at shorthands\else\noczech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
   \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }
 
 \def\inlineextras at czech{%
-  \ifczech at babelshorthands\czech at shorthands\fi%
+  \ifczech at babelshorthands\czech at shorthands\else\noczech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
   \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -83,11 +83,11 @@
 }
 
 \def\blockextras at dutch{%
-  \ifdutch at babelshorthands\dutch at shorthands\fi%
+  \ifdutch at babelshorthands\dutch at shorthands\else\nodutch at shorthands\fi%
 }
 
 \def\inlineextras at dutch{%
-  \ifdutch at babelshorthands\dutch at shorthands\fi%
+  \ifdutch at babelshorthands\dutch at shorthands\else\nodutch at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -9,19 +9,20 @@
 }
 
 % BCP-47 compliant aliases
-\setlanguagealias*{english}{en}
-\setlanguagealias*[variant=australian]{english}{en-AU}
-\setlanguagealias*[variant=newzealand]{english}{en-NZ}
-\setlanguagealias*[variant=us]{english}{en-US}
-\setlanguagealias*[variant=british]{english}{en-GB}
-\setlanguagealias*[variant=canadian]{english}{en-CA}
+\setlanguagealias*[bcp47=en]{english}{en}
+\setlanguagealias*[variant=australian,babelname=autralian,bcp47=en-AU]{en}{en-AU}
+\setlanguagealias*[variant=canadian,babelname=canadian,bcp47=en-CA]{en}{en-CA}
+\setlanguagealias*[variant=british,babelname=british,bcp47=en-NZ]{en}{en-GB}
+\setlanguagealias*[variant=newzealand,babelname=newzealand,bcp47=en-NZ]{en}{en-NZ}
+\setlanguagealias*[variant=us,babelname=american,bcp47=en-US]{en}{en-US}
 
+
 % Babel aliases
-\setlanguagealias[variant=us]{english}{american}
-\setlanguagealias[variant=australian]{english}{australian}
-\setlanguagealias[variant=british]{english}{british}
-\setlanguagealias[variant=canadian]{english}{canadian}
-\setlanguagealias[variant=newzealand]{english}{newzealand}
+\setlanguagealias[variant=us]{en-US}{american}
+\setlanguagealias[variant=australian]{en-AU}{australian}
+\setlanguagealias[variant=british]{en-GB}{british}
+\setlanguagealias[variant=canadian]{en-CA}{canadian}
+\setlanguagealias[variant=newzealand]{en-NZ}{newzealand}
 
 \providebool{british at hyphen}
 \providebool{english at ordinalmonthday}
@@ -169,6 +170,7 @@
    \def\alsoname{see also}%
    \def\proofname{Proof}%
 }
+
 \def\dateenglish{%
    \def\english at day{%
      \ifenglish at ordinalmonthday

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -13,8 +13,10 @@
 
 \define at boolkey{finnish}[finnish@]{babelshorthands}[true]{}
 
+\define at boolkey{finnish}[finnish@]{schoolhyphens}[true]{}
+
 % Register default options
-\xpg at initialize@gloss at options{finnish}{babelshorthands=false}
+\xpg at initialize@gloss at options{finnish}{babelshorthands=false,schoolhyphens=false}
 
 \ifsystem at babelshorthands
   \setkeys{finnish}{babelshorthands=true}
@@ -68,6 +70,21 @@
    \def\proofname{Todistus}%
    \def\glossaryname{Sanasto}%
 }
+
+\def\finnish at language{%
+  \iffinnish at schoolhyphens
+      \xpg at ifdefined{schoolfinnish}{%
+         \polyglossia at setup@language at patterns{schoolfinnish}%
+      }{%
+           \xpg at warning{Finnish 'School' hyphenation patterns (schoolfinnish) not available.\MessageBreak
+	                I will use the standard patterns for Finnish instead}%
+	   \polyglossia at setup@language at patterns{finnish}%
+     }%
+  \else
+      \polyglossia at setup@language at patterns{finnish}%
+  \fi
+}
+
 \def\datefinnish{%
    \def\today{\number\day.~\ifcase\month\or
     tammikuuta\or helmikuuta\or maaliskuuta\or huhtikuuta\or
@@ -80,11 +97,11 @@
 }
 
 \def\blockextras at finnish{%
-  \iffinnish at babelshorthands\finnish at shorthands\fi%
+  \iffinnish at babelshorthands\finnish at shorthands\else\nofinnish at shorthands\fi%
 }
 
 \def\inlineextras at finnish{%
-  \iffinnish at babelshorthands\finnish at shorthands\fi%
+  \iffinnish at babelshorthands\finnish at shorthands\else\nofinnish at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -221,12 +221,12 @@
 }
 
 \def\blockextras at georgian{%
-   \ifgeorgian at numerals\georgian at numbers\fi%
-   \ifgeorgian at babelshorthands\georgian at shorthands\fi%
+   \ifgeorgian at numerals\georgian at numbers\else\nogeorgian at numbers\fi%
+   \ifgeorgian at babelshorthands\georgian at shorthands\else\nogeorgian at shorthands\fi%
 }
 
 \def\inlineextras at georgian{%
-   \ifgeorgian at babelshorthands\georgian at shorthands\fi%
+   \ifgeorgian at babelshorthands\georgian at shorthands\else\nogeorgian at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -149,7 +149,7 @@
    \xpg at info{Option: German, script=\xpg at val}%
 }{\xpg at warning{Unknown German script `#1'}}
 
-% Option defunc'ed, as bot XeTeX and LuaTeX meanwhile
+% Option defunc'ed, as both XeTeX and LuaTeX meanwhile
 % use the experimental German hyphenation patterns by default.
 \define at boolkey{german}[german@]{latesthyphen}[true]{}
 
@@ -158,7 +158,7 @@
 \setkeys{german}{spelling,script,variant}
 
 % Register default options
-\xpg at initialize@gloss at options{german}{variant=german,spelling=new,script=latin,latesthyphen=false,babelshorthands=false}
+\xpg at initialize@gloss at options{german}{variant=german,spelling=new,script=latin,babelshorthands=false}
 % Register alias options
 \xpg at set@alias at values{german}{spelling}{new}{1996}
 \xpg at set@alias at values{german}{spelling}{old}{1901}
@@ -314,11 +314,11 @@
 }
 
 \def\blockextras at german{%
-  \ifgerman at babelshorthands\german at shorthands\fi%
+  \ifgerman at babelshorthands\german at shorthands\else\nogerman at shorthands\fi%
 }
 
 \def\inlineextras at german{%
-  \ifgerman at babelshorthands\german at shorthands\fi%
+  \ifgerman at babelshorthands\german at shorthands\else\nogerman at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -252,8 +252,10 @@
    \renewrobustcmd\anw at print{ʹ}}
 \anw at true
 
-\newcommand{\greeknumerals}[2]{\greeknumber{#2}}
-\newcommand{\Greeknumerals}[2]{\Greeknumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via politunikogreek.
+\providecommand{\greeknumerals}[2]{\greeknumber{#2}}
+\providecommand{\Greeknumerals}[2]{\Greeknumber{#2}}
 
 \protected\def\greeknumber#1{\expandafter\@greeknumber\expandafter{\number#1}}
 \def\@greeknumber#1{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -129,12 +129,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifitalian at babelshorthands\italian at shorthands\fi%
+   \ifitalian at babelshorthands\italian at shorthands\else\noitalian at shorthands\fi%
 }
 
 \def\inlineextras at italian{%
    \lccode\string"2019=\string"2019%
-   \ifitalian at babelshorthands\italian at shorthands\fi%
+   \ifitalian at babelshorthands\italian at shorthands\else\noitalian at shorthands\fi%
 }
 %%% CHANGES END %%%
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -109,16 +109,25 @@
   % change chapter and part headings
   \if at korean@swapheadings
     % With titlesec
-    \ifdefined\titleformat
-      \ifdefined\@part
-        \let\xpg at save@part at format\@part
-        \patchcmd{\@part}%
+    \ifcsdef{titleformat}{%
+      \ifcsdef{H at old@part}{% Hyperref
+        \let\xpg at save@part at format\H at old@part
+        \patchcmd{\H at old@part}%
                  {\partname\nobreakspace\thepart}%
                  {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                  {}%
                  {\xpg at warning{Failed to patch part for Korean}}%
-      \fi
-      \ifdefined\chapter
+      }{% not hyperref
+        \ifcsdef{@part}{%
+            \let\xpg at save@part at format\@part
+            \patchcmd{\@part}%
+                     {\partname\nobreakspace\thepart}%
+                     {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                     {}%
+                     {\xpg at warning{Failed to patch part for Korean}}%
+        }{}%
+      }
+      \ifcsdef{chapter}{%
         \titleformat\chapter[display]%
           {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
           {%
@@ -128,15 +137,15 @@
               \koreanTHEname\space \thechapter\space \@chapapp
             \fi
           }{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
-      \fi
-    \else % (not \ifdefined\titleformat)
+      }{}%
+    }{% (not \ifdefined\titleformat)
       % With KOMA
-      \ifdefined\sectionformat
-        \ifdefined\partformat
+      \ifcsdef{sectionformat}{%
+        \ifcsdef{partformat}{%
           \let\xpg at save@part at format\partformat
           \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
-        \fi
-        \ifdefined\chapterformat
+        }{}%
+        \ifcsdef{chapterformat}{%
           \let\xpg at save@chap at format\chapterformat
           \renewcommand*{\chapterformat}{\mbox{%
             \IfChapterUsesPrefixLine
@@ -149,11 +158,11 @@
             }%
             {\thechapter\autodot\enskip}%
           }}%
-        \fi
-      \else % (not \ifdefined\sectionformat)
+        }{}%
+      }{% (not \ifdefined\sectionformat)
         % With memoir
-        \ifdefined\@memptsize
-          \ifdefined\@makechapterhead
+        \ifcsdef{@memptsize}{%
+          \ifcsdef{@makechapterhead}{%
             \let\xpg at save@chap at format\@makechapterhead
             \patchcmd{\@makechapterhead}%
                      {\printchaptername \chapternamenum \printchapternum}%
@@ -171,10 +180,10 @@
                 \ifpatchable\printchaptername\@chapapp
                   {\chapnamefont\koreanTHEname\chapternamenum}{}}%
             \fi
-          \fi
-          \ifdefined\@part
-            \let\xpg at save@part at format\@part
-            \patchcmd{\@part}%
+          }{}%
+          \ifcsdef{H at old@part}{% Hyperref
+            \let\xpg at save@part at format\H at old@part
+            \patchcmd{\H at old@part}%
                      {\printpartname \partnamenum \printpartnum}%
                      {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
                      {}%
@@ -182,10 +191,22 @@
             \ifdefined\printkoreanpartthe\else
               \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
             \fi
-          \fi
-        \else % (not \ifdefined\@memptsize)
+          }{% not hyperref
+            \ifcsdef{@part}{%
+              \let\xpg at save@part at format\@part
+              \patchcmd{\@part}%
+                       {\printpartname \partnamenum \printpartnum}%
+                       {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
+                       {}%
+                       {\xpg at warning{Failed to patch part for Korean}}%
+              \ifdefined\printkoreanpartthe\else
+                \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
+              \fi
+            }{}%
+          }%
+        }{% (not \ifdefined\@memptsize)
           % With standard classes
-          \ifdefined\@makechapterhead
+          \ifcsdef{@makechapterhead}{%
             \let\xpg at save@chap at format\@makechapterhead
             \patchcmd{\@makechapterhead}%
                      {\@chapapp\space \thechapter}%
@@ -198,23 +219,35 @@
                      }%
                      {}%
                      {\xpg at warning{Failed to patch chapter for Korean}}%
-          \fi
-          \ifdefined\@part
-            \let\xpg at save@part at format\@part
-            \patchcmd{\@part}%
+          }{}%
+          \ifcsdef{H at old@part}{% Hyperref
+            \let\xpg at save@part at format\H at old@part
+            \patchcmd{\H at old@part}%
                      {\partname\nobreakspace\thepart}%
                      {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                      {}%
                      {\xpg at warning{Failed to patch part for Korean}}%
-          \fi % (end \ifdefined\@part)
-        \fi % (end \ifdefined\@memptsize)
-      \fi % (end \ifdefined\sectionformat)
-    \fi % (end \ifdefined\titleformat)
+          }{% not hyperref
+            \ifcsdef{@part}{%
+              \ifpatchable{\@part}%
+                   {\partname\nobreakspace\thepart}%
+                   {\let\xpg at save@part at format\@part
+                    \patchcmd{\@part}%
+                             {\partname\nobreakspace\thepart}%
+                             {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                             {}%
+                             {\ifcsdef{part}{\xpg at warning{Failed to patch part for Korean}}{}}}%
+                   {}%
+            }{}%  (end \ifdefined\@part)
+          }% (end not hyperref)
+        }% (end \ifdefined\@memptsize)
+      }% (end \ifdefined\sectionformat)
+    }% (end \ifdefined\titleformat)
   \fi % (end \if at korean@swapheadings)
   %
   % Change running headers
   \if at korean@swapheaders
-    \ifdefined\chapterformat
+    \ifcsdef{chapterformat}{%
       % With KOMA
       \let\xpg at save@chaptermark at format\chaptermarkformat
       \renewcommand*\chaptermarkformat{%
@@ -229,8 +262,8 @@
         {\thechapter\autodot}%
         \enskip
       }%
-    \else % (not \ifdefined\chapterformat)
-      \ifdefined\@memptsize
+    }{% (not \ifdefined\chapterformat)
+      \ifcsdef{@memptsize}{%
         % With memoir
         \let\xpg at save@chaptermark at format\chaptermark
         \patchcmd{\chaptermark}%
@@ -243,74 +276,85 @@
                    \fi
                  }%
                  {}%
-                 {}%
-      \else % (not \ifdefined\@memptsize)
+                 {\xpg at warning{Failed to patch chaptermark for Korean}}%
+      }{% (not \ifdefined\@memptsize)
         % With standard classes
-        \ifdefined\chaptermark
-          \let\xpg at save@chaptermark at format\chaptermark
-          \patchcmd{\chaptermark}%
-                   {\@chapapp\ \thechapter}%
-                   {%
-                     \ifx\@chapapp\korean at appendix@chapapp
-                       \appendixname\ \thechapter
-                     \else
-                       \koreanTHEname\ \thechapter\ \@chapapp
-                     \fi
-                   }%
-                   {}%
-                   {}%
-        \fi % (end \ifdefined\chaptermark)
-      \fi % (end \ifdefined\@memptsize)
-    \fi % (end \ifdefined\chapterformat)
+        \ifcsdef{chaptermark}{%
+          \ifpatchable{\chaptermark}%
+               {\@chapapp\ \thechapter}%
+               {\let\xpg at save@chaptermark at format\chaptermark
+                \patchcmd{\chaptermark}%
+                         {\@chapapp\ \thechapter}%
+                         {%
+                           \ifx\@chapapp\korean at appendix@chapapp
+                             \appendixname\ \thechapter
+                           \else
+                             \koreanTHEname\ \thechapter\ \@chapapp
+                           \fi
+                         }%
+                         {}%
+                         {\xpg at warning{Failed to patch chaptermark for Korean}}}%
+               {}%
+        }{}% (end \ifdefined\chaptermark)
+      }% (end \ifdefined\@memptsize)
+    }% (end \ifdefined\chapterformat)
   \fi % (end \if at korean@swapheaders)
 }
 
 \def\nokorean at headingsformat{%
   % Reset chapter and part heading
-  \ifdefined\titleformat
+  \ifcsdef{titleformat}{%
     % With titlesec
-    \ifdefined\xpg at save@part at format
-      \let\@part\xpg at save@part at format
-    \fi
-    \ifdefined\chapter
+    \ifcsdef{xpg at save@part at format}{%
+      \ifcsdef{H at old@part}{%
+        \let\H at old@part\xpg at save@part at format
+      }{%
+        \let\@part\xpg at save@part at format
+      }%
+    }{}%
+    \ifcsdef{chapter}{%
       \titleformat\chapter[display]%
         {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
         {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
-    \fi
-  \else % (not \ifdefined\titleformat)
-    \ifdefined\sectionformat
+    }{}%
+  }{% (not \ifdefined\titleformat)
+    \ifcsdef{sectionformat}{%
       % With KOMA
-      \ifdefined\xpg at save@part at format
+      \ifcsdef{xpg at save@part at format}{%
         \let\partformat\xpg at save@part at format
-      \fi
-      \ifdefined\xpg at save@chap at format
+      }{}%
+      \ifcsdef{xpg at save@chap at format}{%
         \let\chapterformat\xpg at save@chap at format
-      \fi
-    \else
+      }{}%
+    }{%
       % With memoir and standard classes
-      \ifdefined\xpg at save@part at format
-        \let\@part\xpg at save@part at format
-      \fi
-      \ifdefined\xpg at save@chap at format
+      \ifcsdef{xpg at save@part at format}{%
+        \ifcsdef{H at old@part}{%
+          \let\H at old@part\xpg at save@part at format
+        }{%
+          \let\@part\xpg at save@part at format
+        }%
+      }{}%
+      \ifcsdef{xpg at save@chap at format}{%
         \let\@makechapterhead\xpg at save@chap at format
-      \fi
-    \fi % (end \ifdefined\sectionformat)
-  \fi % (end \ifdefined\titleformat)
+      }{}%
+    }% (end \ifdefined\sectionformat)
+  }% (end \ifdefined\titleformat)
   %
   % Reset headers
-  \ifdefined\chaptermarkformat
+  \ifcsdef{chaptermarkformat}{%
     % With KOMA
-    \ifdefined\xpg at save@chaptermark at format
+    \ifcsdef{xpg at save@chaptermark at format}{%
       \let\chaptermarkformat\xpg at save@chaptermark at format
-    \fi
-  \else
-    \ifdefined\chaptermark
+    }{}%
+  }{%
+    \ifcsdef{chaptermark}{%
       % With memoir and standard classes
-      \ifdefined\xpg at save@chaptermark at format
+      \ifcsdef{xpg at save@chaptermark at format}{%
         \let\chaptermark\xpg at save@chaptermark at format
-      \fi
-    \fi % (end \ifdefined\chaptermark)
-  \fi % (end \ifdefined\chapterformat)
+      }{}%
+    }{}% (end \ifdefined\chaptermark)
+  }% (end \ifdefined\chapterformat)
 }
 
 \def\datekorean{%
@@ -519,6 +563,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XeTeXcharclassID{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOquarterquarter
@@ -530,6 +575,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassAA{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOquarterquarter
@@ -540,16 +586,16 @@
 % macros for interchartoks (CJK punctuations)
 \def\XPGKOstartOP#1{\leavevmode
     \hbox to.5em\bgroup\hss\XeTeXinterchartokenstate\z@ #1\egroup
-    \kern-1sp \kern1sp }
+    \kern-6sp \kern6sp }
 \def\XPGKOstartCL#1{\leavevmode
     \hbox to.5em\bgroup\XeTeXinterchartokenstate\z@ #1\hss\egroup
-    \kern-2sp \kern2sp }
+    \kern-7sp \kern7sp }
 \def\XPGKOstartMD#1{\leavevmode
     \hbox to.5em\bgroup\hss\XeTeXinterchartokenstate\z@ #1\hss\egroup
-    \kern-3sp \kern3sp }
+    \kern-8sp \kern8sp }
 \def\XPGKOstartFS#1{\leavevmode
     \hbox to.5em\bgroup\XeTeXinterchartokenstate\z@ #1\hss\egroup
-    \kern-4sp \kern4sp }
+    \kern-9sp \kern9sp }
 \let\XPGKOnobreak          \nobreak
 \def\XPGKOhalfzero         {\hskip   \XPGKOhalfdim \relax}%
 \def\XPGKOhalfhalf         {\hskip   \XPGKOhalfdim minus  \XPGKOhalfdim \relax}%
@@ -669,6 +715,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XeTeXcharclassOP{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOquarterquarter
@@ -679,6 +726,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XeTeXcharclassCL{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
@@ -689,6 +737,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassMD{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
                 \or \unkern\unkern \XPGKOnobreak\XPGKOhalfquarter
@@ -699,6 +748,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassFS{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
@@ -709,6 +759,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassLD{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOnobreak\XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
@@ -719,6 +770,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassEX{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOnobreak\XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter
@@ -729,6 +781,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassAO{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOquarterquarter
@@ -739,6 +792,7 @@
     \XeTeXinterchartoks\XeTeXcharclassBoundary\XPGKOcharclassAC{%
         \ifnum\lastnodetype=12 %
             \ifcase\lastkern
+                \or \or \or \or \or
                 \or \unkern\unkern
                 \or \unkern\unkern \XPGKOnobreak\XPGKOhalfhalf
                 \or \unkern\unkern \XPGKOnobreak\XPGKOquarterquarter

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -336,7 +336,9 @@
   \csname datekurdish@\kurdish at variant @\kurdish at script\endcsname%
 }
 
-\newcommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}
+% Use \providecommand here as the ldf file might
+% be reloaded via BCP.
+\providecommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}
 
 \def\kurdishnumber#1{%
   \if at western@numerals

Deleted: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -1,33 +0,0 @@
-\ProvidesFile{gloss-latex.ldf}[polyglossia: module for default language]
-
-\PolyglossiaSetup{latex}{
-  hyphennames={english},
-  hyphenmins={2,3},
-  langtag=ENG,
-  fontsetup=true,
-}
-
-\def\captionslatex{%
-   \def\prefacename{Preface}%
-   \def\refname{References}%
-   \def\abstractname{Abstract}%
-   \def\bibname{Bibliography}%
-   \def\chaptername{Chapter}%
-   \def\appendixname{Appendix}%
-   \def\contentsname{Contents}%
-   \def\listfigurename{List of Figures}%
-   \def\listtablename{List of Tables}%
-   \def\indexname{Index}%
-   \def\figurename{Figure}%
-   \def\tablename{Table}%
-   \def\partname{Part}%
-   \def\enclname{encl}%
-   \def\ccname{cc}%
-   \def\headtoname{To}%
-   \def\pagename{Page}%
-   \def\seename{see}%
-   \def\alsoname{see also}%
-   \def\proofname{Proof}%
-}
-
-\endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -1,4 +1,4 @@
-\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.3 2020-03-08]
+\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.4 2021-10-25]
 
 \ExplSyntaxOn
 
@@ -27,7 +27,7 @@
 
 \bool_new:N \l_polyglossia_latin_use_j_bool
 \bool_new:N \l_polyglossia_latin_use_v_bool
-\bool_new:N \l_polyglossia_latin_use_digraphs_bool
+\bool_new:N \l_polyglossia_latin_use_ligatures_bool
 \bool_new:N \l_polyglossia_latin_capitalize_month_bool
 
 \cs_new:Npn \polyglossia_latin_classical_character_codes:
@@ -388,7 +388,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_false:N \l_polyglossia_latin_use_v_bool
-    \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {classic}
@@ -400,7 +400,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_false:N \l_polyglossia_latin_use_v_bool
-    \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {medieval}
@@ -412,7 +412,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_true:N \l_polyglossia_latin_use_v_bool
-    \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {modern}
@@ -424,7 +424,7 @@
   {
     \bool_set_false:N \l_polyglossia_latin_use_j_bool
     \bool_set_true:N \l_polyglossia_latin_use_v_bool
-    \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
+    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
     \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_true:N \l_polyglossia_latin_punctuation_spacing_bool
     \str_set:Nn \l_polyglossia_latin_variant_str {ecclesiastic}
@@ -519,7 +519,7 @@
   {
     \def \prefacename
       {
-        \bool_if:NTF \l_polyglossia_latin_use_digraphs_bool {Præfatio} {Praefatio}
+        \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool {Præfatio} {Praefatio}
       }
     \def \refname {Conspectus~librorum}
     \def \abstractname {Summarium}
@@ -545,7 +545,7 @@
 
 \cs_new:Npn \polyglossia_latin_month_name:
   {
-    \str_set:Nx \l_tmpa_str
+    \tl_set:Nx \l_tmpa_tl
       {
         \int_case:nn { \month }
           {
@@ -565,10 +565,10 @@
       }
     \bool_if:NTF \l_polyglossia_latin_capitalize_month_bool
       {
-        \tl_mixed_case:n { \l_tmpa_str }
+        \text_titlecase:n { \l_tmpa_tl }
       }
       {
-        \str_use:N \l_tmpa_str
+        \l_tmpa_tl
       }
   }
 
@@ -717,28 +717,28 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_digraph_shorthand:Nnn E { Æ }
+        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Æ }
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Æ }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Æ }
                     {
                       \polyglossia_latin_allow_hyphens: A
                     }
                 }
             }
-        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { æ }
+        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { æ }
                 {
                   \polyglossia_latin_allow_hyphens: a
                 }
             }
-        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { Π}
+        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { Π}
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Π}
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Π}
                     {
                       \polyglossia_latin_allow_hyphens: O
                     }
                 }
             }
-        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { œ }
+        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { œ }
                 {
                   \polyglossia_latin_allow_hyphens: o
                 }
@@ -748,23 +748,20 @@
         {>} { » }
       }
       {
-        \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: #1 }
+        \tl_if_single_token:nTF {#1}
           {
-            \token_if_eq_meaning:NNTF #1 \AE { \polyglossia_latin_allow_hyphens: #1 }
+            \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: }
               {
-                \token_if_eq_meaning:NNTF #1 \ae { \polyglossia_latin_allow_hyphens: #1 }
+                \polyglossia_latin_if_ligature_command:NTF #1 { \polyglossia_latin_allow_hyphens: }
                   {
-                    \token_if_eq_meaning:NNTF #1 \OE { \polyglossia_latin_allow_hyphens: #1 }
-                      {
-                        \token_if_eq_meaning:NNTF #1 \oe { \polyglossia_latin_allow_hyphens: #1 }
-                          {
-                            \token_to_str:N "
-                            #1
-                          }
-                      }
+                    \token_to_str:N "
                   }
               }
           }
+          {
+            \token_to_str:N "
+          }
+          #1
       }
   }
 
@@ -772,22 +769,22 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_digraph_shorthand:Nnn E { Ǽ }
+        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Ǽ }
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { Ǽ } { Á }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { Ǽ } { Á }
                 }
             }
-        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { ǽ } { á } }
+        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { ǽ } { á } }
         {E} { É }
         {e} { é }
         {I} { Í }
         {i} { í }
-        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { \'Π}
+        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { \'Π}
                 {
-                  \polyglossia_latin_digraph_shorthand:Nnn e { \'Œ } { Ó }
+                  \polyglossia_latin_ligature_shorthand:Nnn e { \'Œ } { Ó }
                 }
             }
-        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { \'œ } { ó } }
+        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { \'œ } { ó } }
         {U} { Ú }
         {u} { ú }
         {V} { \' V } % V may be a vowel, but lowercase v is never used as a vowel.
@@ -799,20 +796,17 @@
         {œ} { \'œ }
       }
       {
-        \token_if_eq_meaning:NNTF #1 \AE { Ǽ }
+        \tl_if_single_token:nTF {#1}
           {
-            \token_if_eq_meaning:NNTF #1 \ae { ǽ }
+            \polyglossia_latin_if_ligature_command:NTF #1 { \' }
               {
-                \token_if_eq_meaning:NNTF #1 \OE { \'Π}
-                  {
-                    \token_if_eq_meaning:NNTF #1 \oe { \'œ }
-                      {
-                        \token_to_str:N '
-                        #1
-                      }
-                  }
+                \token_to_str:N '
               }
           }
+          {
+            \token_to_str:N '
+          }
+          #1
       }
   }
 
@@ -820,9 +814,9 @@
   {
     \str_case:nnF {#1}
       {
-        {A} { \polyglossia_latin_diphthong_macron:NNn AE
+        {A} { \polyglossia_latin_ligature_macron:NNnn AE { Ǣ }
                 {
-                  \polyglossia_latin_diphthong_macron:NNn Ae
+                  \polyglossia_latin_ligature_macron:NNnn Ae { Ǣ }
                     {
                       \polyglossia_latin_diphthong_macron:NNn AU
                         {
@@ -831,7 +825,7 @@
                     }
                 }
             }
-        {a} { \polyglossia_latin_diphthong_macron:NNn ae
+        {a} { \polyglossia_latin_ligature_macron:NNnn ae { ǣ }
                 {
                   \polyglossia_latin_diphthong_macron:NNn au { ā }
                 }
@@ -844,12 +838,12 @@
         {e} { \polyglossia_latin_diphthong_macron:NNn eu { ē } }
         {I} { Ī }
         {i} { ī }
-        {O} { \polyglossia_latin_diphthong_macron:NNn OE
+        {O} { \polyglossia_latin_ligature_macron:NNnn OE { \=Π}
                 {
-                  \polyglossia_latin_diphthong_macron:NNn Oe { Ō }
+                  \polyglossia_latin_ligature_macron:NNnn Oe { \=Œ } { Ō }
                 }
             }
-        {o} { \polyglossia_latin_diphthong_macron:NNn oe { ō } }
+        {o} { \polyglossia_latin_ligature_macron:NNnn oe { \=œ } { ō } }
         {U} { Ū }
         {u} { ū }
         {V} { \= V } % V may be a vowel, but lowercase v is never used as a vowel.
@@ -857,7 +851,16 @@
         {y} { ȳ }
       }
       {
-        \token_to_str:N =
+        \tl_if_single_token:nTF {#1}
+          {
+            \polyglossia_latin_if_ligature_command:NTF #1 { \= }
+              {
+                \token_to_str:N =
+              }
+          }
+          {
+            \token_to_str:N =
+          }
         #1
       }
   }
@@ -894,12 +897,12 @@
     \bbl at allowhyphens
   }
 
-\cs_new:Npn \polyglossia_latin_digraph_shorthand:Nnn #1#2#3
-% #1: second letter of digraph (E or e)
-% #2: digraph character
-% #3: non-digraph code
+\cs_new:Npn \polyglossia_latin_ligature_shorthand:Nnn #1#2#3
+% #1: second letter of ligature (E or e)
+% #2: ligature character
+% #3: non-ligature code
   {
-    \bool_if:NTF \l_polyglossia_latin_use_digraphs_bool
+    \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool
       {
         \peek_meaning_remove:NTF #1 {#2} {#3}
       }
@@ -908,14 +911,62 @@
       }
   }
 
+\msg_new:nnn {polyglossia} {latin / no-double-macron-font}
+  {
+    The~combining~double~macron~(U+035E)~is~not~available~in~the~current~
+    font.~The~diphthong~is~typeset~without~macron~ \msg_line_context: .
+  }
+
 \cs_new:Npn \polyglossia_latin_diphthong_macron:NNn #1#2#3
 % #1: first character of diphthong
 % #2: second character of diphthong
 % #3: non-diphthong code
   {
-    \peek_meaning:NTF #2 { #1 \char "35E \relax } {#3} % U+35E: combining double macron
+    \peek_meaning:NTF #2
+      {
+        #1
+        \iffontchar \font "35E \relax % U+35E: combining double macron
+          \char "35E \relax
+        \else
+          \msg_warning:nn {polyglossia} {latin / no-double-macron-font}
+        \fi
+      }
+      {
+        #3
+      }
   }
 
+\cs_new:Npn \polyglossia_latin_ligature_macron:NNnn #1#2#3#4
+% #1: first character of diphthong
+% #2: second character of diphthong
+% #3: ligature code
+% #4: false code
+  {
+    \polyglossia_latin_ligature_shorthand:Nnn #2 {#3}
+      {
+        \polyglossia_latin_diphthong_macron:NNn #1 #2 {#4}
+      }
+  }
+
+% The following conditional tests if the argument is a ligature command (\AE,
+% \ae, \OE, or \oe).
+\prg_new_conditional:Npnn \polyglossia_latin_if_ligature_command:N #1 {TF}
+  {
+    \token_if_eq_meaning:NNTF #1 \AE { \prg_return_true: }
+      {
+        \token_if_eq_meaning:NNTF #1 \ae { \prg_return_true: }
+          {
+            \token_if_eq_meaning:NNTF #1 \OE { \prg_return_true: }
+              {
+                \token_if_eq_meaning:NNTF #1 \oe { \prg_return_true: }
+                  {
+                    \prg_return_false:
+                  }
+              }
+          }
+      }
+  }
+
 \cs_new:Npn \polyglossia_latin_no_shorthands:
   {
     \bbl at deactivate {"}

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -140,8 +140,8 @@
 
 \def\datemalay at indonesian{%
    \def\today{\number\day~\ifcase\month\or
-    Januari\or Pebruari\or Maret\or April\or Mei\or Juni\or
-    Juli\or Agustus\or September\or Oktober\or Nopember\or Desember\fi
+    Januari\or Februari\or Maret\or April\or Mei\or Juni\or
+    Juli\or Agustus\or September\or Oktober\or November\or Desember\fi
     \space \number\year}}
 
 \def\datemalay at malay{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -216,12 +216,12 @@
 }
 
 \def\blockextras at mongolian{%
-   \ifcyrillic at numerals\mongolian at numbers\fi%
-   \ifmongolian at babelshorthands\mongolian at shorthands\fi%
+   \ifcyrillic at numerals\mongolian at numbers\else\nomongolian at numbers\fi%
+   \ifmongolian at babelshorthands\mongolian at shorthands\else\nomongolian at shorthands\fi%
 }
 
 \def\inlineextras at mongolian{%
-   \ifmongolian at babelshorthands\mongolian at shorthands\fi%
+   \ifmongolian at babelshorthands\mongolian at shorthands\else\nomongolian at shorthands\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -148,12 +148,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifoccitan at babelshorthands\occitan at shorthands\fi%
+   \ifoccitan at babelshorthands\occitan at shorthands\else\nooccitan at shorthands\fi%
 }
 
 \def\inlineextras at occitan{%
    \lccode\string"2019=\string"2019%
-   \ifoccitan at babelshorthands\occitan at shorthands\fi%
+   \ifoccitan at babelshorthands\occitan at shorthands\else\nooccitan at shorthands\fi%
 }
 %% Distributable under the LaTeX Project Public License,
 %% version 1.3c or higher (your choice). The latest version of

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -108,12 +108,12 @@
    \lccode\string"2019=\string"2019%
    \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
    \finalhyphendemerits=50000000%
-   \ifpiedmontese at babelshorthands\piedmontese at shorthands\fi%
+   \ifpiedmontese at babelshorthands\piedmontese at shorthands\else\nopiedmontese at shorthands\fi%
 }
 
 \def\inlineextras at piedmontese{%
    \lccode\string"2019=\string"2019%
-   \ifpiedmontese at babelshorthands\piedmontese at shorthands\fi%
+   \ifpiedmontese at babelshorthands\piedmontese at shorthands\else\nopiedmontese at shorthands\fi%
 }
 %%% CHANGES END %%%
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -18,6 +18,10 @@
 \setlanguagealias[variant=portuguese]{portuguese}{portuges}
 \setlanguagealias[variant=brazilian]{portuguese}{brazil}
 
+\ifluatex
+  \RequirePackage{luavlna}
+\fi
+
 \def\portuguese at variant{portuges}
 \define at choicekey*+{portuguese}{variant}[\xpg at val\xpg at nr]{portuguese,brazilian}[portuguese]{%
    \ifcase\xpg at nr\relax
@@ -34,11 +38,92 @@
    \xpg at info{Option: portuguese, variant=\xpg at val}%
 }{\xpg at warning{Unknown portuguese variant `#1'}}
 
+\define at boolkey{portuguese}[portuguese@]{babelshorthands}[true]{}
 
+\define at boolkey{portuguese}[portuguese@]{splithyphens}[true]{}
+
 % Register default options
-\xpg at initialize@gloss at options{portuguese}{variant=portuguese}
+\xpg at initialize@gloss at options{portuguese}{variant=portuguese,
+      babelshorthands=false,
+      splithyphens=true}
 
+\ifsystem at babelshorthands
+  \setkeys{portuguese}{babelshorthands=true}
+\else
+  \setkeys{portuguese}{babelshorthands=false}
+\fi
 
+\ifcsundef{initiate at active@char}{%
+  \input{babelsh.def}%
+  \initiate at active@char{"}%
+  \shorthandoff{"}%
+}{}
+
+\def\portuguese@@splhyphen#1{%
+  \def\portuguese at sh@tmp{%
+       \if\portuguese at sh@next-#1%
+       \else\expandafter\portuguese@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\portuguese at sh@next\portuguese at sh@tmp%
+}
+
+\def\portuguese@@@splhyphen#1{%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
+}
+
+\def\portuguese at splhyphen{%
+  \portuguese@@splhyphen{-}%
+}
+
+\def\portuguese at shorthands{%
+  \bbl at activate{"}%
+  \def\language at group{portuguese}%
+  \declare at shorthand{portuguese}{"=}{\portuguese at splhyphen}%
+  \declare at shorthand{portuguese}{""}{\hskip\z at skip}%
+  \declare at shorthand{portuguese}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{portuguese}{"-}{\nobreak\-\bbl at allowhyphens}%
+  \declare at shorthand{portuguese}{"|}{%
+      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
+      \bbl at allowhyphens}{}%
+  }%
+  \declare at shorthand{portuguese}{"/}{\textormath
+    {\bbl at allowhyphens\discretionary{/}{}{/}\bbl at allowhyphens}{}}%
+  \declare at shorthand{portuguese}{"<}{«}%
+  \declare at shorthand{portuguese}{">}{»}%
+}
+
+\def\noportuguese at shorthands{%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+}
+
+\ifxetex
+  % splithyphens
+  \newXeTeXintercharclass\portuguese at hyphen % -
+\fi
+
+\def\portuguese at hyphens{%
+    \ifluatex
+      \AfterPreamble{\enablesplithyphens{portuguese}}%
+    \else
+      \XeTeXinterchartokenstate=1
+      \XeTeXcharclass `\- \portuguese at hyphen
+      \XeTeXinterchartoks \z@ \portuguese at hyphen = {\portuguese@@splhyphen}% "-" -> "\portuguese@@splhyphen-"
+    \fi%
+}
+
+\def\noportuguese at hyphens{%
+    \ifluatex
+      \AfterPreamble{\disablesplithyphens{portuguese}}%
+    \else
+      \XeTeXcharclass `\- \z@
+    \fi%
+}
+
 \def\portuguese at language{%
    \polyglossia at setup@language at patterns{\portuguese at variant}%
 }%
@@ -113,5 +198,20 @@
 \def\dateportuguese{%
   \csname dateportuguese@\portuguese at variant\endcsname%
 }
+
+\def\noextras at portuguese{%
+  \ifportuguese at babelshorthands\noportuguese at shorthands\fi%
+  \noportuguese at hyphens%
+}
+
+\def\blockextras at portuguese{%
+  \ifportuguese at babelshorthands\portuguese at shorthands\else\noportuguese at shorthands\fi%
+  \ifportuguese at splithyphens\portuguese at hyphens\else\noportuguese at hyphens\fi%
+}
+
+\def\inlineextras at portuguese{%
+  \ifportuguese at babelshorthands\portuguese at shorthands\else\noportuguese at shorthands\fi%
+  \ifportuguese at splithyphens\portuguese at hyphens\else\noportuguese at hyphens\fi%
+}
      
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -348,12 +348,12 @@
 
 \def\blockextras at russian{%
    \russian at capsformat%
-   \ifcyrillic at numerals\russian at numbers\fi%
-   \ifrussian at babelshorthands\russian at shorthands\fi%
+   \ifcyrillic at numerals\russian at numbers\else\norussian at numbers\fi%
+   \ifrussian at babelshorthands\russian at shorthands\else\norussian at shorthands\fi%
 }
 
 \def\inlineextras at russian{%
-   \ifrussian at babelshorthands\russian at shorthands\fi%
+   \ifrussian at babelshorthands\russian at shorthands\else\norussian at shorthands\fi%
 }
 
 %%% These lines taken from russianb.ldf, part of babel package.

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -71,9 +71,10 @@
 % Register default options
 \xpg at initialize@gloss at options{sanskrit}{script=Devanagari,numerals=Devanagari}
 
+% Use \providecommand here as the ldf file might
+% be reloaded via BCP.
+\providecommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
 
-\newcommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
-
 \def\sanskritnumber#1{%
   \ifsanskrit at devanagari@numerals
     \devanagaridigits{\number#1}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -11,7 +11,8 @@
   langtag=SRB,
   hyphennames={serbian},
   hyphenmins={2,2},
-  indentfirst=true,
+  frenchspacing=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
+  indentfirst=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
   fontsetup=false,
   localnumeral=serbiannumerals,
   Localnumeral=Serbiannumerals,
@@ -27,6 +28,10 @@
 % Babel aliases
 \setlanguagealias[script=Cyrillic]{serbian}{serbianc}
 
+\ifluatex
+  \RequirePackage{luavlna}
+\fi
+
 \newif\if at serbian@cyr
 \define at choicekey*+{serbian}{Script}[\xpg at val\xpg at nr]{cyrillic,latin}[cyrillic]{%
    \ifcase\xpg at nr\relax
@@ -70,10 +75,12 @@
    \xpg at info{Option: Serbian, numerals=\xpg at val}%
 }{\xpg at warning{Unknown Serbian numerals value `#1'}}
 
+\define at boolkey{serbian}[serbian@]{splithyphens}[true]{}
+
 \setkeys{serbian}{Script,numerals}
 
 % Register default options
-\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic}
+\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic,splithyphens=true}
 
 \def\captionsserbian{%
    \if at serbian@cyr\captionsserbian at cyr\else\captionsserbian at lat\fi
@@ -154,10 +161,11 @@
     децембар\fi \space \number\year.}%
 }
 
+% Use \providecommand here as the ldf file might
+% be reloaded via serbianc.
+\providecommand{\serbiannumerals}[2]{\serbiannumber{#2}}
+\providecommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
 
-\newcommand{\serbiannumerals}[2]{\serbiannumber{#2}}
-\newcommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
-
 \def\serbiannumber#1{%
   \ifcyrillic at numerals
     \ifcyrillic at asbuk@numerals
@@ -201,12 +209,65 @@
    \let\@Alph\latin at Alph
 }
 
+\def\serbian@@splhyphen#1{%
+  \def\serbian at sh@tmp{%
+       \if\serbian at sh@next-#1%
+       \else\expandafter\serbian@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\serbian at sh@next\serbian at sh@tmp%
+}
+
+\def\serbian@@@splhyphen#1{%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
+}
+
+\def\serbian at splhyphen{%
+  \serbian@@splhyphen{-}%
+}
+
+\ifxetex
+  % splithyphens
+  \newXeTeXintercharclass\serbian at hyphen % -
+  \newXeTeXintercharclass\serbian at nonsyllabicpreposition%
+\fi
+
+\def\serbian at hyphens{%
+    \ifluatex
+      \AfterPreamble{\enablesplithyphens{serbian}}%
+    \else
+      \XeTeXinterchartokenstate=1
+      \XeTeXcharclass `\- \serbian at hyphen
+      \XeTeXinterchartoks \z@ \serbian at hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
+      % necessary if used together with vlna:
+      \XeTeXinterchartoks \serbian at nonsyllabicpreposition \serbian at hyphen = {\serbian@@splhyphen}% "-" -> "\serbian@@splhyphen-"
+    \fi%
+}
+
+\def\noserbian at hyphens{%
+    \ifluatex
+      \AfterPreamble{\disablesplithyphens{serbian}}%
+    \else
+      \XeTeXcharclass `\- \z@
+    \fi%
+}
+
 \def\blockextras at serbian{%
-   \ifcyrillic at numerals\serbian at numbers\fi
+  \ifcyrillic at numerals\serbian at numbers\else\noserbian at numbers\fi%
+  \ifserbian at splithyphens\serbian at hyphens\else\noserbian at hyphens\fi%
 }
+
+\def\inlineextras at serbian{%
+  \ifserbian at splithyphens\serbian at hyphens\else\noserbian at hyphens\fi%
+}
  
 \def\noextras at serbian{%
-   \ifcyrillic at numerals\noserbian at numbers\fi
+   \ifcyrillic at numerals\noserbian at numbers\fi%
+   \noserbian at hyphens%
 }
 
 \def\Asbuk#1{\expandafter\serbian at asbuk@Alph\csname c@#1\endcsname}
@@ -215,21 +276,21 @@
 \def\AsbukTrad#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
 \def\asbukTrad#1{\expandafter\cyr at alph\csname c@#1\endcsname}
 
-% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30.
+% This is a poor man's cyrillic alphanumeric.
+% It just uses the alphabet and thus ends at 30.
 \def\serbian at asbuk@Alph#1{\ifcase#1\or
-   А\or Б\or В\or Г\or Д\or Е\or Ж\or
-   З\or И\or К\or Л\or М\or Н\or О\or
-   П\or Р\or С\or Т\or У\or Ф\or Х\or
-   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
+   А\or Б\or В\or Г\or Д\or Ђ\or Е\or Ж\or
+   З\or И\or Ј\or К\or Л\or Љ\or М\or Н\or
+   Њ\or О\or П\or Р\or С\or Т\or Ћ\or У\or
+   Ф\or Х\or Ц\or Ч\or Џ\or Ш%
    \else\xpg at ill@value{#1}{serbian at asbuk@Alph}\fi%
 }
 
 \def\serbian at asbuk@alph#1{\ifcase#1\or
-   а\or б\or в\or г\or д\or е\or ж\or
-   з\or и\or к\or л\or м\or н\or о\or
-   п\or р\or с\or т\or у\or ф\or х\or
-   ц\or ч\or ш\or щ\or э\or ю\or я%
+   а\or б\or в\or г\or д\or ђ\or е\or ж\or
+   з\or и\or ј\or к\or л\or љ\or м\or н\or
+   њ\or о\or п\or р\or с\or т\or ћ\or у\or
+   ф\or х\or ц\or ч\or џ\or ш%
    \else\xpg at ill@value{#1}{serbian at asbuk@alph}\fi%
 }
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -37,6 +37,14 @@
 }{}
 
 \def\slovak@@splhyphen#1{%
+  \def\slovak at sh@tmp{%
+       \if\slovak at sh@next-#1%
+       \else\expandafter\slovak@@@splhyphen{#1}\fi%
+     }%
+     \futurelet\slovak at sh@next\slovak at sh@tmp%
+}
+
+\def\slovak@@@splhyphen#1{%
   \ifnum\hyphenchar \font>0%
     \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
     \nobreak\hskip\z@%
@@ -232,13 +240,13 @@
 }
 
 \def\blockextras at slovak{%
-  \ifslovak at babelshorthands\slovak at shorthands\fi%
+  \ifslovak at babelshorthands\slovak at shorthands\else\noslovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
   \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }
 
 \def\inlineextras at slovak{%
-  \ifslovak at babelshorthands\slovak at shorthands\fi%
+  \ifslovak at babelshorthands\slovak at shorthands\else\noslovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
   \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -158,7 +158,9 @@
   \let\tgh\relax%
 }
 
-\newcommand*\spanishoperator[2][]{%
+% Use \providecommand here as the ldf file might
+% be reloaded via babel aliases.
+\providecommand*\spanishoperator[2][]{%
   \ifx#1\\\\
     \protected at csxdef{#2}{\mathop{\operator at font #2}\nolimits}%
   \else

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -23,8 +23,10 @@
 \def\tmp at tibetan{tibetan}
 \define at key{tibetan}{numerals}[tibetan]{%
 	\def\@tmpa{#1}%
-	\ifx\@tmpa\tmp at tibetan\@tibetan at numeralstrue\else
-	  \@tibetan at numeralsfalse\fi
+	\ifx\@tmpa\tmp at tibetan\@tibetan at numeralstrue%
+	\else
+	  \@tibetan at numeralsfalse%
+	\fi%
 }
 
 \ifluatex
@@ -33,23 +35,23 @@
 \fi
 
 \def\tibetan at eol{%
-  \ifluatex %
-    \xpg at tibteol=1\relax %
+  \ifluatex%
+    \xpg at tibteol=1\relax%
     \directlua{polyglossia.activate_tibt_eol()}%
-  \else %
+  \else%
     \XeTeXlinebreaklocale "bo"%
     \XeTeXlinebreakskip=0pt plus 0.1em% doesn't do much, but doesn't harm I guess...
-  \fi %
+  \fi%
 }
 
 \def\notibetan at eol{%
-  \ifluatex %
-    \xpg at tibteol=0\relax %
+  \ifluatex%
+    \xpg at tibteol=0\relax%
     %\directlua{polyglossia.activate_tibt_eol()}%
-  \else %
+  \else%
     \XeTeXlinebreaklocale "en"% en? really?
     \XeTeXlinebreakskip=0pt plus 0pt%
-  \fi %
+  \fi%
 }
 
 % Register default options
@@ -82,6 +84,7 @@
    \def\proofname{བདེན་དཔང་།}% not sure about this one...
    \def\glossaryname{མིང་ཚིག་རེའུ་མིག།}%
 }
+
 \def\datetibetan{%   
    \def\tibetan at month{%
      \ifcase\month\or
@@ -106,6 +109,7 @@
 }
 
 \def\tibetandigits#1{\expandafter\@tibetan at digits #1@}
+
 \def\@tibetan at digits#1{%
   \ifx @#1% then terminate
   \else
@@ -124,14 +128,28 @@
   \fi}
 
 \def\@tibetanalph#1{%
-  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
-  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
- \else\xpg at ill@value{#1}{@tibetanalph}\fi}
-\def\tibetanAlph#1{\expandafter\@tibetanAlph\csname c@#1\endcsname}
+    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or
+           ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or
+           བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or
+           འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
+    \else%
+        \xpg at ill@value{#1}{@tibetanalph}%
+    \fi%
+}
+ 
+\def\tibetanAlph#1{%
+    \expandafter\@tibetanAlph\csname c@#1\endcsname%
+}
+
 \def\@tibetanAlph#1{%
-  \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or 
-  ཕ\or བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
- \else\xpg at ill@value{#1}{@tibetanalph}\fi}
+    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or
+          ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or བ\or མ\or ཙ\or
+           ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or
+            ས\or ཧ\or ཨ%
+    \else%
+       \xpg at ill@value{#1}{@tibetanalph}%
+    \fi%
+}
 
 \newcommand{\tibetanumerals}[2]{\tibetannumber{#2}}
 
@@ -141,13 +159,16 @@
      \let\@Alph\@tibetanAlph%
    \fi
 }
+
 \def\notibetan at numbers{%
   \let\@alph\latin at alph%
   \let\@Alph\latin at Alph%
 }
 
+% Store original definition
+\let\xpg at orig@arabic\@arabic
+
 \def\tibetan at globalnumbers{%
-   \let\xpg at orig@arabic\@arabic%
    \let\@arabic\tibetannumber%
    \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
 }
@@ -158,17 +179,31 @@
 
 \def\noextras at tibetan{%
    \notibetan at eol%
-   \ifcsname xpg at orig@baselinestretch\endcsname\renewcommand{\baselinestretch}{\xpg at orig@baselinestretch}\fi %
-   }
+   \ifcsname xpg at orig@baselinestretch\endcsname%
+       \renewcommand{\baselinestretch}{\xpg at orig@baselinestretch}%
+   \fi%
+}
 
 \def\inlineextras at tibetan{%
-   \xdef\xpg at orig@baselinestretch{\ifcsname baselinestretch\endcsname \baselinestretch \else 1\fi}%
+   \xdef\xpg at orig@baselinestretch{%
+       \ifcsname baselinestretch\endcsname
+           \baselinestretch
+        \else
+           1%
+        \fi%
+   }%
    \renewcommand{\baselinestretch}{1.2}%
    \tibetan at eol%
-   }
+}
 
 \def\blockextras at tibetan{%
-   \xdef\xpg at orig@baselinestretch{\ifcsname baselinestretch\endcsname \baselinestretch \else 1\fi}%
+   \xdef\xpg at orig@baselinestretch{%
+        \ifcsname baselinestretch\endcsname
+            \baselinestretch
+        \else
+           1%
+        \fi%
+   }%
    \renewcommand{\baselinestretch}{1.2}%
    \tibetan at eol%
 }

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf	2022-04-05 22:10:52 UTC (rev 62940)
@@ -201,8 +201,8 @@
 \let\ukrainiannumeral=\ukrainiannumber
 \let\Ukrainiannumeral=\Ukrainiannumber
 
-\def\Asbuk#1{\expandafter\ukranian at asbuk@Alph\csname c@#1\endcsname}
-\def\asbuk#1{\expandafter\ukranian at asbuk@alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\ukrainian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\ukrainian at asbuk@alph\csname c@#1\endcsname}
 
 \def\AsbukTrad#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
 \def\asbukTrad#1{\expandafter\cyr at alph\csname c@#1\endcsname}
@@ -247,12 +247,12 @@
 
 \def\blockextras at ukrainian{%
   \ukrainian at capsformat%
-  \ifcyrillic at numerals\ukrainian at numbers\fi%
-  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifcyrillic at numerals\ukrainian at numbers\else\noukrainian at numbers\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\else\noukrainian at shorthands\fi%
 }
 
 \def\inlineextras at ukrainian{%
-  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\else\noukrainian at shorthands\fi%
 }
 
 %%% stuff from Babel

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty	2022-04-05 22:09:37 UTC (rev 62939)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty	2022-04-05 22:10:52 UTC (rev 62940)
@@ -1,5 +1,5 @@
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{polyglossia}[2021/04/12 v1.53
+\ProvidesPackage{polyglossia}[2022/03/27 v1.54
   Modern multilingual typesetting with XeLaTeX and LuaLaTeX]
 \RequirePackage{etoolbox}
 \RequirePackage{makecmds}
@@ -16,27 +16,45 @@
 
 % Execute code #3 if package #1 has been loaded already, else
 % add to package hook #2
-\newcommand\xpg at at@package[3]{%
-    \@ifpackageloaded{#1}{#3}{\AddToHook{#2}{#3}}%
+\cs_new_nopar:Nn \__xpg_at_package_hook:nnn{
+  \@ifpackageloaded{#1}{#3}{\AddToHook{#2}{#3}}%
 }
 
+% safe according to expl3 bug #960
+\cs_generate_variant:Nn \prop_item:Nn { Ne, Nf, No, Nx }
+\cs_generate_variant:Nn \clist_set:Nn { Ne, Nf, No, Nx }
+\cs_generate_variant:Nn \clist_gput_right:Nn {Ne}
+\cs_generate_variant:Nn  \prop_get:NnN {NeN}
+\cs_generate_variant:Nn  \prop_gput:Nnn {Nne, Nee, Nen}
+\cs_generate_variant:Nn  \cs_gset:Npn {Npe}
+\cs_generate_variant:Nn  \cs_new:Nn {Ne}
+\cs_generate_variant:Nn  \cs_new_nopar:Nn {Ne}
+\cs_generate_variant:Nn  \cs_gset_nopar:Npn {Npe}
+\cs_generate_variant:Nn  \cs_gset_nopar:Npn {cpe}
+\cs_generate_variant:Nn  \tl_set:Nn {Ne}
+\cs_generate_variant:Nn  \str_foldcase:n {e}
+\prg_generate_conditional_variant:Nnn \file_if_exist:n {e} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \tl_if_blank:n {e} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \clist_if_in:Nn {Ne} {TF, T, F, p}
+\prg_generate_conditional_variant:Nnn \prop_if_in:Nn {Ne} {TF, T, F, p}
 % correct a bug in tracklang
-\xpg at at@package{tracklang}{file/after/tracklang.sty}{%
+\__xpg_at_package_hook:nnn{tracklang}{file/tracklang.sty/after}{%
   \@ifpackagelater{tracklang}{2019/08/30}{}{\global\def\AddTrackedLangage{\AddTrackedLanguage}}
 }
 
-
 %% This is for compatibility with Babel-aware package:
 \def\languageshorthands#1{\relax} %this is for scrlttr2 class
 \def\bbl at cs#1{\csname bbl@#1\endcsname}%
 \AtEndPreamble{\let\bbl at set@language\xpg at set@language at aux} %for biblatex
 \AtEndPreamble{\let\bbl at main@language\xpg at main@language} %for biblatex
-\providecommand\texorpdfstring[2]{#1}% dummy command if hyperref is not loaded
+\AtEndPreamble{
+  \providecommand\texorpdfstring[2]{#1}% dummy command if hyperref is not loaded
+}
 
-\ifluatex
+\sys_if_engine_luatex:T{
   \RequirePackage{luatexbase} % already included by fontspec, but needed here
   \RequireLuaModule{polyglossia}
-\fi
+}
 
 % Which version of XeTeX do we use? What is the boudary class? 4095 or 255
 \@ifundefined{e at alloc@intercharclass at top}
@@ -44,10 +62,16 @@
   {\let\xpg at boundaryclass=\e at alloc@intercharclass at top}
 
 % Useful for getting list of loaded languages and variants. Like babel's bbl at loaded
-\let\xpg at loaded\@empty% list of loaded languages (polyglossia name)
-\let\xpg at vloaded\@empty% list of loaded variants
-\let\xpg at bloaded\@empty% list of loaded languages (babel name)
-\let\xpg at bcp@loaded\@empty% list of loaded languages (bcp-47 id)
+% all language loaded
+\seq_new:N \__xpg_langs_loaded
+% list of loaded languages (polyglossia name)
+\clist_new:N \xpg at loaded
+% list of loaded variants
+\clist_new:N \xpg at vloaded
+% list of loaded languages (babel name)
+\clist_new:N \xpg at bloaded
+% list of loaded languages (bcp-47 id)
+\clist_new:N \xpg at bcp@loaded
 
 % counter in latin
 \def\latinalph#1{\expandafter\latin at alph\csname c@#1\endcsname}
@@ -117,26 +141,38 @@
 % error out if lang is not loaded
 \cs_new_nopar:Nn \polyglossia at error@iflangnotloaded:n
 {
-  \cs_if_exist:cF{#1 at loaded}
+  \seq_if_in:NxF \__xpg_langs_loaded {#1}
   {
     \xpg at error{language~ #1~ is~ not~ loaded.~ Please~ load~ it~ before~ using~ it.}
   }
 }
 
+\msg_new:nnn { polyglossia } { languagenotloaded }
+{
+  The~ language~ #1~ is~ not~ loaded.~ You~ should~ load~ it.
+}
+\msg_redirect_name:nnn { polyglossia } { languagenotloaded } { critical }
 
-% error do not use directly the gloss file
-\msg_new:nnn { polyglossia } { directloadgloss }
+\cs_new_nopar:Nn \__xpg_msg_if_lang_not_loaded:n
 {
-  You~ should~ not~ load~ directly~ the~ gloss~ file~ using~ `\string\usepackage'.
-  You~ must~ use~ `\string\setotherlanguage\{#1\}' or  `\string\setmainlanguage\{#1\}'.
+  \tl_if_blank:eT {\xpg_alias_base_lang:n{#1}}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#1}
+  }
 }
-\msg_redirect_name:nnn { polyglossia } { directloadgloss } { critical }
+% 
 
 %% use macro if defined, else warn that it is not
-\def\csuse at warn#1{%
-   \ifcsundef{#1}{\xpg at warning{ \expandafter\string\csname #1\endcsname\space is~ not~ defined}}%
-   {\csname #1\endcsname}}
+\cs_new_nopar:Nn \__xpg_use_or_warn:N
+{
+  \cs_if_exist_use:NF {#1}
+  {
+    \xpg at warning {  \tl_to_str:N {#1} ~ is~ not~ defined }
+  }
+}
+\cs_generate_variant:Nn \__xpg_use_or_warn:N {c}
 
+
 %% ensure directionality if bidi is loaded, else ignore
 \def\@@ensure at dir#1{\ifcsundef{@ensure at dir}{#1}{\@ensure at dir{#1}}}
 \def\@@ensure at maindir#1{\ifcsundef{@ensure at maindir}{#1}{\@ensure at maindir{#1}}}
@@ -153,66 +189,94 @@
   }
 }
 
+% if #1 is LR run #2 else #3
+\prg_set_conditional:Nnn \__xpg_if_LR_str:n {p, T, F, TF}
+{
+  \str_case_e:nnF{#1}{
+    {LR}{\prg_return_true:}
+    {RL}{\prg_return_false:}
+  }
+  {
+    \xpg at error{Unknown~ direction~#1}
+    \prg_return_false:
+  }
+}
+\prg_generate_conditional_variant:Nnn \__xpg_if_LR_str:n {e} {p, T, F, TF}
+
 % (lua)bidi commands to change directionality for paragraphs
 % and inline text.
 % overwritten with correct package
 \cs_new_nopar:Nn{\polyglossia at setpardirection:n}{%
-  \str_case_e:nnTF{#1}{%
-       {LR}{\relax}%
-       {RL}{\xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}}%
-     }%
-     {}%
-     {\xpg at error{Unknown~ language~ direction~ #1 ~(base~ wrapper)}}%
+  \__xpg_if_LR_str:nF {#1}
+  {
+    \xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
+  }
 }
 \cs_new_nopar:Nn{\polyglossia at settextdirection:n}{%
-  \str_case_e:nnTF{#1}{%
-       {LR}{\relax}%
-       {RL}{\xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}}%
-     }%
-     {}%
-     {\xpg at error{Unknown~ language~ direction~ #1 ~(base~ wrapper)}}%
+  \__xpg_if_LR_str:nF {#1}
+  {
+    \xpg at error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
+  }
 }
-\xpg at at@package{bidi}{package/after/bidi}{%
+\__xpg_at_package_hook:nnn{bidi}{package/bidi/after}{%
   \ExplSyntaxOn%
   \cs_gset_nopar:Nn{\polyglossia at setpardirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\setLR}%
-        {RL}{\setRL}%
-      }%
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(bidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \setLR%
+    }%
+    {%
+      \setRL%
+    }%
   }%
   \cs_gset_nopar:Nn{\polyglossia at settextdirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\LRE}%
-        {RL}{\RLE}%
-      }%
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(bidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \LRE%
+    }%
+    {%
+      \RLE%
+    }%
   }%
   \ExplSyntaxOff%
 }
-\xpg at at@package{luabidi}{package/after/luabidi}{%
+\__xpg_at_package_hook:nnn{luabidi}{package/luabidi/after}{%
   \ExplSyntaxOn%
   \cs_gset_nopar:Nn{\polyglossia at setpardirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\setLR}%
-        {RL}{\setRL}%
-      }
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(luabidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \setLR%
+    }%
+    {%
+      \setRL%
+    }%
   }%
   \cs_gset_nopar:Nn{\polyglossia at settextdirection:n}{%
-    \str_case_e:nnTF{#1}{%
-        {LR}{\LRE}%
-        {RL}{\RLE}%
-      }
-      {}%
-      {\xpg at error{Unknown~ language~ direction~ #1 ~(luabidi~ wrapper)}}%
+    \__xpg_if_LR_str:nTF{#1}%
+    {%
+      \LRE%
+    }%
+    {%
+      \RLE%
+    }%
   }%
   \ExplSyntaxOff%
 }
 
+% emulate \RTLmain
+\cs_new_nopar:Nn \__xpg_setRTLmain: {}
+\str_case_e:nnF{\c_sys_engine_str}{%
+  {luatex}{\cs_gset:Nn \__xpg_setRTLmain: {\setRTLmain}}
+  {xetex}{\cs_gset:Nn \__xpg_setRTLmain: {\@RTLmaintrue\setnonlatin}}
+}
+{
+  \cs_gset:Nn \__xpg_setRTLmain:
+  {
+    \xpg at warning{You’re~ running a~ TeX~ engine~ that~ is~ not~ LuaTeX~ or~ XeTeX.\MessageBreak
+      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
+  }
+}
+
 %% compatibility with babel
 \let\addto\gappto% gappto is defined in etoolbox
 
@@ -248,6 +312,8 @@
   %% TODO? \toggletrue{#1 at setup@done}%
   % reinit \do
   \def\do##1{\setotherlanguage{##1}}%
+  % register base alias
+  \xpg_language_alias { #1 } { #1 }
 }
 
 % Adjust language key setting after initial setup
@@ -260,7 +326,7 @@
 
 % setup hyphennames from a str list of hyphen
 \cs_new:Nn \polyglossia_setup_hyphen:n {
-  \exp_args:Nne \clist_set:Nn{\l_tmpa_clist}{\prop_item:Nn \polyglossia at langsetup {#1 / hyphennames}}
+  \clist_set:Ne{\l_tmpa_clist}{\prop_item:Nn \polyglossia at langsetup {#1 / hyphennames}}
   \providebool{havehyphen}
   \boolfalse{havehyphen}
   % for each hyphen in the set until we find one that works
@@ -267,7 +333,7 @@
   \clist_map_inline:Nn \l_tmpa_clist {
     \ifbool{havehyphen}{}{%
        % check if language hyphenname is defined
-       \polyglossia at check@ifdefined:NF{#1}{%
+      \__xpg_check_if_exist_l@:NF{#1}{%
           % if not, first consider nohyphenation
           \str_if_eq:nnTF{##1}{nohyphenation}
             {%
@@ -284,7 +350,7 @@
                       \xpg at set@hyphenation at patterns{##1}
                       \global\booltrue{havehyphen}
                   }%
-               }{}%
+                }{}%
            }%
        }%
     }%
@@ -303,7 +369,7 @@
     \polyglossia at setup@language at patterns{#1}%
   }%
   % setup hyphenmins
-  \exp_args:NNe \clist_set:Nn \l_tmpa_clist
+  \clist_set:Ne \l_tmpa_clist
     { \prop_item:Nn \polyglossia at langsetup {#1 / hyphenmins} }
   \cs_if_eq:cNF {l@#1} \l at nohyphenation
     {
@@ -509,7 +575,14 @@
             \prop_gput:Nnn{\polyglossia at langsetup}{#1/Localnumeral}{##1}
          },
     #1 / Localnumeral.value_required:n = true,
-    #1 / Localnumeral.initial:n = {polyglossia at C@localnumeral}
+    #1 / Localnumeral.initial:n = {polyglossia at C@localnumeral},
+    % environment define command (by default create the environment)
+    #1 / DefineCommandsCmd
+       .code:n = {\prop_gput:Nnn{\polyglossia at langsetup}{#1/DefineCommandsCmd}{##1}},
+    #1 / DefineCommandsCmd
+       .value_required:n = true,
+    #1 / DefineCommandsCmd
+      .initial:n = {xpg_define_language_commands:e}
   }
 }
 
@@ -753,7 +826,10 @@
       }
 }
 
-\AtEndDocument{\prop_log:N{\polyglossia at langsetup}}
+\AtEndDocument{
+  \prop_log:N{\polyglossia at langsetup}
+  \prop_log:N{\__xpg_alias}
+}
 \def\xpg at lastlanguage{0}%
 
 \providebool{xpg at hyphenation@disabled}%
@@ -910,7 +986,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{rm}%
+  }%
   \csgdef{#1 at font@sf}{%
     \cs_if_exist_use:cF{#1fontsf}%
       {
@@ -931,7 +1009,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{sf}%
+  }%
   \csgdef{#1 at font@tt}{%
     \cs_if_exist_use:cF{#1fonttt}%
       {
@@ -952,7 +1032,9 @@
        }%
        \polyglossia at addfontfeature@language:xx{\prop_item:Nn{\polyglossia at langsetup}{#1/langtag}}
                                               {\prop_item:Nn{\polyglossia at langsetup}{#1/language}}
-      }}%
+      }%
+      \def\familytype{tt}%
+  }%
   \endgroup
 }
 
@@ -1008,21 +1090,29 @@
 \newXeTeXintercharclass\xpg at normalclass %TODO
 }{}
 
-\ifxetex
 %% when no patterns are available, we use \l at nohyphenation, assigned to 255
 %%  (suggestion by Enrico Gregorio)
-  \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=255 }{}
-\else\ifluatex
-  \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=\directlua{
-    tex.sprint(polyglossia.newloader_loaded_languages.nohyphenation)}\relax
-  }{}
-\fi\fi
+\str_case_e:nn{\c_sys_engine_str}{
+  {luatex}
+    {
+      \@ifundefined{l at nohyphenation}
+        {\chardef\l at nohyphenation=\directlua{
+           tex.sprint(polyglossia.newloader_loaded_languages.nohyphenation)}\relax
+        }
+        {}
+    }
+  {xetex}
+    {
+      \@ifundefined{l at nohyphenation}{\chardef\l at nohyphenation=255 }{}
+    }
+}
 
+
 %we call this macro when a gloss file is not found for a given language
 \def\xpg at nogloss#1{%
    \xpg at warning{File~ gloss-#1.ldf~ does~ not~ exist!\MessageBreak
    I~ will~ nevertheless~ try~ to~ use~ hyphenation~ patterns~ for~ #1.}%
-  \PolyglossiaSetup{#1}{hyphenmins,hyphennames={#1},fontsetup=true}%
+  \PolyglossiaSetup{#1}{hyphenmins={2,3},hyphennames={#1},fontsetup=true}%
   % the above amounts to:
   %\ifcsundef{l@#1}%
   %  {\expandafter\adddialect\csname l@#1\endcsname\l at nohyphenation\relax}%
@@ -1039,40 +1129,105 @@
   \catcode`\@=\xpg at saved@at at catcode%
 }
 
+%% Load a lde file
+\cs_new_nopar:Nn \__xpg_gloss_ext: {lde}
+\cs_new_nopar:Ne \__xpg_saved_ at pkgextension: {\@pkgextension}
+
+\msg_new:nnn { polyglossia } { directloadgloss }
+{
+  You~ should~ not~ load~ directly~ the~ gloss~ file. ~
+  You~ must~ use~ `\string\setotherlanguage\{#1\}' or  `\string\setmainlanguage\{#1\}'.
+}
+\msg_redirect_name:nnn { polyglossia } { directloadgloss } { critical }
+\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension_error}{m m m m}
+{
+  \msg_critical:nn { polyglossia } { directloadgloss }
+}
+% ProvideExplPackage but for language file
+\cs_new_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
+\cs_new_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
+\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension}{m m m m}
+{
+  \__xpg_saved_ProvidesExplPackage{#1}{#2}{#3}{#4}
+  \cs_gset_eq:NN \@pkgextension \__xpg_saved_ at pkgextension:
+  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
+}
+
+
+% wrapper for loading a gle file
+\NewDocumentCommand{\RequireLanguageDefinitionExtension}{O{} m}
+{
+  \cs_gset_eq:NN \__xpg_saved_ at pkgextension: \@pkgextension
+  \cs_gset_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
+  \cs_gset_eq:NN \@pkgextension \__xpg_gloss_ext:
+  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension
+  \RequirePackage[#1]{gloss-#2}
+  % be paranoiac restore
+  \cs_gset_eq:NN \@pkgextension \__xpg_saved_ at pkgextension:
+  \cs_gset_eq:NN \__xpg_ProvidesLanguageDefinitionExtension_error \ProvideLanguageDefinitionExtension
+}
+
 % try to load a language file
 \cs_new:Nn \polyglossia_load_lang_definition:nn {
-  \file_if_exist:nTF{gloss-#2.ldf}
+  \file_if_exist:eTF{gloss-#2.lde}
   {
-    % Temporarily force catcode of ~ to 13 since babelsh.def
-    % requires it. This is needed particularly with LaTeX3
-    % packages which force \ExplSyntaxOn (#425)
-    \protected\edef\xpg at restore@tilde at catcode{\catcode 126 = \the\catcode 126\relax}
-    \catcode 126 = 13
-    \xpg at input{gloss-#2.ldf}
+    \RequireLanguageDefinitionExtension[#1]{#2}
     \setkeys{#2}{#1}
-    % restore former ~ catcode
-    \xpg at restore@tilde at catcode
   }
   {
-    \xpg at nogloss{#2}
+    \file_if_exist:nTF{gloss-#2.ldf}
+    {
+      % Temporarily force catcode of ~ to 13 since babelsh.def
+      % requires it. This is needed particularly with LaTeX3
+      % packages which force \ExplSyntaxOn (#425)
+      \protected\edef\xpg at restore@tilde at catcode{\catcode 126 = \the\catcode 126\relax}
+      \catcode 126 = 13
+      \xpg at input{gloss-#2.ldf}
+      \setkeys{#2}{#1}
+      % restore former ~ catcode
+      \xpg at restore@tilde at catcode
+    }
+    {
+      \xpg at nogloss{#2}
+    }
   }
 }
+\cs_generate_variant:Nn \polyglossia_load_lang_definition:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 % load a master language from an alias file
 \newcommand*\xpg at load@master at language[1] {
-   \xpg at input{gloss-#1.ldf}
-   \ifcsundef{#1 at loaded}%
-   {
-     \exp_args:Nx\polyglossia at define@language at cmd:n{#1}%
-   }{}
-   \polyglossia at register@language:nn{}{#1}%
-   \csgdef{#1 at loaded}{}%
+  \file_if_exist:eTF{gloss-#1.lde}
+  {
+    \RequireLanguageDefinitionExtension{#1}
+  }
+  {
+    \xpg at input{gloss-#1.ldf}
+  }
+  \seq_if_in:NxF \__xpg_langs_loaded {#1}
+  {
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1} {
+      \use:c{\prop_item:Nn{\polyglossia at langsetup}
+                          {#1/DefineCommandsCmd}}
+                          {#1}
+      }
+  }
+  \polyglossia at register@language:nn{}{#1}%
+  \seq_gput_right:Nn \__xpg_langs_loaded {#1}
 }
 
+\prop_new:N \__xpg_alias
 
-% define environment and command
-\cs_new:Nn \polyglossia at define@language at cmd:n {
-  \ifcsundef{#1 at alias@lang}{%
+% define environment and command if not alias
+\cs_new:Nn \xpg_define_language_commands:n {
+  \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1}
+  {
     \exp_args:Ne
     \newenvironment {\prop_item:Nn{\polyglossia at langsetup}{#1/envname}} [1] []
     {
@@ -1083,130 +1238,213 @@
     }%
     \exp_args:Nc \newcommand {text#1} [2][]
     {%
-      \xpg at textlanguage[##1]{#1}{##2}%
+      \__xpg_textlanguage:een{##1}{#1}{##2}%
     }%
-  }{}
+  }
 }
+\cs_generate_variant:Nn \xpg_define_language_commands:n {e}
 
+\AtBeginDocument{
+  \prop_log:N{\__xpg_alias}
+}
+
+% resolve alias property #1 lang #2 item
+\cs_new:Nn \xpg_alias_prop_item:nn {
+  \prop_if_in:NeTF \__xpg_alias {#1/#2}
+  {
+    \prop_item:Ne \__xpg_alias {#1/#2}
+  }
+  {
+    \prop_if_in:NeTF \__xpg_alias {#1/target}
+    {
+      % target to self fall back to language table
+      \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
+      {
+        \prop_item:Nn{\polyglossia at langsetup} {#1/#2}
+      }
+      % load alias by recursion
+      {
+        \xpg_alias_prop_item:ee { \prop_item:Ne \__xpg_alias {#1/target} } {#2}
+      }
+    }
+    {
+      % empty
+    }
+  }
+}
+\cs_generate_variant:Nn \xpg_alias_prop_item:nn {en, ne, ee}
+
+% add option #2 to list of option of language #1
+\cs_new:Nn \xpg_alias_add_to_option_i:nn
+{
+  \tl_if_blank:eTF {#2}
+  {
+    \xpg_alias_prop_item:nn {#1}{options}
+  }
+  {
+    \tl_if_blank:eTF { \xpg_alias_prop_item:nn {#1}{options} }
+    {
+      #2
+    }
+    {
+      \xpg_alias_prop_item:nn {#1}{options},#2
+    }
+  }
+}
+
+
+% get base language
+\cs_new:Nn \xpg_alias_base_lang:n {
+  \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
+  {
+    #1
+  }
+  {
+    \xpg_alias_base_lang:n {  \prop_item:Ne \__xpg_alias {#1/target} }
+  }
+}
+\cs_generate_variant:Nn \xpg_alias_base_lang:n {e}
+
+\keys_define:nn { polyglossia/alias }
+{
+  % babelname\l_tmpa_prop
+  babelname .prop_put:N = \__xpg_language_alias_prop,
+  % bcp47
+  bcp47 .prop_put:N = \__xpg_language_alias_prop,
+  % variant
+  variant .prop_put:N = \__xpg_language_alias_prop,
+}
+
+
+
 % provide way to define alias environment and command
+% #1 () variant
+% #2 [] option (not yet without variant and bcp47 name)
+% #3 language
+% #4 () babel name
+% #5 [] bcp47 name
+% #6 alias
+\DeclareDocumentCommand \xpg_language_alias { D(){} O{} m D(){} O{} m}
+{
+  \prop_gremove:Nn \__xpg_alias {#6/target}
+  \prop_gremove:Nn \__xpg_alias {#6/options}
+  \prop_gremove:Nn \__xpg_alias {#6/bcp47}
+  \prop_gremove:Nn \__xpg_alias {#6/babelname}
+  \prop_gremove:Nn \__xpg_alias {#6/variant}
+  \prop_gput:Nee \__xpg_alias {#6/target} {#3}
+  \tl_if_blank:eF {#1}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/variant} {#1}
+  }
+  \tl_if_blank:eF {#5}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/bcp47} {#5}
+  }
+  \tl_if_blank:eF {#4}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/babelname} {#1}
+  }
+  \tl_if_blank:eF {#2}
+  {
+    \prop_gput:Nee \__xpg_alias {#6/options} {#2}
+  }
+}
+
+
+% provide way to define alias environment and command
 % \setlanguagealias[<options>]{<language>}{<alias>}
 \DeclareDocumentCommand \setlanguagealias {s O{} m m}
 {
   % The starred version does not define commands and environments
   \IfBooleanF {#1}
+  {
+    \exp_args:Nc \providecommand {text#4} [2][] {}
+    \exp_args:Nc \renewcommand {text#4} [2][]
     {
-     \ifcsundef{#4 at alias@lang}{%
-       \exp_args:Ne
-       \newenvironment {#4}
-       {
-         \begin{otherlanguage}[#2]{#3}
-       }%
-       {
-         \end{otherlanguage}
-       }%
-       \exp_args:Nc \newcommand {text#4} [2][]
-       {%
-         \xpg at textlanguage[#2,##1]{#3}{##2}%
-       }%
-     }{%
-       \exp_args:Ne
-       \renewenvironment {#4}
-       {
-         \begin{otherlanguage}[#2]{#3}
-       }%
-       {
-         \end{otherlanguage}
-       }%
-       \exp_args:Nc \renewcommand {text#4} [2][]
-       {%
-         \xpg at textlanguage[#2,##1]{#3}{##2}%
-       }%
-     }%
+      \__xpg_textlanguage:een{##1}{#4}{##2}
+    }
+    \exp_args:Nc \providecommand {#4} {}
+    \exp_args:Ne  \renewenvironment {#4}
+    {
+      \begin{otherlanguage}{#4}
+    }
+    {
+      \end{otherlanguage}
+    }
   }%
-  \csgdef{#4 at alias@lang}{#3}%
-  \tl_if_blank:nF {#2} {\csgdef{#4 at alias@opts}{#2}}%
+  \tl_clear_new:N \__xpg_alias_option_tl
+  \prop_clear_new:N \__xpg_language_alias_prop
+  \keys_set_known:nnN{polyglossia/alias} {#2} \__xpg_alias_option_tl
+  \xpg_language_alias
+    (\prop_item:Nn \__xpg_language_alias_prop {variant})
+    % TODO not yet [\__xpg_alias_option_tl]
+    [#2]
+    {#3}
+    (\prop_item:Nn \__xpg_language_alias_prop {babelname})
+    [\prop_item:Nn \__xpg_language_alias_prop {bcp47}]
+    {#4}
 }
 
 \cs_new:Nn \polyglossia at register@language:nn {
-   % register polyglossia language name
-   \ifcsundef{#2 at registered}{%
-       \global\edef\xpg at loaded{%
-           \ifx\xpg at loaded\@empty\else\xpg at loaded,\fi #2%
-        }%
-   }{}
-   \csgdef{#2 at registered}{}%
-   \tl_if_blank:nF {#1}{%
-      % Register the language options
-      \polyglossia at set@lang at options:nn {#2} {#1}%
-   }%
-   % register babelname
-   \def\xpg at tmp@babelname{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}}%
-   \ifcsundef{\csname xpg at tmp@babelname\endcsname @bbl at registered}{%
-       \global\edef\xpg at bloaded{%
-           \ifx\xpg at bloaded\@empty\else\xpg at bloaded,\fi\xpg at tmp@babelname}%
-   }{}%
-   \csgdef{\csname xpg at tmp@babelname\endcsname @bbl at registered}{}%
-   % register BCP-47 ID
-   \def\xpg at tmp@bcpname{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
-   \ifcsundef{\csname xpg at tmp@bcpname\endcsname @bcp at registered}{%
-       \global\edef\xpg at bcp@loaded{%
-           \ifx\xpg at bcp@loaded\@empty\else\xpg at bcp@loaded,\fi\xpg at tmp@bcpname}%
-   }{}%
-   \csgdef{\csname xpg at tmp@bcpname\endcsname @bcp at registered}{}%
+  \clist_if_in:NeF \xpg at loaded {#2}{
+    \clist_gput_right:Ne \xpg at loaded {#2}
+  }
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at set@langvariant}
+  % register babelname
+  \prop_get:NeN \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
+  \clist_if_in:NeF \xpg at bloaded {\l_tmpa_tl}{
+    \clist_gput_right:Ne \xpg at bloaded {\l_tmpa_tl}
+  }
+  % register BCP-47 ID
+  \prop_get:NeN \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
+  \clist_if_in:NeF \xpg at bcp@loaded {\l_tmpa_tl}{
+    \clist_gput_right:Ne \xpg at bcp@loaded {\l_tmpa_tl}
+  }
 }
 
-
 \newcommand{\setdefaultlanguage}[2][]{%
   % latex is an internal language, so do not record
-  \ifstrequal{#2}{latex}{}{%
-     % register polyglossia language name
-     \ifcsundef{#2 at registered}{%
-       \global\edef\xpg at loaded{%
-           \ifx\xpg at loaded\@empty\else\xpg at loaded,\fi #2%
-        }%
-     }{}%
-     \csgdef{#2 at registered}{}%
-  }%
-  \ifcsundef{#2 at loaded}%
+  \str_if_eq:eeF{#2}{latex}
   {
-    \polyglossia_load_lang_definition:nn{#1}{#2}
-    % define environment and command (except for internal latex language)
-    \ifstrequal{#2}{latex}{}{%
-      \exp_args:Nx\polyglossia at define@language at cmd:n{#2}
-    }%
-    \csgdef{#2 at loaded}{}%
+    \clist_if_in:NeF \xpg at loaded {\xpg_alias_base_lang:n{##2}}{
+      \clist_gput_right:Ne \xpg at loaded {\xpg_alias_base_lang:n{##2}}
+    }
   }
+  \seq_if_in:NxF \__xpg_langs_loaded {#2}
   {
-    \relax
+    \polyglossia_load_lang_definition:nn{#1}{#2}
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
+       \use:c{\prop_item:Nn{\polyglossia at langsetup}
+            {#2/DefineCommandsCmd}}
+            {#2}
+    }
+    \seq_gput_right:Nn \__xpg_langs_loaded {#2}
   }
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia_load_lang_definition:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-       \exp_args:Nxx \polyglossia at set@default at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       \polyglossia at set@default at language:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    \polyglossia at set@default at language:nn {#1} {#2}%
-  }%
+  \polyglossia at set@default at language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+    {\xpg_alias_base_lang:n{#2}}%
 }
 
+
 \cs_new:Nn \polyglossia at set@default at language:nn
 {
   \gdef\xpg at main@language{#2}%
-  \tl_if_blank:nTF {#1}{\gdef\mainlanguagevariant{}}{%
+  \tl_if_blank:nTF {#1}
+  {
+    \cs_gset_nopar:Npn \mainlanguagevariant {}
+  }
+  {%
      % Register the language options
-     \polyglossia at set@lang at options:nn {#2} {#1}%
+     \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at main@langvariant}%
   }%
   \csgdef{#2 at gvar}{\mainlanguagevariant}%
   %% The following settings are for the default language and script
   % this tells bidi.sty or luabidi.sty that the document is RTL
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}{%
-    \str_case_e:nnF{\c_sys_engine_str}{%
-      {luatex}{\setRTLmain}
-      {xetex}{\@RTLmaintrue\setnonlatin}
-    }{}%
-  }{}%
+  \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+  {
+    \__xpg_setRTLmain:
+  }
   \cs_gset_nopar:Nn \polyglossia at AtBeginDocument@selectlanguage: {
     \selectbackgroundlanguage{#2}
     \selectlanguage[#1]{#2}%
@@ -1213,27 +1451,30 @@
   }
   \xpg at info{Default~ language~ is~ #2}%
   \polyglossia at set@language at name[#1]{#2}%
-  \def\mainlanguagename{#2}
+
+  \cs_gset_nopar:Npn \mainlanguagename {#2}
   % Store babelname of main language (for external packages such as biblatex)
-  \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
-      { \edef\mainbabelname{\l_tmpa_tl} }
+  \cs_gset_nopar:Npe \mainbabelname { \prop_item:Nn  \polyglossia at langsetup {#2/babelname} }
   % Store babelname of current language (for external packages such as biblatex)
-  \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
-      { \edef\babelname{\l_tmpa_tl}% 
-        \cs_gset_eq:cc{#2 at gbabelname}{babelname}%
-      }
+  \cs_gset_eq:NN \babelname \mainbabelname
+  \cs_gset_eq:cc{#2 at gbabelname}{babelname}%
   % Store BCP-47 id of main language
-  \prop_get:NxNT \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
-      { \csedef{mainbcp47id}{\l_tmpa_tl} }
-  % Store BCP-47 id of current language
-  \prop_get:NxNT \polyglossia at langsetup {#2/bcp47} \l_tmpa_tl
-      { \csedef{bcp47id}{\l_tmpa_tl}% 
-        \cs_gset_eq:cc{#2 at gbcp47id}{bcp47id}%
-      }
-  \ifluatex %
-  \directlua{polyglossia.set_default_language('\luatexluaescapestring{\string#2}')}%
-  \fi %
+  \cs_gset_nopar:cpe {mainbcp47id} { \prop_item:Nn  \polyglossia at langsetup {#2/bcp47} }
+  \cs_gset_eq:cc {bcp47id} {mainbcp47id}
+  \cs_gset_eq:cc{#2 at gbcp47id}{bcp47id}
+
+ \sys_if_engine_luatex:T
+   {
+     \directlua{polyglossia.set_default_language('\luatexluaescapestring{\string#2}')}%
+   }
 }
+\cs_generate_variant:Nn\polyglossia at set@default at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 \let\setmainlanguage=\setdefaultlanguage
 
@@ -1241,12 +1482,11 @@
 % Currently supported: bcp-47
 \DeclareDocumentCommand \languageid {m}
 {
-    \str_case:nnTF {#1}
+    \str_case:nnF {#1}
       {
         {bcp-47}    { \csuse{bcp47id} }
         {bcp47}     { \csuse{bcp47id} }
       }
-      {}
       {
         \xpg at error{Invalid~ \string\languageid\space argument:~ #1}
       }
@@ -1256,25 +1496,26 @@
 % Currently supported: bcp-47
 \DeclareDocumentCommand \mainlanguageid {m}
 {
-    \str_case:nnTF {#1}
+    \str_case:nnF {#1}
       {
         {bcp-47}    { \csuse{mainbcp47id} }
         {bcp47}     { \csuse{mainbcp47id} }
       }
-      {}
       {
         \xpg at error{Invalid~ \string\mainlanguageid\space argument:~ #1}
       }
 }
-
-\def\mainbabelname{}%
-\def\mainlanguagevariant{}%
+% main babel name
+\cs_new_nopar:Npn \mainlanguagename {}
+\cs_new_nopar:Npn \mainbabelname {}
+\cs_new_nopar:cpn {mainbcp47id} {}
+\cs_new_nopar:Npn \mainlanguagevariant {}%
 % Store main language variant for external packages
 \define at key{xpg at main@langvariant}{variant}{%
-  \gdef\mainlanguagevariant{#1}%
+  \cs_gset_nopar:Npn \mainlanguagevariant {#1}%
 }
 
-\def\babelname{}%
+\cs_new_nopar:Npn \babelname {}
 \def\languagevariant{}%
 % Store current language variant for external packages
 \define at key{xpg at set@langvariant}{variant}{%
@@ -1287,21 +1528,16 @@
      \ifcsundef{#2 at gvar}{\def\languagevariant{}}{\def\languagevariant{\csuse{#2 at gvar}}}
    }{%
      % Register the language options
-     \polyglossia at set@lang at options:nn {#2} {#1}%
+     \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at set@langvariant}%
+     \cs_set_eq:cc{#2 at gvar}{languagevariant}%
   }%
 }
 
 
 \newcommand*{\resetdefaultlanguage}[2][]{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at reset@default at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       polyglossia at reset@default at language:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    polyglossia at reset@default at language:nn {#1} {#2}%
-  }%
+  \polyglossia at reset@default at language:nn
+    {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+    {\xpg_alias_base_lang:n{#2}}%
 }
 
 \cs_new:Nn \polyglossia at reset@default at language:nn
@@ -1315,7 +1551,10 @@
   \cs_if_exist_use:c{noextras at bbl@\mainbabelname}%
   \csuse{init at noextras@\xpg at main@language}%
   \polyglossia at set@language at name[#1]{#2}%
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}{\@rlmaintrue\@rl at footnotetrue}{}%
+  \__xpg_if_LR_str:eF{\prop_item:Ne{\polyglossia at langsetup}{#2/direction}}
+  {
+    \@rlmaintrue\@rl at footnotetrue
+  }
   \selectlanguage[#1]{#2}%
   \selectbackgroundlanguage{#2}%
   % Store babelname of current language (for external packages such as biblatex)
@@ -1339,6 +1578,13 @@
     \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
   }%
 }
+\cs_generate_variant:Nn \polyglossia at reset@default at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
 % This saves the normalfont for the latin script since we may change normalfont in other scripts
 \let\normalfontlatin=\normalfont%
@@ -1420,15 +1666,18 @@
 \def\xpg at select@fontfamily#1{%
   \def\tmp at tt{tt}\def\tmp at sf{sf}%
   \ifx\familytype\tmp at tt
-    \csuse at warn{#1 at font@tt}%
+    \__xpg_use_or_warn:c{#1 at font@tt}%
   \else\ifx\familytype\tmp at sf
-    \csuse at warn{#1 at font@sf}%
-      \else\csuse at warn{#1 at font@rm}\fi\fi}
+    \__xpg_use_or_warn:c{#1 at font@sf}%
+      \else\__xpg_use_or_warn:c{#1 at font@rm}\fi\fi}
 
 \def\xpg at set@normalfont#1{%
-  \DeclareRobustCommand\rmfamily{\csuse{#1 at font@rm}}%
-  \DeclareRobustCommand\sffamily{\csuse{#1 at font@sf}}%
-  \DeclareRobustCommand\ttfamily{\csuse{#1 at font@tt}}%
+  \letcs{\rmfamily}{#1 at font@rm}%
+  \letcs{\sffamily}{#1 at font@sf}%
+  \letcs{\ttfamily}{#1 at font@tt}%
+  \robustify\rmfamily%
+  \robustify\sffamily%
+  \robustify\ttfamily%
   \gdef\normalfont{\protect\xpg at select@fontfamily{#1}%
                    \fontseries{\seriesdefault}\selectfont%
                    \fontshape{\shapedefault}
@@ -1447,14 +1696,10 @@
     \@afterindentfalse%
 }
 
-\newcommand*{\selectbackgroundlanguage}[1]{%
-  \ifcsdef{#1 at alias@lang}{%
-     \polyglossia at select@background at language:n {\csuse{#1 at alias@lang}}%
-  }{%
-     \polyglossia at select@background at language:n {#1}%
-  }%
+\cs_new_nopar:Npn \selectbackgroundlanguage #1
+{%
+  \polyglossia at select@background at language:n {\xpg_alias_base_lang:n{#1}}
 }
-
 \cs_new:Nn \polyglossia at select@background at language:n
 {
   \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/lcscript}}{latin}
@@ -1462,26 +1707,23 @@
                    {\xpg at set@normalfont{#1}}%
   \csuse{#1 at globalnumbers}%
 }
-
-\newcommand{\setotherlanguage}[2][]{%
-  \ifcsundef{#2 at loaded}
+\cs_generate_variant:Nn \polyglossia at select@background at language:n {e}
+%  Declare secondary language #2 with language options #1
+\DeclareDocumentCommand \setotherlanguage { O{} m }
+{
+  \seq_if_in:NxF \__xpg_langs_loaded {#2}
   {
-    \polyglossia_load_lang_definition:nn{#1}{#2}
-    % define environment and command
-    \exp_args:Nx\polyglossia at define@language at cmd:n{#2}
-    \ifcsdef{#2 at alias@lang}{%
-       \ifcsdef{#2 at alias@opts}{%
-         \exp_args:Nxx \polyglossia_load_lang_definition:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-         \exp_args:Nxx \polyglossia at set@other at language:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-       }{%
-         \polyglossia at set@other at language:nn {#1} {\csuse{#2 at alias@lang}}%
-       }%
-    }{%
-      \polyglossia at set@other at language:nn {#1} {#2}%
-    }%
-    \csgdef{#2 at loaded}{}%
+    \polyglossia_load_lang_definition:ee {#1} {#2}%
+    % define environment and command if not alias
+    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
+       \use:c{\prop_item:Nn{\polyglossia at langsetup}
+             {#2/DefineCommandsCmd}}
+             {#2}
+    }
+    \polyglossia at set@other at language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
+      {\xpg_alias_base_lang:n{#2}}%
+    \seq_gput_right:Nn \__xpg_langs_loaded {#2}
   }
-  {}
 }
 
 \cs_new:Nn \polyglossia at set@other at language:nn
@@ -1489,16 +1731,23 @@
   \polyglossia at register@language:nn{#1}{#2}%
   % If a variant is set, store it.
   \gdef\otherlanguagevariant{}
-  \tl_if_blank:nTF {#1}{}{%
-    % Register the language options
-    \polyglossia at set@lang at options:nn {#2} {#1}%
-  }%
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#2} {#1} {@xpg at other@langvariant}%
+
   \csgdef{#2 at gvar}{\otherlanguagevariant}%
   \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
     { \xdef\otherlanguagebabelname{\l_tmpa_tl} }
   \cs_gset_eq:cc{#2 at gbabelname}{otherlanguagebabelname}%
 }
+\cs_generate_variant:Nn  \polyglossia at set@other at language:nn {
+  ee, ef, en, eo, ex,
+  fe, ff, fn, fo, fx,
+  ne, nf,     no, nx,
+  oe, of, on, oo, ox,
+  xe, xf, xn, xo, xx
+}
 
+
 % Store main language variant for external packages
 \define at key{xpg at other@langvariant}{variant}{%
   \gdef\otherlanguagevariant{#1}%
@@ -1527,15 +1776,7 @@
 % where \text<alias> would cause clashes
 % (e.g., \textit)
 \newcommand\textlang[3][]{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \xpg at textlanguage[\csuse{#2 at alias@opts},#1]{\csuse{#2 at alias@lang}}{#3}%
-     }{%
-       \xpg at textlanguage[#1]{\csuse{#2 at alias@lang}}{#3}%
-     }%
-  }{%
-    \xpg at textlanguage[#1]{#2}{#3}%
-  }%
+  \__xpg_textlanguage:een {#1} {#2} {#3}
 }%
 
 % Alias to {<lang>}, but more suitable
@@ -1578,6 +1819,8 @@
 
 % joint code of \foreignlanguage, otherlanguage*
 % and \text<lang>
+% #1 option
+% #2 language
 \newcommand{\xpg at otherlanguage}[2][]
 {%
   \polyglossia at error@iflangnotloaded:n{#2}
@@ -1593,67 +1836,91 @@
 }
 
 \renewcommand{\foreignlanguage}[3][]
-{%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at foreignlanguage:nnn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}} {#3}%
-     }{%
-       \polyglossia at foreignlanguage:nnn {#1} {\csuse{#2 at alias@lang}} {#3}%
-     }%
-  }{%
-    \polyglossia at foreignlanguage:nnn {#1} {#2} {#3}%
-  }%
+{
+  \__xpg_foreignlanguage:eeen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
 }
 
-\cs_new:Nn \polyglossia at foreignlanguage:nnn
+% internal wrapper for foreing language
+% #1 option
+% #2 alias
+% #3 base lang
+% #3 text
+\cs_new:Nn \__xpg_foreignlanguage:nnnn
 {
-   \polyglossia at error@iflangnotloaded:n{#2}
-   \bgroup
-   \xpg at otherlanguage[#1]{#2}%
-   \polyglossia at lang@settextdirection:nn{#2}{#3}%
-   \egroup
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \group_begin:
+    \xpg at otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#4}%
+    \polyglossia at lang@settextdirection:nn{#3}{#4}%
+  \group_end:
 }
+\cs_generate_variant:Nn \__xpg_foreignlanguage:nnn {een}
 
+
 % otherlanguage* is the environment equivalent of \foreignlanguage
 \expandafter\providecommand\csname otherlanguage*\endcsname{}
 
 \renewenvironment{otherlanguage*}[2][]
 {%
-  \ifcsdef{#2 at alias@lang}{%
-     \ifcsdef{#2 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at otherlanguage:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
-     }{%
-       \polyglossia at otherlanguage:nn {#1} {\csuse{#2 at alias@lang}}%
-     }%
-  }{%
-    \polyglossia at otherlanguage:nn {#1} {#2}%
-  }%
+  \__xpg_otherlanguage:eee {#1} {#2} {\xpg_alias_base_lang:n{#2}}
 }
-{\egroup}
+{\group_end:}
 
-\cs_new:Nn \polyglossia at otherlanguage:nn
+% internal wrapper
+% #1 option
+% #2 alias
+% #3 base lang
+\cs_new:Nn \__xpg_otherlanguage:nnn
 {
-  \xpg at otherlanguage[#1]{#2}%
-  \polyglossia at lang@settextdirection:nn{#2}\bgroup%
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \xpg at otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#3}%
+  \polyglossia at lang@settextdirection:nn{#3}\group_begin:%
 }
+\cs_generate_variant:Nn \__xpg_otherlanguage:nnn {
+  eee
+}
 
 % use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
 % except that dates are localized.
-\newcommand\xpg at textlanguage[3][]{%
-  \polyglossia at error@iflangnotloaded:n{#2}
-   \bgroup
-   \xpg at otherlanguage[#1]{#2}%
-   \csuse{date#2}%
-   % This is a hook for external packages which want to access variants
-   % via babelname (such as biblatex)
-   \cs_if_exist_use:c{date at bbl@\babelname}%
-   \polyglossia at lang@settextdirection:nn{#2}{#3}%
-   \egroup
+% #1: option
+% #2: alias
+% #3: text
+\cs_new:Nn \__xpg_textlanguage:nnn
+{
+  \__xpg_textlanguage:nnen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
+}
+\cs_generate_variant:Nn \__xpg_textlanguage:nnn {een}
+
+% use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
+% except that dates are localized.
+% #1: option
+% #2: alias
+% #3: base language
+% #4: text
+\cs_new:Nn \__xpg_textlanguage:nnnn
+{
+  \tl_if_blank:nT {#3}
+  {
+    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
+  }
+  \group_begin:
+    \xpg at otherlanguage[#1]{#3}%
+    \csuse{date#3}%
+    % This is a hook for external packages which want to access variants
+    % via babelname (such as biblatex)
+    \cs_if_exist_use:c{date at bbl@\babelname}%
+    \polyglossia at lang@settextdirection:nn{#3}{#4}%
+  \group_end:
   % Reset the language's/script's font families
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}}{latin}{}{\resetfontlatin}%
+  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#3/lcscript}}{latin}{}{\resetfontlatin}%
 }
+\cs_generate_variant:Nn \__xpg_textlanguage:nnnn {nnen}
 
-
 % Define language-specific hyphenation exceptions
 \newcommand\pghyphenation[3][]{
   \bgroup
@@ -1675,51 +1942,52 @@
   \let\emp at langname\@undefined}
 
 \DeclareDocumentCommand \selectlanguage {s O{} m}
-{%
-  \ifcsdef{#3 at alias@lang}{%
-     \ifcsdef{#3 at alias@opts}{%
-       \exp_args:Nxx \polyglossia at select@language:nnn {#1} {\csuse{#3 at alias@opts},#2} {\csuse{#3 at alias@lang}}%
-     }{%
-       \polyglossia at select@language:nnn {#1} {#2} {\csuse{#3 at alias@lang}}%
-     }%
-  }{%
-     \polyglossia at error@iflangnotloaded:n{#3}%
-     \polyglossia at select@language:nnn {#1} {#2} {#3}%
-  }
+{
+  \__xpg_msg_if_lang_not_loaded:n {#3}
+  \polyglossia at select@language:nee {#1}
+    {\xpg_alias_add_to_option_i:nn{#3}{#2}}
+    {\xpg_alias_base_lang:n{#3}}
 }
 
 \cs_new:Nn \polyglossia at select@language:nnn
 {
   \IfBooleanF {#1}
-    {
-      \cs_set_nopar:Npx \xpg at pop@language { \exp_not:N \xpg at pop@language at i {#2} {#3} }
-      \group_insert_after:N \xpg at pop@language
-    }
-  \tl_if_blank:nTF {#2}{}{%
-    % Register the language options
-    \polyglossia at set@lang at options:nn {#3} {#2}%
-   }%
-   % The starred variant does not write to the aux
-   \IfBooleanTF#1{%
-     \xpg at set@language at nonaux[#2]{#3}%
-   }{%
-     \xpg at set@language at aux[#2]{#3}%
-   }%
-   \ifluatex%
-     \directlua{polyglossia.select_language('\luatexluaescapestring{\string#3}',
-                     \the\csname l@#3\endcsname)}%
-   \fi%
+  {
+    \cs_set_nopar:Npx \xpg at pop@language { \exp_not:N \xpg at pop@language at i {#2} {#3} }
+    \group_insert_after:N \xpg at pop@language
+  }
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {#3} {#2} {@xpg at set@langvariant}%
+  % The starred variant does not write to the aux
+  \IfBooleanTF#1{%
+    \xpg at set@language at nonaux[#2]{#3}%
+  }
+  {%
+    \xpg at set@language at aux[#2]{#3}%
+  }%
+  \sys_if_engine_luatex:T
+  {
+    \directlua{polyglossia.select_language('\luatexluaescapestring{\string#3}',
+      \the\csname l@#3\endcsname)}%
+  }
   \polyglossia at register@language:nn{#2}{#3}%
 }
+\cs_generate_variant:Nn \polyglossia at select@language:nnn {
+ nee, nne
+}
 
 
-\cs_new:Nn \polyglossia at set@lang at options:nn
-{  
+% set lang option #2 for lang #1
+\cs_new:Nn \polyglossia at set@lang at options:nnn
+{
+  \tl_if_blank:nF {#2}
+  {
     % If the optional argument sets a value for the key “variant”, copy it to xpg at langvariant
     \clist_map_inline:nn { #2 } {%
-        \xpg at parsevariantkeyvalue##1=@xpg at langvariant:#1\relax
+      \xpg at parsevariantkeyvalue##1=#3:#1\relax
     }%
     \exp_args:Nne \setkeys{#1}{#2}%
+  }
 }
 
 % Initialize default language options, so that
@@ -1726,7 +1994,7 @@
 % \iflanguageoption has the info it needs also
 % for default settings
 \newcommand*\xpg at initialize@gloss at options[2]{%
-   \polyglossia at set@lang at options:nn {#1} {#2}%
+   \polyglossia at set@lang at options:nnn {#1} {#2} {@xpg at set@langvariant}%
 }
 
 % Record synonymous keyvals such as variant=us and variant=american
@@ -1776,16 +2044,16 @@
 {
   \prop_get:cnNTF {xpg at current@options@#1} {#2} \l_tmpa_tl
      {
-        \exp_args:Nee \str_if_eq:NNTF{\l_tmpa_tl}{#3}
+       \str_if_eq:eeTF{\l_tmpa_tl}{#3}
           {\prg_return_true:}
           {
             \prop_get:cnNTF {xpg at alias@keyvals@#1@#3} {#2} \l_tmpb_tl
                {
-                \exp_args:Nne \clist_set:Nn{\l_tmpa_clist}{\l_tmpb_tl}
+                \clist_set:Ne{\l_tmpa_clist}{\l_tmpb_tl}
                 \providetoggle{xpgvalfound}
                 \togglefalse{xpgvalfound}
                 \clist_map_inline:Nn \l_tmpa_clist {
-                   \exp_args:Nee \str_if_eq:NNT{##1}{\l_tmpa_tl}
+                   \str_if_eq:eeT{##1}{\l_tmpa_tl}
                       { \toggletrue{xpgvalfound} }
                 }
                 \iftoggle{xpgvalfound}{\prg_return_true:}{\prg_return_false:}
@@ -1808,39 +2076,39 @@
 
 % Append any variant to csv list of variants
 \define at key{xpg at langvariant}{variant}{%
-  \edef\xpg at vloaded{#1\ifx\xpg at vloaded\@empty\else,\xpg at vloaded\fi}%
-}
-
-\prg_set_conditional:Npnn \polyglossia at check@if at lang@loaded:N #1 { p , T , F , TF }{
-  \cs_if_exist:cTF{#1}{
-     \prg_return_true:
-  }{
-    \prg_return_false:
+  \clist_if_in:NeF \xpg at vloaded {#1}{
+    \clist_gput_right:Ne \xpg at vloaded {#1}
   }
 }
 
 % Test if language is loaded
 \newcommand*\iflanguageloaded[3]{%
-  \polyglossia at check@if at lang@loaded:NTF{#1 at loaded}{#2}{#3}%
+   \AddToHook{begindocument/end}{%
+     \clist_if_in:NeTF \xpg at loaded{#1}{#2}{#3}%
+   }%
 }
 
 % Same for babellanguage is loaded
 \newcommand*\ifbabellanguageloaded[3]{%
-  \polyglossia at check@if at lang@loaded:NTF{#1 at bbl@loaded}{#2}{#3}%
+  \AddToHook{begindocument/end}{%
+     \clist_if_in:NeTF \xpg at bloaded{#1}{#2}{#3}%
+  }%
 }
 
 % Same for languageid
 \DeclareDocumentCommand \iflanguageidloaded {mmmm}
 {
+  \AddToHook{begindocument/end}{%
     \str_case:nnTF {#1}
       {
-        {bcp-47}    { \polyglossia at check@if at lang@loaded:NTF{#2 at bcp@loaded}{#3}{#4} }
-        {bcp47}     { \polyglossia at check@if at lang@loaded:NTF{#2 at bcp@loaded}{#3}{#4} }
+        {bcp-47}    { \clist_if_in:NeTF \xpg at bcp@loaded{#2}{#3}{#4} }
+        {bcp47}     { \clist_if_in:NeTF \xpg at bcp@loaded{#2}{#3}{#4} }
       }
       {}
       {
         \xpg at error{Invalid~ \string\iflanguageidloaded\space argument:~ #1}
       }
+   }%
 }
 
 % Check if the current font has a given glyph
@@ -1859,8 +2127,10 @@
            }
   }
   {
-    \xpg at warning{You’re running a TeX engine that is not LuaTeX or XeTeX.\MessageBreak
-                 That is almost guaranteed to cause problems.}
+    \xpg at warning{You’re ~ running ~ a ~ TeX engine ~ that ~ is ~
+      not ~ LuaTeX ~ or ~ XeTeX.\MessageBreak
+      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
+    \prg_return_false:
   }
 }
 
@@ -1902,6 +2172,11 @@
    }%
    \@select at language[#1]{#2}%
     % Write to the aux
+   \xpg at set@language at only@aux[#1]{#2}%
+}
+
+\newcommand*{\xpg at set@language at only@aux}[2][]{%
+    % Write to the aux
    \if at filesw%
       \ifx#1\\\\%
           \protected at write\@auxout{}{\protect\selectlanguage*{#2}}%
@@ -1933,45 +2208,8 @@
   }{}%
 }
 
-% Open a group in the aux file. This is to keep
-% nested language options local (see #320).
-% In bidi tables, the opening/closing needs to be swapped (see #354)
-\newcommand*{\xpg at set@group at aux}{%
-   \if at filesw%
-      \ifbool{xpg at inbiditable}{%
-        \protected at write\@auxout{}{\egroup}%
-        \addtocontents{toc}{\egroup}%
-        \addtocontents{lof}{\egroup}%
-        \addtocontents{lot}{\egroup}%
-      }{%
-        \protected at write\@auxout{}{\bgroup}%
-        \addtocontents{toc}{\bgroup}%
-        \addtocontents{lof}{\bgroup}%
-        \addtocontents{lot}{\bgroup}%
-      }%
-    \fi
-}
-
-% Close the group in the aux file.
-% In bidi RTL tables, the opening/closing needs
-% to be swapped (see #354).
-\newcommand*{\xpg at unset@group at aux}{%
-   \if at filesw%
-      \ifbool{xpg at inbiditable}{%
-        \protected at write\@auxout{}{\bgroup}%
-        \addtocontents{toc}{\bgroup}%
-        \addtocontents{lof}{\bgroup}%
-        \addtocontents{lot}{\bgroup}%
-      }{%
-        \protected at write\@auxout{}{\egroup}%
-        \addtocontents{toc}{\egroup}%
-        \addtocontents{lof}{\egroup}%
-        \addtocontents{lot}{\egroup}%
-      }%
-    \fi
-}
-
-\prg_set_conditional:Npnn \polyglossia at check@ifdefined:N #1 { p , T , F , TF }{
+% check if language is defined
+\prg_set_conditional:Npnn \__xpg_check_if_exist_l@:N #1 { p , T , F , TF }{
   \cs_if_exist:cTF {l@#1}
     {
       \cs_if_eq:cNTF {l@#1} \l at nohyphenation
@@ -1993,21 +2231,22 @@
 \def\polyglossia at luatex@load at lang#1{%
   % if \l@#1 is not properly defined, call lua function newloader(#1),
   % and assign the returned number to \l@#1
-  \polyglossia at check@ifdefined:NF {#1}
-    {
-      \expandafter\chardef\csname l@#1\endcsname=
-        \directlua{ tex.sprint(polyglossia.newloader'#1') }\relax
-    }
+  \__xpg_check_if_exist_l@:NF {#1}
+  {
+    \expandafter\chardef\csname l@#1\endcsname=
+    \directlua{ tex.sprint(polyglossia.newloader'#1') }\relax
+  }
 }
 
 % This check is also used by biblatex, so don't
 % rename silently.
 \newcommand\xpg at ifdefined[3]{%
-    % With luatex, we first need to define \l@#1.
-    \ifluatex
-      \polyglossia at luatex@load at lang{#1}%
-    \fi
-    \polyglossia at check@ifdefined:NTF{#1}{#2}{#3}%
+  % With luatex, we first need to define \l@#1.
+  \sys_if_engine_luatex:T
+  {
+    \polyglossia at luatex@load at lang{#1}%
+  }
+  \__xpg_check_if_exist_l@:NTF{#1}{#2}{#3}%
 }%
 
 % Set \bbl at hyphendata@\the\language, which is (lua)babel's
@@ -2014,27 +2253,32 @@
 % hyphenation pattern hook
 % FIXME Clarifiy why/when this is needed.
 \newcommand*\xpg at set@bbl at hyphendata[1]{%
-    \ifluatex%
-        \ifcsdef{bbl at hyphendata@#1}{}{%
-            \global\@namedef{bbl at hyphendata@\the\language}{}%
-        }%
-    \fi% 
+  \sys_if_engine_luatex:T
+  {
+    \ifcsdef{bbl at hyphendata@#1}{}{%
+      \global\@namedef{bbl at hyphendata@\the\language}{}%
+    }%
+  }
 }
 
 % Set hyphenation patterns for a given language. This does the right
 % thing both for XeTeX and LuaTeX
 \newcommand*\xpg at set@hyphenation at patterns[1]{%
-  \ifluatex
-    \polyglossia at luatex@load at lang{#1}%
-    \language=\csname l@#1\endcsname
-  \else
-    \ifxetex
-      \language=\csname l@#1\endcsname
-    \else
+  \str_case_e:nnF{\c_sys_engine_str}{
+      {luatex}
+        {
+          \polyglossia at luatex@load at lang{#1}%
+          \language=\csname l@#1\endcsname
+        }
+      {xetex}
+        {
+          \language=\csname l@#1\endcsname
+        }
+    }
+    {
       \xpg at warning{You’re~running~a~TeX~engine~that~is~not~LuaTeX~or~XeTeX.\MessageBreak
         That~is~almost~guaranteed~to~cause~problems.}%
-    \fi
-  \fi
+    }
 }
 
 
@@ -2071,38 +2315,46 @@
 % Hook for external packages such as biblatex
 \def\polyglossia at language@switched{}
 
-\def\noextrascurrent#1{%
-   \csuse{noextras@#1}%
-   % This is a hook for external packages which want to access variants
-   % via babelname (such as biblatex)
-   \cs_if_exist_use:c{noextras at bbl@\babelname}
+% remove all custumization for language #1
+\cs_new:Npn \noextrascurrent #1
+{%
+  \cs_if_exist_use:c{noextras@#1}%
+  % This is a hook for external packages which want to access variants
+  % via babelname (such as biblatex)
+  \cs_if_exist_use:c{noextras at bbl@\babelname}
 }
 
 % Common code for `\select at language' and `\foreignlanguage'.
 \newcommand{\select@@language}[2][]{%
   % disable the extras and number settings of the previous language
-  \ifcsundef{languagename}{}{%
-     \noextrascurrent{\languagename}%
-     \csuse{no\languagename @numbers}%
-     \ifxetex
-        \str_if_eq:eeTF{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-            {%
-               \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}%
-                  {}% RTL -> RTL
-                  {\setlatin}% RTL -> LTR
-            }{%
-               \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}{RL}%
-                  {\setnonlatin}% LTR -> RTL
-                  {}% LTR -> LTR
-           }%
-     \fi
+  \cs_if_exist:cT{languagename}
+  {%
+    \noextrascurrent{\languagename}%
+    \cs_if_exist_use:c{no\languagename @numbers}%
+    \sys_if_engine_xetex:T{
+      \__xpg_if_LR_str:eTF{\prop_item:Ne{\polyglossia at langsetup}{\languagename/direction}}
+      {
+        \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+          {\setnonlatin}% LTR -> RTL
+      }%
+      {%
+        \__xpg_if_LR_str:eT{\prop_item:Nn{\polyglossia at langsetup}{#2/direction}}
+          {\setlatin}% RTL -> LTR
+      }
+    }
   }%
   \polyglossia at set@language at name[#1]{#2}%
   % Set the language's/script's font families
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}}{latin}{\resetfontlatin}{\xpg at set@normalfont{#2}}%
+  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#2/lcscript}} {latin}
+  {
+    \resetfontlatin
+  }
+  {
+    \xpg at set@normalfont{#2}
+  }%
   \xpg at select@fontfamily{#2}%
-  \csuse at warn{#2 at language}%
-  \csuse{#2 at numbers}%
+  \__xpg_use_or_warn:c{#2 at language}%
+  \cs_if_exist_use:c{#2 at numbers}%
   \use at localhyphenmins[#1]{#2}%
   \polyglossia at lang@frenchspacing:n{#2}
 }
@@ -2112,24 +2364,48 @@
 
 \provideenvironment{otherlanguage}{}{}
 
-\newbool{xpg at noset@groups}
+%
+% Keep track of the active (nested) languages and options
+%
+\clist_new:N \l_xpg_lang_stack
+
+\cs_new:Nn \polyglossia at stack@language:nn
+{
+  \clist_push:Nn \l_xpg_lang_stack {#1:#2}
+}
+
+\cs_generate_variant:Nn \seq_set_split:Nnn {Nnx}
+
+\cs_new:Nn \polyglossia at unstack@language:n
+{
+  \clist_gpop:NNTF \l_xpg_lang_stack \l_tmpa_tl {
+     % Stored format = options:language => split:
+     \seq_set_split:Nnx \l_tmpa_seq {:} \l_tmpa_tl
+     \seq_get_left:NN \l_tmpa_seq \l_tmpb_tl
+     \seq_get_right:NN \l_tmpa_seq \l_tmpc_tl
+     % Execute passed command with language and maybe options
+     \tl_if_empty:NTF \l_tmpb_tl {\cs_if_exist_use:c{#1}{\l_tmpc_tl}}
+                                 {\cs_if_exist_use:c{#1}[\l_tmpb_tl]{\l_tmpc_tl}}
+  }
+  {}
+}
+
 \renewenvironment{otherlanguage}[2][]
 {%
-  % We usually embrace the switch in groups to keep the changes local.
-  % We cannot do this if an LTR environmet starts in an RTL paragraph,
-  % as bidi interferes here badly with its directionality smartness.
-  \ifxetex
-    \str_if_eq:eeT{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-       {%
-        \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/direction}}{RL}%
-           {}% RTL -> RTL
-           {\ifvmode\else\booltrue{xpg at noset@groups}\fi}% RTL -> LTR
-       }%
-  \fi%
-  \ifbool{xpg at noset@groups}{}{\xpg at set@group at aux}%
+  % Get real current options (incl. defaults)
+  \clist_clear_new:N \l_xpg_current_options
+  \prop_map_inline:cn {xpg at current@options@#2}
+  {
+      \clist_put_right:Nn \l_xpg_current_options {##1=##2}
+  }
+  % Store current options and language on stack
+  \polyglossia at stack@language:nn{\clist_use:Nn \l_xpg_current_options {,}}{#2}%
   \selectlanguage[#1]{#2}%
 }
-{\ifbool{xpg at noset@groups}{}{\xpg at unset@group at aux}}
+{%
+   % restore previous language in aux file and remove closed one from stack
+   \polyglossia at unstack@language:n{xpg at set@language at only@aux}%
+}
 
 \newcommand{\setlocalhyphenmins}[3]{%
    \xpg at ifdefined{#1}{%
@@ -2146,14 +2422,8 @@
 % \setlanghyphenmins[options]{lang}{l}{r}
 \newcommand*\setlanghyphenmins[4][]{%
   % Check for real language name and options
-  \edef\xpg at tmp@lang{#2}%
-  \edef\xpg at tmp@opts{#1}%
-  \ifcsdef{#2 at alias@lang}{%
-     \edef\xpg at tmp@lang{\csuse{#2 at alias@lang}}%
-     \ifcsdef{#2 at alias@opts}{%
-       \edef\xpg at tmp@opts{\csuse{#2 at alias@opts},#1}%
-     }{}%
-  }{}%
+  \edef\xpg at tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
+  \edef\xpg at tmp@lang{\xpg_alias_base_lang:n{#2}}
   \bgroup
   \polyglossia at error@iflangnotloaded:n{\xpg at tmp@lang}
   \exp_args:Nne \setkeys{\xpg at tmp@lang}{\xpg at tmp@opts}%
@@ -2160,12 +2430,12 @@
   % Store BCP-47 id of language
   \tl_if_blank:nTF {\xpg at tmp@opts}{%
     \ifcsundef{\csname xpg at tmp@lang\endcsname @gbcp47id}{%
-       \csedef{tmp at bcp47id}{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
+       \csedef{tmp at bcp47id}{\prop_item:Ne{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
     }{%
        \csedef{tmp at bcp47id}{\csuse{#2 at gbcp47id}}%
     }%
   }{%
-    \csedef{tmp at bcp47id}{\exp_args:Nne \prop_item:Nn{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
+    \csedef{tmp at bcp47id}{\prop_item:Ne{\polyglossia at langsetup}{\xpg at tmp@lang /bcp47}}%
   }%
   \xpg at warning{id: \csuse{tmp at bcp47id}}%
   \csgdef{\csname tmp at bcp47id\endcsname @hyphenmins}{{#3}{#4}}%
@@ -2197,15 +2467,15 @@
       \edef\tmpa{\csuse{\csname tmp at bcp47id\endcsname @hyphenmins}}%
       \expandafter\expandafter\expandafter\set at hyphenmins\tmpa\relax%
    }
-   \ifluatex
+   \sys_if_engine_luatex:T{
      % Set \totalhyphenmin if specified
      \prop_get:NxNTF \polyglossia at langsetup {#2/totalhyphenmin} \l_tmpa_tl
      {
-        \xpg at warning{totalhyphenmin: '\l_tmpa_tl'}
+        \xpg at info{totalhyphenmin: '\l_tmpa_tl'}
         \expandafter\hyphenationmin \l_tmpa_tl%
      }%
      {}%
-   \fi
+   }
 }
 
 % Babel previously compiled in hyphenrules into the kernel (via hyphen.cfg)
@@ -2217,37 +2487,17 @@
 % supports language options and aliases.
 \renewenvironment{hyphenrules}[2][]
 {%
-  % We usually embrace the switch in groups to keep the changes local.
-  % We cannot do this if an LTR environmet starts in an RTL paragraph,
-  % as bidi interferes here badly with its directionality smartness.
-  \ifxetex
-    \str_if_eq:eeT{\exp_args:Nne\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
-       {%
-        \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/direction}}{RL}%
-           {}% RTL -> RTL
-           {\ifvmode\else\booltrue{xpg at noset@groups}\fi}% RTL -> LTR
-       }%
-  \fi%
-  \ifbool{xpg at noset@groups}{}{\xpg at set@group at aux}%
   % Check for real language name and options
-  \edef\xpg at tmp@lang{#2}%
-  \edef\xpg at tmp@opts{#1}%
-  \ifcsdef{#2 at alias@lang}{%
-     \edef\xpg at tmp@lang{\csuse{#2 at alias@lang}}%
-     \ifcsdef{#2 at alias@opts}{%
-       \edef\xpg at tmp@opts{\csuse{#2 at alias@opts},#1}%
-     }{}%
-  }{}%
-  \tl_if_blank:nF {\xpg at tmp@opts}{%
-     % Register the language options
-     \polyglossia at set@lang at options:nn {\xpg at tmp@lang} {\xpg at tmp@opts}%
-  }%
+  \edef\xpg at tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
+  \edef\xpg at tmp@lang{\xpg_alias_base_lang:n{#2}}
+  % Register the language options
+  \polyglossia at set@lang at options:nnn {\xpg at tmp@lang} {\xpg at tmp@opts} {@xpg at set@langvariant}%
   % Now switch patterns
-  \csuse at warn{\csuse{xpg at tmp@lang}@language}%
+  \__xpg_use_or_warn:c{\use:c{xpg at tmp@lang}@language}%
   % And activate hyphenmins
   \use at localhyphenmins[\xpg at tmp@opts]{\xpg at tmp@lang}%
 }
-{\ifbool{xpg at noset@groups}{}{\xpg at unset@group at aux}}
+{}
 
 \AtEndPreamble{%
    \@ifpackageloaded{bidi}{%
@@ -2302,15 +2552,15 @@
 
 % Set the LuaTeX renderer. As opposed to fontspec, we use Harfbuzz by default.
 % This can be changed via the luatexrenderer package option.
-\ifluatex
-  \exp_args:Nee \str_if_eq:nnF{\l_polyglossia_luatex_renderer}{none}
-     {
-         \xpg at info{Setting~ LuaTeX~ font~ renderer~ to~ \l_polyglossia_luatex_renderer}
-         \exp_args:Nee \defaultfontfeatures{Renderer=\l_polyglossia_luatex_renderer}
-     }
-\fi
+\sys_if_engine_luatex:T{
+  \str_if_eq:eeF{\l_polyglossia_luatex_renderer}{none}
+  {
+    \xpg at info{Setting~ LuaTeX~ font~ renderer~ to~ \l_polyglossia_luatex_renderer}
+    \exp_args:Ne \defaultfontfeatures{Renderer=\l_polyglossia_luatex_renderer}
+  }
+}
 
-\bool_if:nTF \l_polyglossia_verbose_bool {} {
+\bool_if:nF \l_polyglossia_verbose_bool {
    \gdef\@latex at info#1{\relax}% no latex info
    \gdef\@font at info#1{\relax}% no latex font info
    \gdef\@font at warning#1{\relax}% no latex font warnings
@@ -2318,9 +2568,9 @@
    \gdef\xpg at info#1{\relax}% no polyglossia info
 }
 
-\bool_if:nTF \l_polyglossia_localmarks_bool {
+\bool_if:nT \l_polyglossia_localmarks_bool {
   \polyglossia at enable@local at marks:
-}{}
+}
 
 % compatibility
 \newif\ifsystem at babelshorthands



More information about the tex-live-commits mailing list.