texlive[53592] Master/texmf-dist: polyglossia (29jan20)

commits+karl at tug.org commits+karl at tug.org
Wed Jan 29 23:37:53 CET 2020


Revision: 53592
          http://tug.org/svn/texlive?view=revision&revision=53592
Author:   karl
Date:     2020-01-29 23:37:53 +0100 (Wed, 29 Jan 2020)
Log Message:
-----------
polyglossia (29jan20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/polyglossia/README
    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/farsical.sty
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-albanian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-amharic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-armenian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-asturian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-austrian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bahasa.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-basque.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bengali.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-breton.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-british.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bulgarian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-canadien.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-coptic.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-danish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-divehi.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-esperanto.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-estonian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-friulian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gaelic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-galician.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-hebrew.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hindi.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hungarian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-icelandic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-interlingua.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-japanese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kannada.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-khmer.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-lao.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latvian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lithuanian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-macedonian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malayalam.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-marathi.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nko.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-norwegian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-persian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-polish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romanian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romansh.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sami.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-slovenian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sorbian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-swedish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-syriac.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tamil.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-telugu.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-thai.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkish.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkmen.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-urdu.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-vietnamese.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-welsh.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/hebrewcal.sty
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-french.lua
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-korean.lua
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-latin.lua
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-punct.lua
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-sanskrit.lua
    trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-aeb.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-af.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afb.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-am.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-apd.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-IQ.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-JO.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-LB.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-MR.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-PS.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-SY.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-YE.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arq.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ary.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arz.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ast.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ayl.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be-tarask.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bg.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bo.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-br.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bs.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ca.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Arab.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Latn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cop.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cy.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cz.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-da.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1901.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1996.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dsb.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dv.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-monoton.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-polyton.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-AU.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-CA.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-GB.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-NZ.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-US.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eo.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-ES.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-MX.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-et.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eu.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fa.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fi.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CA.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CH.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-FR.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fur.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ga.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gd.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gl.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-grc.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-he.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hi.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hr.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hsb.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hu.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hy.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ia.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-id.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-is.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-it.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ja.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ka.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-km.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Arab.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Latn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ko.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Arab.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Latn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurmanji.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-classic.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-ecclesia.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-medieval.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lo.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lt.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lv.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mk.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ml.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mn.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mr.ldf
    trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nb.ldf

Modified: trunk/Master/texmf-dist/doc/latex/polyglossia/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/polyglossia/README	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/doc/latex/polyglossia/README	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,7 +1,7 @@
 
    ¦----------------------------------------------¦
    ¦                                              ¦
-   ¦       THE POLYGLOSSIA PACKAGE v1.46          ¦
+   ¦       THE POLYGLOSSIA PACKAGE v1.47          ¦
    ¦                                              ¦
    ¦     Modern multilingual typesetting          ¦
    ¦        with XeLaTeX and LuaLaTeX             ¦
@@ -34,8 +34,8 @@
 
 LICENSE
 
-Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2019 Arthur Reutenauer,
-Copyright (c) 2019 Bastien Roucariès, 2019 Jürgen Spitzmüller
+Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2020 Arthur Reutenauer,
+Copyright (c) 2019-2020 Bastien Roucariès, 2019-2020 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	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/doc/latex/polyglossia/polyglossia.tex	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,19 +2,19 @@
 % !TeX TS-program = xelatex
 \documentclass[11pt]{ltxdoc}
 \usepackage{color}
-\usepackage{xspace,fancyvrb,booktabs}
+\usepackage{xspace,fancyvrb,longtable,booktabs}
 \usepackage[neverdecrease]{paralist}
 \usepackage[format=hang,labelfont=bf,labelsep=period]{caption}
-\definecolor{myblue}{rgb}{0.02,0.04,0.48}
+\definecolor{xpgblue}{rgb}{0.02,0.04,0.48}
 \definecolor{lightblue}{rgb}{0.61,.8,.8}
-\definecolor{myred}{rgb}{0.65,0.04,0.07}
+\definecolor{xpgred}{rgb}{0.65,0.04,0.07}
 \usepackage[
     unicode=true,
     bookmarks=true,
     colorlinks=true,
-    linkcolor=myblue,
-    urlcolor=myblue,
-    citecolor=myblue,
+    linkcolor=xpgblue,
+    urlcolor=xpgblue,
+    citecolor=xpgblue,
     hyperindex=false,
     hyperfootnotes=false,
     pdftitle={Polyglossia: Modern multilingual typesetting with XeLaTeX and LuaLaTeX},
@@ -30,13 +30,13 @@
 \setotherlanguages{arabic,armenian,hebrew,syriac,greek,russian,serbian,catalan,georgian}
 \usepackage[protrusion]{microtype}
 \newcommand*\Cmd[1]{\cmd{#1}\DescribeMacro{#1}\xspace}
-\newcommand*\pkg[1]{\textsf{\color{myblue}#1}}
-\newcommand*\file[1]{\texttt{\color{myblue}#1}}
-\newcommand*\TR[1]{\textcolor{myred}{#1}}
-\newcommand*\TX[1]{\hyperref[#1]{\textcolor{myred}{#1}}}
-\newcommand*\TB[1]{\textcolor{myblue}{\bf #1}}
-\newcommand*\TA[1]{\textsc{\color{myblue}#1}}
+\newcommand*\pkg[1]{\textsf{\color{xpgblue}#1}}
+\newcommand*\file[1]{\texttt{\color{xpgblue}#1}}
+\newcommand*\TR[1]{\textcolor{xpgred}{#1}}
+\newcommand*\TX[1]{\hyperref[#1]{\textcolor{xpgred}{#1}}}
+\newcommand*\TA[1]{\textsc{\color{xpgblue}#1}}
 \newcommand*\link[1]{\href{#1}{#1}}
+\renewcommand*\meta[1]{\texttt{⟨#1⟩}}
 \def\eg{\textit{e.g.,}\xspace}
 \def\ie{\textit{i.e.,}\xspace}
 \def\ca{\textit{ca.}\@\xspace}
@@ -44,14 +44,37 @@
 \def\Ie{\textit{I.e.,}\xspace}
 \def\etc{\@ifnextchar.{\textit{etc}}{\textit{etc.}\@\xspace}}
 
+%% Commands for documenting options
+\newcommand*\xpgoption[1]{\textcolor{xpgblue}{\ttfamily\bfseries #1}}
+\newcommand*\xpgvalue[1]{\texttt{#1}}
+\newcommand*\xpgpresetvalue[1]{\texttt{\textit{#1}}}
+\newcommand*\xpgdefaultvalue[1]{\texttt{*#1}}
+
+% arguments: #1 version number, #2 key name, #3 footnote, #4 possible values
+\NewDocumentCommand\xpgchoicekey{omom}{%
+	\xpgoption{#2}\IfValueT{#3}{\footnote{#3}}%
+    \IfValueT{#1}{\new{#1}} \xpgvalue{=} #4\par%
+}
+
+% arguments: #1 version number, #2 key name, #3 footnote
+\NewDocumentCommand\xpgboolkey{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgvalue{false}}}
+\NewDocumentCommand\xpgboolkeytrue{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{\xpgpresetvalue{true}} or \xpgvalue{false}}}
+\NewDocumentCommand\xpgboolkeyfalse{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgpresetvalue{false}}}
+
+% arguments: #1 version number, #2 key name, #3 default code
+\NewDocumentCommand\xpgcodekey{omv}{%
+	\xpgoption{#2}\IfValueT{#1}{\new{#1}}
+     \xpgvalue{=} \meta{code} (default value: \texttt{#3})\par%
+}
+
 %% Sidenotes  << copied from fontspec.dtx
 \newcommand\new[1]{%
-  \edef\thisversion{#1}%
+  \edef\thisversion{v#1}%
   \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
   $\leftarrow$}%
   \marginpar{\centering
     \small\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
-    \textsf{#1}}}
+    \textsf{v#1}}}
 \newcommand\displaycmd[2]{%
   \\\DescribeMacro{#2}\centerline{\cmd{#1}}}
 \renewenvironment{itemize}{\begin{compactitem}[\char"2023]}%[{\fontspec{DejaVu Sans}\char"25BB}]}%
@@ -71,7 +94,7 @@
 \pretocmd{\subsection}{\condbreak{2\baselineskip}}{}{}
 
 %% fontspec declarations:
-\setmainfont{Linux Libertine O}
+\setmainfont{Linux Libertine O}[Numbers=OldStyle]
 \setsansfont{Linux Biolinum O}
 \setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
 \newfontfamily\arabicfont[Script=Arabic]{Amiri}
@@ -90,12 +113,12 @@
 
 
 \begin{document}
-\hyphenation{Kha-li-ghi Reu-ten-auer}
+\hyphenation{Kha-li-ghi Reu-ten-auer new-zea-land}
 \GetFileInfo{polyglossia.sty}
 
 \title{\textcolor{lightblue}{\Huge\fontspec[LetterSpace=40]{GFS Ambrosia} Πολυγλωσσια}
 \\[16pt]
-\color{myblue}Polyglossia: Modern multilingual typesetting with \XeLaTeX\ and \LuaLaTeX}
+\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\\
@@ -118,7 +141,7 @@
 \section{Introduction}
 
 \pkg{Polyglossia} is a package for facilitating multilingual typesetting with
-\XeLaTeX\ and (with some exceptions) \LuaLaTeX.  Basically, it
+\XeLaTeX\ and (with some exceptions) \LuaLaTeX. Basically, it
 can be used as an alternative to \pkg{babel} for performing the following
 tasks automatically:
 
@@ -142,7 +165,7 @@
       that are written from right to left (via the package \pkg{bidi},
       available separately).
 \end{enumerate}
-
+%
 Several features of \pkg{babel} that do not make sense in the \XeTeX\ world (like font
 encodings, shorthands, etc.) are not supported.
 Generally speaking, \pkg{polyglossia} aims to remain as compatible as possible
@@ -154,7 +177,7 @@
 macros defined in the \pkg{etoolbox} package by \TA{Philipp Lehmann} and \TA{Joseph Wright}.
 Being designed for \XeLaTeX\ and \LuaLaTeX, it obviously also relies on \pkg{fontspec} by
 \TA{Will Robertson}. For languages written from right to left, it needs the package \pkg{bidi}
-(for \XeTeX) or  \pkg{luabidi} (for \LuaTeX) by \TA{Vafa Khalighi} (\textarabic{وفا خليقي}) and
+(for \XeTeX) or \pkg{luabidi} (for \LuaTeX) by \TA{Vafa Khalighi} (\textarabic{وفا خليقي}) and
 the \pkg{bidi-tex GitHub Organisation}.
 Polyglossia also bundles three packages for calendaric computations (\pkg{hebrewcal},
 \pkg{hijrical}, and \pkg{farsical}).
@@ -165,16 +188,16 @@
 \subsection{Activating languages}
 
 The default language of a document is specified by means of the command
-	\displaycmd{\setdefaultlanguage[⟨options⟩]\{⟨lang⟩\}}{\setdefaultlanguage}
+	\displaycmd{\setdefaultlanguage\oarg{options}\marg{lang}}{\setdefaultlanguage}
 (or, equivalently, \Cmd\setmainlanguage).
 Secondary languages are specified with
-	\displaycmd{\setotherlanguage[⟨options⟩]\{⟨lang⟩\}.}{\setotherlanguage}
+	\displaycmd{\setotherlanguage\oarg{options}\marg{lang}.}{\setotherlanguage}
 All these commands allow you to set language-specific options.\footnote{%
 	Section~\ref{specific} documents these options for the respective languages.}
 It is also possible to load a series of secondary languages at once (but without options)
 using
-	\displaycmd{\setotherlanguages\{⟨lang1⟩,⟨lang2⟩,⟨lang3⟩,…\}.}{\setotherlanguages}
-
+	\displaycmd{\setotherlanguages\marg{lang1⟩,⟨lang2⟩,⟨lang3⟩,⟨…}.}{\setotherlanguages}
+%
 All language-specific options can be modified locally by means of the
 language-switching commands described in section \ref{languageswitching}.
 
@@ -195,7 +218,7 @@
 % Edited by hand -- JS, 2019-11-01
 \begin{tabular}{lllll}
 \toprule
-\TX{afrikaans}  & danish         & \TX{hungarian} & marathi         & \TX{slovenian} \\
+\TX{afrikaans}  & danish         & \TX{hungarian} & \TX{marathi}    & \TX{slovenian} \\
 albanian        & divehi         & icelandic      & \TX{mongolian}  & \TX{sorbian}   \\
 amharic         & \TX{dutch}     & interlingua    & nko             & \TX{spanish}   \\
 \TX{arabic}     & \TX{english}   & \TX{italian}   & \TX{norwegian}  & swedish        \\
@@ -209,7 +232,7 @@
 bulgarian       & \TX{georgian}  & latvian        & \TX{russian}    & \TX{ukrainian} \\
 \TX{catalan}    & \TX{german}    & lithuanian     & \TX{sami}       & urdu           \\
 coptic          & \TX{greek}     & macedonian     & \TX{sanskrit}   & vietnamese     \\
-croatian        & \TX{hebrew}    & \TX{malay}     & \TX{serbian}    & \TX{welsh}     \\
+\TX{croatian}   & \TX{hebrew}    & \TX{malay}     & \TX{serbian}    & \TX{welsh}     \\
 \TX{czech}      & \TX{hindi}     & malayalam      & \TX{slovak}     &                \\
 \bottomrule
 \end{tabular}
@@ -216,19 +239,19 @@
 
 \end{table}
 
-\paragraph{Version Notes} The support for Amharic\new{v1.0.1} should be considered an experimental attempt to
+\paragraph{Version Notes} The support for Amharic\new{1.0.1} should be considered an experimental attempt to
 port the package \pkg{ethiop}; feedback is welcome.
-Version 1.1.1\new{v1.1.1} added support for Asturian, %\footnote{ Provided by Kevin Godby and Xuacu Saturio.}, 
+Version 1.1.1\new{1.1.1} added support for Asturian, %\footnote{ Provided by Kevin Godby and Xuacu Saturio.},
 Lithuanian, %\footnote{ Provided by Kevin Godby and Paulius Sladkevičius.},
 and Urdu. %\footnote{ Provided by Kamal Abdali.}
 %
-Version 1.2\new{v1.2.0} introduced Armenian, Occitan, Bengali,
+Version 1.2\new{1.2.0} introduced Armenian, Occitan, Bengali,
 Lao, Malayalam, Marathi, Tamil, Telugu, and Turkmen.\footnote{%
   See acknowledgements at the end for due credit to the various contributors.}
-Version 1.43\new{v1.43} brought basic support for Japanese (this
+Version 1.43\new{1.43} brought basic support for Japanese (this
 is considered experimental, feedback is appreciated).
-In version 1.45\new{v1.45}, support for Kurdish and Mongolian as well as some new
-variants (Canadian French and English) have been added. Furthermore,  for consistency reasons, some language have
+In version 1.45\new{1.45}, support for Kurdish and Mongolian as well as some new
+variants (Canadian French and English) have been added. Furthermore, for consistency reasons, some language have
 been renamed (\emph{farsi}\textrightarrow\emph{persian}, \emph{friulan}\textrightarrow\emph{friulian},
 \emph{magyar}\textrightarrow\emph{hungarian}, \emph{portuges}\textrightarrow\emph{portuguese},
 \emph{samin}\textrightarrow\emph{sami}) or merged (\emph{bahasai}\slash\emph{bahasam}\textrightarrow\emph{malay},
@@ -237,10 +260,10 @@
 \emph{irish}\slash\emph{scottish}\textrightarrow\emph{gaelic},
 \emph{norsk}\slash\emph{nynorsk}\textrightarrow\emph{norwegian}). The old names are still supported for backwards
 compatibility reasons.
-Version 1.46\new{v1.46} introduces support for Afrikaans, Belarusian, Bosnian and Georgian.
+Version 1.46\new{1.46} introduces support for Afrikaans, Belarusian, Bosnian and Georgian.
 
 
-\subsection{Relation to and use of Babel language names}
+\subsection{Relation to and use of Babel language names}\label{sec:babelnames}
 
 If you are familiar with the \pkg{babel} package, you will note that \pkg{polyglossia}'s language naming
 slightly differs. Whereas \pkg{babel} has a unique name for each language variety (\eg\emph{american} and \emph{british}),
@@ -249,7 +272,7 @@
 Furthermore, \pkg{babel} sometimes uses abbreviated language names (\eg\emph{bahasam} for Bahasa Malayu) as well
 as endonyms, \ie language names coming from the designated languages (such as \emph{bahasa}, \emph{canadien} or \emph{magyar}).
 As opposed to this, \pkg{polyglossia} always uses spelled-out (lower-cased) English language names.
-Please refer to table~\ref{tab:bbllang} for the differing language names in both packages. 
+Please refer to table~\ref{tab:bbllang} for the differing language names in both packages.
 
 \begin{table}
 \caption{\label{tab:bbllang}Babel-polyglossia language name matching}
@@ -257,7 +280,7 @@
 \begin{minipage}[t]{1\columnwidth}
 \small\centering
 \begin{tabular}{lll}
-\toprule 
+\toprule
 \textbf{Babel name} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\tabularnewline
 \midrule
 acadien            & french     & variant=acadian                     \\
@@ -270,20 +293,20 @@
 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                     \\
 farsi              & persian    &                                     \\
+ecclesiasticlatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.ecclesiastic}).}
+                   & 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                        \\
 irish              & gaelic     & variant=irish [\emph{default}]      \\
 kurmanji           & kurdish    & variant=kurmanji                    \\
-latin.classic\footnote{Available in \pkg{polyglossia} as \emph{latinclassic} (as dots are invalid in command names).}
-                   & latin      & variant=classic                     \\
-latin.ecclesiastic\footnote{Available in \pkg{polyglossia} as \emph{latinecclesiastic} (as dots are invalid in command names).}
-                   & latin      & variant=ecclesiastic                \\
-latin.medieval\footnote{Available in \pkg{polyglossia} as \emph{latinmedieval} (as dots are invalid in command names).}
-                   & latin      & variant=medieval                    \\
 lowersorbian       & sorbian    & variant=lower                       \\
 magyar             & hungarian  &                                     \\
+medievallatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.medieval}).}
+                   & latin      & variant=medieval                    \\
 naustrian          & german     & variant=austrian                    \\
 newzealand         & english    & variant=newzealand                  \\
 ngerman            & german     & variant=german [\emph{default}]     \\
@@ -298,7 +321,7 @@
 slovene            & slovenian  &                                     \\
 spanishmx          & spanish    & variant=mexican                     \\
 swissgerman        & german     & variant=swiss, spelling=old         \\
-uppersorbian       & sorbian    & variant=upper                       \\
+uppersorbian       & sorbian    & variant=upper [\emph{default}]      \\
 \bottomrule
 \end{tabular}
 \end{minipage}
@@ -305,55 +328,240 @@
 	
 \end{table}
 
-For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{v1.46} (for the few justified
+For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{1.46} (for the few justified
 exceptions, please refer to the notes in table~\ref{tab:bbllang}).
 The babel names listed in table~\ref{tab:bbllang} can be used instead of the corresponding polyglossia
 name\slash options in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the \pkg{polyglossia} and
 \pkg{babel} language switching commands\slash environments documented in section~\ref{sec:langcmds} and
-\ref{sec:babelcmds} (\eg \cmd\textaustrian\ is synonymous to \cmd{\textgerman[variant=austrian,spelling=old]}).
+\ref{sec:babelcmds} (\eg \cmd\textaustrian\ is synonymous to ¦\textgerman[variant=austrian,spelling=old]¦).
 However, unless you have special reasons, we strongly encourage you to use the \pkg{polyglossia} names.
 
 
+\subsection{Using IETF language tags}\label{sec:langtags}
+
+\pkg{Polyglossia}\new{1.47} also supports the use of language tags that conform to the IETF BCP-47
+\emph{Best Current Practice}.\footnote{Please refer to \url{https://tools.ietf.org/html/bcp47} and
+	\url{https://en.wikipedia.org/wiki/IETF_language_tag} for details.}
+Thus, you can use tags such as ¦en-GB¦ (for British English) or ¦de-AT-1901¦ (for Austrian German, old spelling)
+in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the language switching command
+\cmd{\textlang\marg{tag}}, the environment \cmd{\begin\{lang\}\marg{tag}} \ldots\ \cmd{\end\{lang\}} and the \pkg{babel}
+language switching commands\slash environments documented in section~\ref{sec:babelcmds}.
+Table~\ref{tab:BCP47-polyglossia} lists the currently supported tags.
+
+\bgroup\small\addfontfeatures{Numbers={Monospaced,Lining}}
+\begin{longtable}[c]{lll}
+	\caption{\label{tab:BCP47-polyglossia}BCP47-polyglossia language name matching}\\
+	\toprule
+	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
+	\midrule
+	\endfirsthead
+	\caption[]{BCP47-polyglossia language name matching (\emph{continued})}\\
+	\toprule
+	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
+	\midrule
+	\endhead
+	aeb              & arabic      & locale=tunisia                                     \\
+	af               & afrikaans   &                                                    \\
+	afb              & arabic      & locale=default                                     \\
+	am               & amharic     &                                                    \\
+	apd              & arabic      & locale=default                                     \\
+	ar               & arabic      &                                                    \\
+	ar-IQ            & arabic      & locale=mashriq                                     \\
+	ar-JO            & arabic      & locale=mashriq                                     \\
+	ar-LB            & arabic      & locale=mashriq                                     \\
+	ar-MR            & arabic      & locale=mauritania                                  \\
+	ar-PS            & arabic      & locale=mashriq                                     \\
+	ar-SY            & arabic      & locale=mashriq                                     \\
+	ar-YE            & arabic      & locale=default                                     \\
+	arq              & arabic      & locale=algeria                                     \\
+	ary              & arabic      & locale=morocco                                     \\
+	arz              & arabic      & locale=default                                     \\
+	ast              & asturian    &                                                    \\
+	ayl              & arabic      & locale=libya                                       \\
+	be               & belarusian  &                                                    \\
+	be-tarask        & belarusian  & spelling=classic                                   \\
+	bg               & bulgarian   &                                                    \\
+	bn               & bengali     &                                                    \\
+	bo               & tibetan     &                                                    \\
+	br               & breton      &                                                    \\
+	bs               & bosnian     &                                                    \\
+	ca               & catalan     &                                                    \\
+	ckb              & kurdish     & variant=sorani [\emph{default}]                    \\
+	ckb-Arab         & kurdish     & variant=sorani, script=Arabic [\emph{default}]     \\
+	ckb-Latn         & kurdish     & variant=sorani, script=Latin                       \\
+	cop              & coptic      &                                                    \\
+	cy               & welsh       &                                                    \\
+	cz               & czech       &                                                    \\
+	da               & danish      &                                                    \\
+	de               & german      &                                                    \\
+	de-AT            & german      & variant=austrian, spelling=new                     \\
+	de-AT-1901       & german      & variant=austrian, spelling=old                     \\
+	de-AT-1996       & german      & variant=austrian, spelling=new                     \\
+	de-CH            & german      & variant=swiss, spelling=new                        \\
+	de-CH-1901       & german      & variant=swiss, spelling=old                        \\
+	de-CH-1996       & german      & variant=swiss, spelling=new                        \\
+	de-DE            & german      & variant=german, spelling=new                       \\
+	de-DE-1901       & german      & variant=german, spelling=old                       \\
+	de-DE-1996       & german      & variant=german, spelling=new  [\emph{default}]     \\
+	de-Latf          & german      & script=blackletter                                 \\
+	de-Latf-AT       & german      & variant=austrian, spelling=new, script=blackletter \\
+	de-Latf-AT-1901  & german      & variant=austrian, spelling=old, script=blackletter \\
+	de-Latf-AT-1996  & german      & variant=austrian, spelling=new, script=blackletter \\
+	de-Latf-CH       & german      & variant=swiss, spelling=new, script=blackletter    \\
+	de-Latf-CH-1901  & german      & variant=swiss, spelling=old, script=blackletter    \\
+	de-Latf-CH-1996  & german      & variant=swiss, spelling=new, script=blackletter    \\
+	de-Latf-DE       & german      & variant=german, spelling=new, script=blackletter   \\
+	de-Latf-DE-1901  & german      & variant=german, spelling=old, script=blackletter   \\
+	de-Latf-DE-1996  & german      & variant=german, spelling=new, script=blackletter   \\
+	dsb              & sorbian     & variant=lower                                      \\
+	dv               & divehi      &                                                    \\
+	el               & greek       &                                                    \\
+	el-monoton       & greek       & variant=monotonic  [\emph{default}]                \\
+	el-polyton       & greek       & varant=polytonic                                   \\
+	en               & english     &                                                    \\
+	en-AU            & english     & variant=australian                                 \\
+	en-CA            & english     & variant=canadian                                   \\
+	en-GB            & english     & variant=british                                    \\
+	en-NZ            & english     & variant=newzealand                                 \\
+	en-US            & english     & variant=us [\emph{default}]                        \\
+	eo               & esperanto   &                                                    \\
+	es               & spanish     &                                                    \\
+	es-ES            & spanish     & variant=spanish [\emph{default}]                   \\
+	es-MX            & spanish     & variant=mexican                                    \\
+	et               & estonian    &                                                    \\
+	eu               & basque      &                                                    \\
+	fa               & persian     &                                                    \\
+	fi               & finnish     &                                                    \\
+	fr               & french      &                                                    \\
+	fr-CA            & french      & variant=canadian                                   \\
+	fr-CH            & french      & variant=swiss                                      \\
+	fr-FR            & french      & variant=french [\emph{default}]                    \\
+	fur              & friulian    &                                                    \\
+	ga               & gaelic      & variant=irish [\emph{default}]                     \\
+	gd               & gaelic      & variant=scottish                                   \\
+	gl               & galician    &                                                    \\
+	grc              & greek       & variant=ancient                                    \\
+	he               & hebrew      &                                                    \\
+	hi               & hindi       &                                                    \\
+	hr               & croatian    &                                                    \\
+	hsb              & sorbian     & variant=upper [\emph{default}]                     \\
+	hu               & hungarian   &                                                    \\
+	hy               & armenian    &                                                    \\
+	ia               & interlingua &                                                    \\
+	id               & malay       & variant=indonesian                                 \\
+	is               & icelandic   &                                                    \\
+	it               & italian     &                                                    \\
+	ja               & japanese    &                                                    \\
+	ka               & georgian    &                                                    \\
+	km               & khmer       &                                                    \\
+	kmr              & kurdish     & variant=kurmanji                                   \\
+	kmr-Arab         & kurdish     & variant=kurmanji, script=Arabic                    \\
+	kmr-Latn         & kurdish     & variant=kurmanji, script=Latin                     \\
+	kn               & kannada     &                                                    \\
+	ko               & korean      &                                                    \\
+	ku               & kurdish     &                                                    \\
+	ku-Arab          & kurdish     & script=Arabic                                      \\
+	ku-Latn          & kurdish     & script=Latin                                       \\
+	la               & latin       &                                                    \\
+	la-x-classic     & latin       & variant=classic                                    \\
+	la-x-ecclesia    & latin       & variant=ecclesiastic                               \\
+	la-x-medieval    & latin       & variant=medieval                                   \\
+	lo               & lao         &                                                    \\
+	lt               & lithuanian  &                                                    \\
+	lv               & latvian     &                                                    \\
+	mk               & macedonian  &                                                    \\
+	ml               & malayalam   &                                                    \\
+	mn               & mongolian   &                                                    \\
+	mr               & marathi     &                                                    \\
+	nb               & norwegian   & variant=bokmal                                     \\
+	nko              & nko         &                                                    \\
+	nl               & dutch       &                                                    \\
+	nn               & norwegian   & variant=nynorsk [\emph{default}]                   \\
+	oc               & occitan     &                                                    \\
+	pl               & polish      &                                                    \\
+	pms              & piedmontese &                                                    \\
+	pt               & portuguese  &                                                    \\
+	pt-BR            & portuguese  & variant=brazilian                                  \\
+	pt-PT            & portuguese  & variant=portuguese [\emph{default}]                \\
+	rm               & romansh     &                                                    \\
+	ro               & romanian    &                                                    \\
+	ru               & russian     &                                                    \\
+	ru-luna1918      & russian     & spelling=modern [\emph{default}]                   \\
+	ru-petr1708      & russian     & spelling=old                                       \\
+	sa               & sanskrit    &                                                    \\
+	sa-Beng          & sanskrit    & script=Bengali                                     \\
+	sa-Deva          & sanskrit    & script=Devanagari [\emph{default}]                 \\
+	sa-Gujr          & sanskrit    & script=Gujarati                                    \\
+	sa-Knda          & sanskrit    & script=Kannada                                     \\
+	sa-Mlym          & sanskrit    & script=Malayalam                                   \\
+	sa-Telu          & sanskrit    & script=Telugu                                      \\
+	se               & sami        &                                                    \\
+	sk               & slovak      &                                                    \\
+	sl               & slovenian   &                                                    \\
+	sq               & albanian    &                                                    \\
+	sr               & serbian     &                                                    \\
+	sr-Cyrl          & serbian     & script=Cyrillic                                    \\
+	sr-Latn          & serbian     & script=Latin [\emph{default}]                      \\
+	sv               & swedish     &                                                    \\
+	syr              & syriac      &                                                    \\
+	ta               & tamil       &                                                    \\
+	te               & telugu      &                                                    \\
+	th               & thai        &                                                    \\
+	tk               & turkmen     &                                                    \\
+	tr               & turkish     &                                                    \\
+	uk               & ukrainian   &                                                    \\
+	ur               & urdu        &                                                    \\
+	vi               & vietnamese  &                                                    \\
+	zsm              & malay       & variant=malaysian [\emph{default}]                 \\
+	\bottomrule
+\end{longtable}
+\egroup
+
 \subsection{Global options}
 
 \pkg{Polyglossia} can be loaded with the following global package options:
 
 \begin{itemize}
-	\item \TB{babelshorthands}\new{v1.1.1} globally activates \pkg{babel}
-		shorthands whenever available. Currently shorthands are implemented for
-		Afrikaans, Belarusian, Catalan, Czech, Dutch, Finnish, Georgian, German,
-		Italian, Latin, Mongolian, Russian, and Slovak. Please refer to the respective
-		language descriptions (sec.~\ref{specific}) for details.
+	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+		Globally activates \pkg{babel} shorthands whenever available. Currently
+		shorthands are implemented for Afrikaans, Belarusian, Catalan, Croatian,
+		Czech, Dutch, Finnish, Georgian, German, Italian, Latin, Mongolian,
+		Russian, Slovak, and Ukrainian. Please refer to the respective language descriptions
+		(sec.~\ref{specific}) for details.
 
-	\item \TB{localmarks} redefines the internal \LaTeX\ macros \cmd\markboth\ and
-		\cmd\markright. In earlier versions of \pkg{polyglossia},\new{v1.2.0} this
+	\item \xpgoption{localmarks} redefines the internal \LaTeX\ macros \cmd\markboth\ and
+		\cmd\markright. In earlier versions of \pkg{polyglossia},\new{1.2.0} this
 		option was set by default, but we now realize that it causes more problems
 		than it helps, so it is now off by default.  For backwards-compatibility, the
-		option \TB{nolocalmarks} which used to switch off the previous default, and
+		option \xpgoption{nolocalmarks} which used to switch off the previous default, and
 		now does nothing, is still available.
 
-	\item \TB{quiet} turns off most info messages and some of the warnings issued
+	\item \xpgoption{quiet} turns off most info messages and some of the warnings issued
 		by \LaTeX, \pkg{fontspec} and \pkg{polyglossia}.
 \end{itemize}
 
+\condbreak{5\baselineskip}
 \section{Language-switching commands}\label{languageswitching}
 
 \subsection{Recommended commands}\label{sec:langcmds}
 For each activated language the command
-\cmd{\text⟨lang⟩[⟨options⟩]\{…\}} \DescribeMacro{\text⟨lang⟩}
+\cmd{\text\meta{lang}\oarg{options}\marg{…}} \DescribeMacro{\text\meta{lang}}
 (as well as the synonymous \DescribeMacro{\textlang}%
-\cmd{\textlang[⟨options⟩]\{⟨lang⟩\}\{…\}}\new{1.46})
+\cmd{\textlang\oarg{options}\marg{lang}\marg{…}}\new{1.46})
 becomes available for short insertions of text in that language.
+
 For example ¦\textrussian{\today}¦ and ¦\textlang{russian}{\today}¦ yield \textrussian{\today}
 The commands switch to the correct hyphenation patterns, they activate
 some extra features for the selected language (such as extra spacing before
-punctuation in French), and they translate the date when using ¦\today¦.
-They do not, however, translate so-called \textit{caption strings},\ie
-``chapter'', ``figure'' etc., to the local language (these remain in the main
+punctuation in French), and they translate the date when using \cmd\today.
+They do not, however, translate so-called \textit{caption strings}, \ie
+``chapter'', ``figure'' etc., to the local language (these remain in the currently active `outer'
 language).
 
-The\DescribeEnv{⟨lang⟩}\ environment ¦⟨lang⟩¦, which is also available for any activated language,
-is meant for longer passages of text. It behaves slightly different than the \cmd{\text⟨lang⟩} and
+The\DescribeEnv{\meta{lang}}\ environment \meta{lang}, which is also available for any activated language
+(as well as the equivalent \DescribeMacro{lang}%
+\cmd{\begin\{lang\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{lang\}}\new{1.47}),
+is meant for longer passages of text. It behaves slightly different than the \cmd{\text\meta{lang}} and
 \cmd\textlang\ commands: It does everything the latter do, but additionally, the caption strings
 are translated as well, and the language is also passed to auxiliary files, the table of contents
 and the lists of figures/tables.
@@ -361,7 +569,7 @@
 For instance the following allows us to quote the beginning
 of Homer’s \textit{Iliad}:
 
-\begin{Verbatim}[formatcom=\color{myblue}]
+\begin{Verbatim}[formatcom=\color{xpgblue}]
   \begin{quote}
    \begin{greek}[variant=ancient]
      μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς
@@ -393,17 +601,17 @@
 compiled into the \XeLaTeX\ and \LuaLaTeX\ format) are redefined, but keep a
 similar behaviour.
 \begin{itemize}
-\item \DescribeMacro{\selectlanguage}\cmd{\selectlanguage[⟨options⟩]\{⟨lang⟩\}}
-\item \DescribeMacro{\foreignlanguage}\cmd{\foreignlanguage[⟨options⟩]\{⟨lang⟩\}\{…\}}
-\item \DescribeEnv{otherlanguage}\cmd{\begin\{otherlanguage\}[⟨options⟩]\{⟨lang⟩\}} \dots{} \cmd{\end\{otherlanguage\}}
-\item \DescribeEnv{otherlanguage*}\cmd{\begin\{otherlanguage*\}[⟨options⟩]\{⟨lang⟩\}} \dots{} \cmd{\end\{otherlanguage*\}}
+\item \DescribeMacro{\selectlanguage}\cmd{\selectlanguage\oarg{options}\marg{lang}}
+\item \DescribeMacro{\foreignlanguage}\cmd{\foreignlanguage\oarg{options}\marg{lang}\marg{…}}
+\item \DescribeEnv{otherlanguage}\cmd{\begin\{otherlanguage\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage\}}
+\item \DescribeEnv{otherlanguage*}\cmd{\begin\{otherlanguage*\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage*\}}
 \end{itemize}
 %
-¦\selectlanguage{⟨lang⟩}¦ and the ¦otherlanguage¦ environment are identical to the
-the ¦⟨lang⟩¦ environment, except that ¦\selectlanguage{⟨lang⟩}¦
-does not need to be explicitly closed. The command ¦\foreinlanguage{⟨lang⟩}{…}¦ and the ¦otherlanguage*¦
-environment are identical with the use of the ¦\text⟨lang⟩¦ or ¦\textlang¦ command, with the one
-notable exception that they do not translate the date with ¦\today¦.
+\cmd\selectlanguage\marg{lang} and the ¦otherlanguage¦ environment are identical to the
+the \meta{lang} environment, except that \cmd\selectlanguage\marg{lang}
+does not need to be explicitly closed. The command \cmd\foreinlanguage\marg{lang}\marg{…} and the ¦otherlanguage*¦
+environment are identical with the use of the \cmd\text\meta{lang} or \cmd\textlang\ command, with the one
+notable exception that they do not translate the date with \cmd\today.
 
 Since the \XeLaTeX\ and \LuaLaTeX\ format incorporate \pkg{babel}’s \file{hyphen.cfg},
 the low-level commands for hyphenation and language switching
@@ -411,13 +619,12 @@
 
 \subsection{Other commands}
 The following commands are probably of lesser interest to the end user, but
-ought to be mentioned here.\footnote{Note that these commands require polyglossia
-language names; they do not support language\slash babel aliases.}
+ought to be mentioned here.
 \begin{itemize}
-\item \DescribeMacro{\selectbackgroundlanguage}\cmd{\selectbackgroundlanguage\{⟨lang⟩\}}:
+\item \DescribeMacro{\selectbackgroundlanguage}\cmd{\selectbackgroundlanguage\marg{lang}}:
     this selects the global font setup and the numbering definitions for the default language.
 
-\item \DescribeMacro{\resetdefaultlanguage}\cmd{\resetdefaultlanguage[⟨options⟩]\{⟨lang⟩\}} (experimental):
+\item \DescribeMacro{\resetdefaultlanguage}\cmd{\resetdefaultlanguage\oarg{options}\marg{lang}} (experimental):
 	completely switches the default language
 	to another one in the middle of a document: \textit{this may have adverse effects}!
 
@@ -435,43 +642,49 @@
 \subsection{Setting up alias commands}
 
 By means of the macro
-\displaycmd{\setlanguagealias[⟨options⟩]\{⟨language⟩\}\{⟨alias⟩\}}{\setlanguagealias}\new{v1.46}
+\displaycmd{\setlanguagealias\oarg{options}\marg{language}\marg{alias}}{\setlanguagealias}\new{1.46}
 you can define alias commands for specific language (variants). \Eg
 
 \begin{quote}
 \begin{verbatim}
-\setlanguagealias[variant=austrian]{german}{deAT}
+\setlanguagealias[variant=austrian]{german}{AT}
 \end{verbatim}
 \end{quote}
 %
-will define a command \cmd{\textdeAT} as well as an environment ¦{deAT}¦ which will link towards
-the command \cmd{\textgerman[variant=austrian]} and the environment ¦{german}[variant=austrian]¦,
+will define a command \cmd{\textAT} as well as an environment ¦{AT}¦ which will link towards
+the command ¦\textgerman[variant=austrian]¦ and the environment ¦{german}[variant=austrian]¦,
 respectively. The aliases can also be used in the language switching commands described in
 section~\ref{sec:langcmds} and \ref{sec:babelcmds}.
 Note, though, that the usual restrictions for command names apply, so something such as
-¦de-AT¦ or ¦de_AT¦ will not work since ¦-¦ and ¦_¦ are not allowed in command names.
+¦de-AT¦ or ¦de_AT¦ will not work since ¦-¦ and ¦_¦ are not allowed in command names (the same
+holds true for any non-ASCII character and for digits).
 
-For the latter case, and for the case where an alias would clash with an existing \cmd{\text⟨...⟩}
-command (\eg ¦\textit¦), a starred version \Cmd{\setlanguagealias*} is provided which does not define
-a \cmd{\text⟨alias⟩} command (but which will set up the alias for everything else, including
-\cmd{\textlang\{⟨alias⟩\}}).
+For the latter case, and for the case where an alias would clash with an existing command
+(\eg ¦\fi¦) or a \cmd{\text\meta{\ldots}} command (\eg \cmd\textit), a starred version \Cmd{\setlanguagealias*}
+is provided which does neither define a \cmd{\text\meta{alias}} command nor an \meta{alias} environment,
+but which will set up the alias for everything else, including \cmd{\textlang\marg{alias}}
+and \cmd{\begin\{lang\}\marg{alias}}.
 
+\pkg{Polyglossia} comes with some aliases predefined, namely aliases for \pkg{babel} language names
+(see sec.~\ref{sec:babelnames}) and for IETF BCP-47 language tags (the latter via \cmd{\setlanguagealias*};
+see sec.~\ref{sec:langtags}).
+
 \section{Font setup}
 
 With polyglossia it is possible to associate a specific font with any script or language
 that occurs in the document. That font should always be defined as
-¦\⟨script⟩font¦\ or ¦\⟨language⟩font¦.
+\cmd{\⟨script⟩font}\ or \cmd{\⟨language⟩font}.
 For instance, if the default font defined by \cmd\setmainfont\
 does not support Greek, then one can define the font used to display Greek with:\\
-\centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,⟨…⟩]\{⟨font⟩\}}. }
+\centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,\meta{…}]\marg{font}}. }
 Note that polyglossia will use the font defined as is, so assure to do all necessary settings
 (please refer to the \pkg{fontspec} documentation for details).
-For instance, if ¦\arabicfont¦ is explicitly defined, then the option ¦Script=Arabic¦ should
+For instance, if \cmd\arabicfont\ is explicitly defined, then the option ¦Script=Arabic¦ should
 be included in that definition.
 
 If a specific sans serif or monospace (`teletype') font is needed for a particular script or language,
-it can be defined by means of \new{v1.2.0}
-¦\⟨script⟩fontsf¦\ or ¦\⟨language⟩fontsf¦ and ¦\⟨script⟩fonttt¦\ or ¦\⟨language⟩fonttt¦, respectively.
+it can be defined by means of \new{1.2.0}
+\cmd{\⟨script⟩fontsf} or \cmd{\⟨language⟩fontsf} and \cmd{\⟨script⟩fonttt} or \cmd{\⟨language⟩fonttt}, respectively.
 
 Whenever a new language is activated, \pkg{polyglossia} will first check whether
 a font has been defined for that language or – for languages in non-Latin scripts –
@@ -486,7 +699,7 @@
 
 \subsection{Hyphenation exceptions}
 
-\TeX\ provides the command ¦\hyphenation{⟨exceptions⟩}¦ to globally define hyphenation exceptions
+\TeX\ provides the command \cmd\hyphenation\marg{exceptions} to globally define hyphenation exceptions
 which override the hyphenation patterns for specified words. The command takes as argument a space-separated
 list of words where hyphenation points are marked by a dash (if no dash is used, the respective word is not
 hyphenated at all):
@@ -498,8 +711,8 @@
 \end{Verbatim}
 %
 These exceptions, however, apply to all languages. In addition to this, \pkg{polyglossia} provides
-the command\new{v1.45}
-\displaycmd{\pghyphenation[⟨options⟩]\{⟨lang⟩\}\{⟨exceptions⟩\}}{\pghyphenation}
+the command\new{1.45}
+\displaycmd{\xpghyphenation\oarg{options}\marg{lang}\marg{exceptions}}{\xpghyphenation}
 which can be used to define exceptions that only apply to a specific language or language variant,
 respectively.
 
@@ -514,25 +727,33 @@
 
 \section{Language-specific options and commands}\label{specific}
 
-This section gives a list of all languages for which options and end-user commands are defined.
-The default value of each option is given in italic.
+This section gives a list of all languages for which options and end-user
+commands are defined. Note the following conventions:
+\begin{itemize}
+	\item The preset value of each option (\ie the setting that applies by default,
+	if the option is not explicitly set) is given in \xpgpresetvalue{italics}.
+	\item If an option key may be used without a value, the value that applies
+	for value-less keys is marked by a preceding \xpgdefaultvalue{asterisk}.
+\end{itemize}
+For instance, \texttt{babelshorthands = *true} or \texttt{\textit{false}} means that
+\xpgvalue{babelshorthands} is \xpgvalue{false} by default in the respective language,
+and that passing \xpgvalue{babelshorthands} (without value) is equivalent to passing
+\xpgvalue{babelshorthands=true}.
 
-%\subsection{amharic}\label{amharic}
-
-\subsection{afrikaans}\label{afikaans}
+\subsection{afrikaans}\label{afrikaans}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-	if this is turned on, the following shorthands defined for fine-tuning hyphenation and
+	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+	If this is turned on, the following shorthands defined for fine-tuning hyphenation and
 	micro-typography of Afrikaans words are activated:
 	\begin{shorthands}
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		in the hyphenation patterns (as opposed to ¦\-¦ in default \TeX).
+		in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 		cases where the hyphen should stick at the following syllable.
 		\item[¦"|¦] disables a ligature at this position.
 		\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 ¦\slash¦,
+		\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}
 \end{itemize}
@@ -540,23 +761,23 @@
 \subsection{arabic}\label{arabic}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{calendar} = \textit{gregorian} or islamic (= hijri)
-	\item \TB{locale} = \textit{default},\footnote{ %
-			For Egypt, Sudan, Yemen and the Gulf states.}
-		mashriq,\footnote{ %
-			For Iraq, Syria, Jordan, Lebanon and Palestine.}
-		libya, algeria, tunisia, morocco, or mauritania.
+	\item \xpgchoicekey{calendar}{\xpgpresetvalue{gregorian} or \xpgvalue{islamic} (= \xpgvalue{hijri})}
+	\item \xpgchoicekey{locale}{\xpgpresetvalue{default}\footnote{ %
+			For Egypt, Sudan, Yemen and the Gulf states.},
+		\xpgvalue{mashriq}\footnote{ %
+			For Iraq, Syria, Jordan, Lebanon and Palestine.},
+		\xpgvalue{libya}, \xpgvalue{algeria}, \xpgvalue{tunisia}, \xpgvalue{morocco}, \xpgvalue{mauritania}}
 		This setting influences the spelling of the month names for the Gregorian calendar,
 		as well as the form of the numerals (unless overriden by the following option).
-	\item \TB{numerals} = \textit{mashriq} or maghrib
-		(the latter is the default when locale = algeria, tunisia or morocco)
-  \item \TB{abjadjimnotail} = \textit{false} or true. \new{v1.0.3}
+	\item \xpgchoicekey{numerals}{\xpgpresetvalue{mashriq} or \xpgvalue{maghrib}}
+		The latter is the default when \xpgvalue{locale=algeria}, \xpgvalue{tunisia}, or \xpgvalue{morocco}.
+	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
     Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
 	\end{itemize}
 \paragraph*{Commands:}
 	\begin{itemize}
 	\item \Cmd\abjad and \Cmd\abjadmaghribi (see section \ref{abjad})
-  \item \Cmd\aemph to emphasize text with ¦\overline¦.\new{v1.2.0}
+  \item \Cmd\aemph to emphasize text with \cmd\overline.\new{1.2.0}
     ¦\textarabic{\aemph{اب}}¦ yields \textarabic{\aemph{اب}}.
     This command is also available for Farsi, Urdu, etc.
 	\end{itemize}
@@ -564,19 +785,19 @@
 \subsection{armenian}\label{armenian}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant}\new{v1.45} = eastern or \textit{western}
-	\item \TB{numerals}\new{v1.45} = armenian or \textit{arabic}
+  \item \xpgchoicekey[1.45]{variant}{\xpgvalue{eastern} or \xpgpresetvalue{western}}
+	\item \xpgchoicekey[1.45]{numerals}{\xpgvalue{armenian} or \xpgpresetvalue{arabic}}
 \end{itemize}
 
-\subsection[belarusian]{belarusian\new{v1.46}}\label{belarusian}
+\subsection[belarusian]{belarusian\new{1.46}}\label{belarusian}
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true.
+  \item \xpgboolkeyfalse{babelshorthands}
 	If this is turned on, the following shorthands are activated:
 	\begin{shorthands}
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		in the hyphenation patterns (as opposed to ¦\-¦).
+		in the hyphenation patterns (as opposed to \cmd\-).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 		cases where the hyphen should stick at the following syllable.
 		\item[¦"|¦] disables a ligature at this position.
@@ -590,67 +811,123 @@
 		\item[¦"<¦] for French left double quotes (looks like <<).
 		\item[¦">¦] for French right double quotes (looks like >>).
 	\end{shorthands}
-	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-	alphanumerical numbering.
-	\item \TB{spelling} = \textit{modern} or classic (=~tarask). With ¦spelling=classic¦, captions and dates
-	     adhere to the Taraškievica (or Belarusian classical) orthography rather than the standard orthography.
+    \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}
+	          \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+	          \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+	                \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+	                It supports numbers up to 999\,999.
+         \end{itemize}
+	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{classic} (= \xpgvalue{tarask})}
+	With ¦spelling=classic¦, captions and dates adhere to the Taraškievica (or
+	Belarusian classical) orthography rather than the standard orthography.
 \end{itemize}
 %
 \paragraph*{Commands:}
 \begin{itemize}
-	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-	environments such as ¦enumerate¦. The command takes a counter as argument,
-	\eg ¦\textbelarusian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-	\item \Cmd\asbuk: same in lowercase
+     \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+          It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+          The command takes a counter as argument, \eg ¦\textbelarusian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
+     \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+     \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+          numbers up to 999\,999.\\
+          \Eg ¦\textbelarusian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+     \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 \end{itemize}
 
-\subsection[bengali]{bengali\new{v1.2.0}}\label{bengali}
+\subsection[bengali]{bengali\new{1.2.0}}\label{bengali}
 \paragraph*{Options:}
 	\begin{itemize}
-		\item \TB{numerals} = Western, Bengali or \textit{Devanagari}
-		\item \TB{changecounternumbering} = true or \textit{false} (use specified
-			numerals for headings and page numbers)
+	  \item \xpgchoicekey{numerals}{\xpgvalue{Western}, \xpgvalue{Bengali}, or \xpgpresetvalue{Devanagari}}
+		\item \xpgboolkeyfalse{changecounternumbering}
+		Use specified numerals for headings and page numbers.
 	\end{itemize}
 
 \subsection{catalan}\label{catalan}
 \paragraph*{Options:}
 \begin{itemize}
-  \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-    Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l’s.
+  \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+    Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l or L.
 \end{itemize}
 
 \paragraph*{Commands:}
 \begin{itemize}
-  \item \Cmd{\l.l} and \Cmd{\L.L}\new{v1.1.1} can be used to type a geminated l, as in \textit{co\l.laborar},
+  \item \Cmd{\l.l} and \Cmd{\L.L}\new{1.1.1} can be used to type a geminated l, as in \textit{co\l.laborar},
         similar to \pkg{babel} (the glyph U+00B7 MIDDLE DOT is used as a geminating sign).
 \end{itemize}
 
+\subsection{croatian}\label{croatian}
+\paragraph*{Options:}
+\begin{itemize}
+	\item \xpgboolkeyfalse[1.47]{babelshorthands}
+	If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
+	of Croatian words are activated.
+	\begin{shorthands}
+		\item[¦"|¦] disables a ligature at this position.
+		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
+		            other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
+		\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.
+	\end{shorthands}
+	Furthermore, the following shorthands generate easy access to Croatian digraphs (ligatures):
+	\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}).
+	\end{shorthands}
+	
+	Finally, there are also four shorthands for quotation marks:
+	\begin{shorthands}
+		\item[¦"`¦] for Croatian left double quotes („).
+		\item[¦"'¦] for Croatian right double quotes (”).
+		\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).
+\end{itemize}
+
 \subsection{czech}\label{czech}
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.45}
-	if this is turned on, the following shorthands for Czech are activated:
+	\item \xpgboolkeyfalse[1.45]{babelshorthands}
+	If this is turned on, the following shorthands for Czech are activated:
 	\begin{shorthands}
 		\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
 		            of the next line when hyphenated, as common in Czech typesetting
 		            (only needed with ¦splithyphens=false¦).
-		\item[¦"‘¦] for Czech left double quotes (looks like ,,).
-		\item[¦"’¦] for Czech right double quotes (looks like “).
-		\item[¦">¦] for Czech left double guillemets (looks like >>).
-		\item[¦"<¦] for Czech right double guillemets (looks like <<).
+		\item[¦"‘¦] for Czech left double quotes („).
+		\item[¦"’¦] for Czech right double quotes (“).
+		\item[¦">¦] for Czech left double guillemets (»).
+		\item[¦"<¦] for Czech right double guillemets («).
 	\end{shorthands}
-	\item \TB{splithyphens} = false or \textit{true}.\new{v1.45}
+	\item \xpgboolkeytrue[1.45]{splithyphens}
 	      According to Czech 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}).
-          By default, this is done automatically\new{v1.46} (if you are using \LuaTeX, the \pkg{luavlna} package is
+          By default, this is done automatically\new{1.46} (if you are using \LuaTeX, the \pkg{luavlna} package is
           loaded to achieve this).
           Set this option to ¦false¦ to disable the feature.
-    \item \TB{vlna} = false or \textit{true}. \new{v1.45}
+	\item \xpgboolkeytrue[1.45]{vlna}
          According to Czech typesetting conventions, single-letter words (non-syllable prepositions)
          must not occur at line ends.
-         \pkg{Polyglossia} takes care of this automatically by default\new{v1.46} (if you are using \LuaTeX, the
+         \pkg{Polyglossia} takes care of this automatically by default\new{1.46} (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}
@@ -658,17 +935,17 @@
 \subsection{dutch}\label{dutch}
 \paragraph*{Options:}
 \begin{itemize}
-  \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-		if this is turned on, the following shorthands defined for fine-tuning hyphenation and
+  \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+		If this is turned on, the following shorthands defined for fine-tuning hyphenation and
 		micro-typography of Dutch words are activated:
 		\begin{shorthands}
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-			        in the hyphenation patterns (as opposed to ¦\-¦ in default \TeX).
+			        in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 			        cases where the hyphen should stick at the following syllable.
 		\item[¦"|¦] disables a ligature at this position.
 		\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 ¦\slash¦,
+		\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}
         In addition, the macro \Cmd\- is redefined to allow hyphens in the rest of the word (equivalent to ¦"-¦).
@@ -677,9 +954,10 @@
 \subsection{english}\label{english}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{variant} = \textit{american} (= us), usmax (same as ‘american’ but with additional hyphenation patterns),
-	british (= uk), australian, canadian\new{v1.45} or newzealand
-	\item \TB{ordinalmonthday} = true/\textit{false} (true by default only when variant = british)
+	\item \xpgchoicekey{variant}{\xpgpresetvalue{american} (= \xpgvalue{us}), \xpgvalue{usmax} (same as \xpgvalue{american} but with additional hyphenation patterns),
+	\xpgvalue{british} (= \xpgvalue{uk}), \xpgvalue{australian}, \xpgvalue{canadian}\new{1.45}, or \xpgvalue{newzealand}}
+	\item \xpgboolkeyfalse{ordinalmonthday}
+		The default value is true for \xpgvalue{variant=british}.
 	\end{itemize}
 
 \subsection{esperanto}\label{esperanto}
@@ -693,17 +971,17 @@
 \subsection{finnish}\label{finnish}
 \paragraph*{Options:}
 \begin{itemize}
-  \item \TB{babelshorthands} = \textit{false} or true. \new{v1.45}
-		if this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
-		of Finnish words are activated:
+  \item \xpgboolkeyfalse[1.45]{babelshorthands}
+		If this is turned on, the following shorthands for fine-tuning hyphenation
+		and micro-typography of Finnish words are activated:
 		\begin{shorthands}
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-                    in the hyphenation patterns (as opposed to ¦\-¦).
+                    in the hyphenation patterns (as opposed to \cmd\-).
         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
                     cases where the hyphen should stick at the following syllable.
         \item[¦"|¦] disables a ligature at this position.
         \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 ¦\slash¦,
+        \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}
 \end{itemize}
@@ -711,90 +989,115 @@
 \subsection{french}\label{french}
 \paragraph*{Options:}
 	\begin{itemize}
-		\item\TB{variant} = \textit{french} or canadian (=~acadian).\new{v1.45}
-		Currently, the three variants do not differ; they are supported for compatibility with \pkg{babel} (where they do not differ either).
-		\item \TB{autospacing} = \textit{true} or false. One of the most distinct features of French typography is the addition
-		of extra spacing around punctuation and quotation marks (guillemets). By default, polyglossia adds these spaces automatically, so you don't need
-		to enter them. This options allows you to switch this feature off globally.
-		\item \TB{thincolonspace}\new{v1.46} = true or \textit{false}. Normally, a
-		full (non-breaking) interword space is inserted before a colon. Use this
-		option if you prefer a thinner space as used before \texttt{;}, \texttt{!},
-		and \texttt{?}.
-		\item \TB{autospaceguillemets}\footnote{Up to version 1.44, the option was
-		called \textit{automaticspacesaroundguillemets}. For backards compatibility
-		reasons, the more verbose old option is still supported.} = \textit{true}
-		or false. If you only want to disable the automatic addition of spacing
-		after opening and before closing guillemets (and not at punctuation), set
-		this to \textit{false}. Note that the more general option
-		\textit{autospacing} overrides this.
-		\item \TB{autospacetypewriter}\footnote{Babel's syntax \textit{OriginalTypewriter} is also supported.}\new{1.45} = true or \textit{false} (default value = true). By default, automatic spacing is disabled in typewriter font. If this is enabled, spacing in typewriter context is the same as with roman and sans serif font, depending on the \textit{autospacing} and \textit{autospaceguillemets} settings (note that this was the default up to v.~1.44).	
-		\item \TB{frenchfootnote} = true or \textit{false} (default value = true). If \textit{true}, footnotes start with a non-superscripted number followed by a dot, as common in French typography. Note that this might interfere with the specific footnote handling of classes or packages.
-		Also note that this option is only functional (by design) if French is the main language.
-		\item \TB{frenchitemlabels}\new{v.1.46} = true or \textit{false} (default value = true). If \textit{true}, itemize item labels use em-dashes throughout,
-		as common in French typography.
-		Note that this option is only functional (by design) if French is the main language. Also, it might interfere with list packages such as \pkg{enumitem}.
-		\item \TB{itemlabels}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of all levels.
-		\item \TB{itemlabeli}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the first level.
-		\item \TB{itemlabelii}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the second level.
-		\item \TB{itemlabeliii}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the third level.
-		\item \TB{itemlabeliv}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the fourth level.
+		\item \xpgchoicekey{variant}{\xpgpresetvalue{french} or \xpgvalue{canadian} (=~\xpgvalue{acadian})\new{1.45}, \xpgvalue{swiss}\new{1.47}}
+			Currently, the only difference between the four variants is that \xpgvalue{swiss}
+			uses \xpgvalue{thincolonspace=true} by default since this conforms to the Swiss
+			conventions.
+		\item \xpgboolkeytrue{autospacing}
+			One of the most distinct features of French typography is the addition of
+			extra spacing around punctuation and quotation marks (guillemets). By
+			default, polyglossia adds these spaces automatically, so you don't need
+			to enter them. This options allows you to switch this feature off
+			globally.
+		\item \xpgboolkeyfalse[1.46]{thincolonspace}
+			With \xpgvalue{variant=swiss}, the default value is \xpgvalue{true}. If \xpgvalue{false}, a full
+			(non-breaking) interword space is inserted before a colon. If \xpgvalue{true}, a
+			thinner space -- as before \texttt{;}, \texttt{!}, and \texttt{?} -- is
+			used. Note that this option must be set after the ¦variant¦ option.
+		\item \xpgboolkeytrue{autospaceguillemets}[Up to version 1.44, the option was
+		called \xpgvalue{automaticspacesaroundguillemets}. For backwards compatibility
+		reasons, the more verbose old option is still supported.]
+			If you only want to disable the automatic addition of spacing after
+			opening and before closing guillemets (and not at punctuation), set this
+			to \textit{false}. Note that the more general option \textit{autospacing}
+			overrides this.
+		\item \xpgboolkeyfalse[1.45]{autospacetypewriter}[Babel's syntax \xpgvalue{OriginalTypewriter}
+		is also supported.]
+			By default, automatic spacing is disabled in typewriter font. If this is
+			enabled, spacing in typewriter context is the same as with roman and sans
+			serif font, depending on the \xpgvalue{autospacing} and
+			\xpgvalue{autospaceguillemets} settings (note that this was the default up
+			to v.~1.44).	
+		\item \xpgboolkeyfalse{frenchfootnote}
+			If \xpgvalue{true}, footnotes start with a non-superscripted number
+			followed by a dot, as common in French typography. Note that this might
+			interfere with the specific footnote handling of classes or packages.
+			Also note that this option is only functional (by design) if French is
+			the main language.
+		\item \xpgboolkeyfalse[1.46]{frenchitemlabels}
+			If \textit{true}, itemize item labels use em-dashes throughout, as common
+			in French typography.  Note that this option is only functional (by
+			design) if French is the main language. Also, it might interfere with
+			list packages such as \pkg{enumitem}.
+		\item \xpgcodekey[1.46]{itemlabels}¦\textemdash¦
+			If \emph{frenchitemlabels} is true, you can customize here the used item
+			label of all levels.
+		\item \xpgcodekey[1.46]{itemlabeli}¦\textemdash¦
+			If \emph{frenchitemlabels} is true, you can customize here the used item
+			label of the first level.
+		\item \xpgcodekey[1.46]{itemlabelii}¦\textemdash¦
+			If \emph{frenchitemlabels} is true, you can customize here the used item
+			label of the second level.
+		\item \xpgcodekey[1.46]{itemlabeliii}¦\textemdash¦
+			If \emph{frenchitemlabels} is true, you can customize here the used item
+			label of the third level.
+		\item \xpgcodekey[1.46]{itemlabeliv}¦\textemdash¦
+			If \emph{frenchitemlabels} is true, you can customize here the used item
+			label of the fourth level.
 	\end{itemize}
 \paragraph*{Commands:}
 \begin{itemize}
-	\item \Cmd\NoAutoSpacing\new{v1.45} disables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\NoAutoSpacing foo:bar}¦
-	\item \Cmd\AutoSpacing\new{v1.45} enables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\AutoSpacing regarde!}¦
+	\item \Cmd\NoAutoSpacing\new{1.45} disables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\NoAutoSpacing foo:bar}¦
+	\item \Cmd\AutoSpacing\new{1.45} enables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\AutoSpacing regarde!}¦
 \end{itemize}
 
-\subsection[gaelic]{gaelic\new{v1.45}}\label{gaelic}
+\subsection[gaelic]{gaelic\new{1.45}}\label{gaelic}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant} = \textit{irish} or scottish
+	\item \xpgchoicekey{variant}{\xpgpresetvalue{irish} or \xpgvalue{scottish}}
 \end{itemize}
 
-\subsection[georgian]{georgian\new{v1.46}}\label{georgian}
+\subsection[georgian]{georgian\new{1.46}}\label{georgian}
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true.
-	If this is turned on, the following shorthands are activated:
-	\begin{shorthands}
-		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		in the hyphenation patterns (as opposed to ¦\-¦).
-		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
-		cases where the hyphen should stick at the following syllable.
-		\item[¦"|¦] disables a ligature at this position.
-		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
-		\item[¦"---¦] Cyrillic emdash in plain text.
-		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
-		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
-		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
-		\item[¦"‘¦] for German left double quotes (looks like ,,).
-		\item[¦"’¦] for German right double quotes (looks like “).
-		\item[¦"<¦] for French left double quotes (looks like <<).
-		\item[¦">¦] for French right double quotes (looks like >>).
-	\end{shorthands}
-	\item \TB{numerals} = \textit{arabic} or georgian. Uses either Arabic numerals or Georgian
-	      alphanumerical numbering.
-    \item \TB{oldmonthnames} = \textit{true} or false (default: false). Uses traditional Georgian
-          month names.
+	\item \xpgboolkeyfalse{babelshorthands}
+		If this is turned on, the following shorthands are activated:
+		\begin{shorthands}
+			\item[¦"-¦] adds a hyphenation point that does still allow for
+			hyphenation at the points preset in the hyphenation patterns (as opposed
+			to \cmd\-).
+			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+			cases where the hyphen should stick at the following syllable.
+			\item[¦"|¦] disables a ligature at this position.
+			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+			\item[¦"---¦] Cyrillic emdash in plain text.
+			\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
+			\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
+			\item[¦",¦] thinspace for initials with a breakpoint in following surname.
+			\item[¦"‘¦] for German left double quotes (looks like ,,).
+			\item[¦"’¦] for German right double quotes (looks like “).
+			\item[¦"<¦] for French left double quotes (looks like <<).
+			\item[¦">¦] for French right double quotes (looks like >>).
+		\end{shorthands}
+	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic} or \xpgvalue{georgian}}
+		Uses either Arabic numerals or Georgian alphanumerical numbering.
+	\item \xpgboolkeyfalse{oldmonthnames}
+		Uses traditional Georgian month names.
 \end{itemize}
 
 \subsection{german}\label{german}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item\TB{variant} = \textit{german}, austrian or swiss.\new{v1.33.4}
-		Setting variant=austrian or variant=swiss uses some lexical variants.
-		With spelling=old, variant=swiss furthermore loads specific hyphenation
+	\item \xpgchoicekey{variant}{\xpgpresetvalue{german}, austrian, or swiss\new{1.33.4}}
+		Setting \xpgvalue{variant=austrian} or \xpgvalue{variant=swiss} uses some lexical variants.
+		With \xpgvalue{spelling=old}, \xpgvalue{variant=swiss} furthermore loads specific hyphenation
 		patterns.
-	\item \TB{spelling} = \textit{new} (= 1996) or old (= 1901):
-		indicates whether hyphenation patterns for traditional (1901) or reformed
+	\item \xpgchoicekey{spelling}{\xpgpresetvalue{new} (= \xpgvalue{1996}) or \xpgvalue{old} (= \xpgvalue{1901})}
+		Indicates whether hyphenation patterns for traditional (1901) or reformed
 		(1996) orthography should be used. The latter is the default.
-	\item \TB{latesthyphen} = \textit{false} or true: if this option is set to true,
-		the latest (experimental) hyphenation patterns ‘(n)german-x-latest’
-		will be loaded instead of ‘german’ or ‘ngerman’. NB: This is based on
-		the file \texttt{language.dat} that comes with \TeX Live 2008 and later.
-	\item\TB{babelshorthands} = \textit{false} or true: \new{v1.0.3}
-		if this is turned on, all shorthands defined in \pkg{babel}
+	\item \xpgboolkeyfalse[1.0.3]{babelshorthands}
+		If this is turned on, all shorthands defined in \pkg{babel}
 		for fine-tuning hyphenation and micro-typography of German words are activated.
 		\begin{shorthands}
 		\item[¦"ck¦] for ¦ck¦ to be hyphenated as ¦k-k¦ (1901 spelling).
@@ -804,12 +1107,12 @@
 		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
 		           other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
-		           cases where the hyphen should stick at the following syllable,\eg ¦bergauf und "~ab¦.
+		           cases where the hyphen should stick at the following syllable, \eg ¦bergauf und "~ab¦.
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		           in the hyphenation patterns (as opposed to ¦\-¦).
-		\item[¦""¦] allows for a line break at this position (without hyphenation sign); 
+		           in the hyphenation patterns (as opposed to \cmd\-).
+		\item[¦""¦] allows for a line break at this position (without hyphenation sign);
 		           \eg ¦(pseudo"~)""wissenschaftlich¦.
-		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to ¦\slash¦, hyphenation at the breakpoints
+		\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}
 
@@ -820,7 +1123,7 @@
 		\item[¦"<¦] for French left double quotes («)
 		\item[¦">¦] for French right double quotes (»).
 		\end{shorthands}
-	\item\TB{script} = \textit{latin} or blackletter\new{v1.46} (=~fraktur\new{v1.2.0}).
+	\item \xpgchoicekey[1.2.0]{script}{\xpgpresetvalue{latin} or \xpgvalue{blackletter}\new{1.46} (= \xpgvalue{fraktur})}
 		Setting ¦script=blackletter¦ adapts the captions for typesetting German in blackletter type (using the long s (ſ)
 		where appropriate).
 	\end{itemize}
@@ -828,9 +1131,9 @@
 \subsection{greek}\label{greek}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{variant} = \textit{monotonic} (= mono), polytonic (= poly), or ancient
-	\item \TB{numerals} = \textit{greek} or arabic
-	\item \TB{attic} = \textit{false}/true
+	\item \xpgchoicekey{variant}{\xpgpresetvalue{monotonic} (= \xpgvalue{mono}), \xpgvalue{polytonic} (= \xpgvalue{poly}), or \xpgvalue{ancient}}
+	\item \xpgchoicekey{numerals}{\xpgpresetvalue{greek} or \xpgvalue{arabic}}
+	\item \xpgboolkeyfalse{attic}
 	\end{itemize}
 \paragraph*{Commands:}
 	\begin{itemize}
@@ -845,10 +1148,12 @@
 \subsection{hebrew}\label{hebrew}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{numerals} = hebrew or \textit{arabic}
-	\item \TB{calendar} = hebrew or \textit{gregorian}
-	\item \TB{marcheshvan} = true or \textit{false} (default value = true). If true, the second month of the civil year will be output as \texthebrew{מרחשון} (Marcheshvan)
-	rather than \texthebrew{חשון} (Heshvan), which is the default.
+	\item \xpgchoicekey{numerals}{\xpgvalue{hebrew} or \xpgpresetvalue{arabic}}
+	\item \xpgchoicekey{calendar}{\xpgvalue{hebrew} or \xpgpresetvalue{gregorian}}
+	\item \xpgboolkeyfalse{marcheshvan}
+		If \xpgvalue{true}, the second month of the civil year will be output as
+		\texthebrew{מרחשון} (Marcheshvan) rather than \texthebrew{חשון} (Heshvan),
+		which is the default.
 	\end{itemize}
 \paragraph*{Commands:}
 	\begin{itemize}
@@ -856,17 +1161,17 @@
   \item \Cmd\aemph (see section \ref{arabic}).
 	\end{itemize}
 
-\subsection[hindi]{hindi\new{v1.2.0}}\label{hindi}
+\subsection[hindi]{hindi\new{1.2.0}}\label{hindi}
 \paragraph*{Options:}
 	\begin{itemize}
-    \item \TB{numerals} = Western or \textit{Devanagari}
+		\item \xpgchoicekey{numerals}{\xpgvalue{Western} or \xpgpresetvalue{Devanagari}}
 	\end{itemize}
 
 \subsection{hungarian}\label{hungarian}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{swapstrings} = \textit{all}, captions, headings, headers, hheaders or none\new{v1.46}
-	      
+	\item \xpgchoicekey[1.46]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
+	\xpgvalue{captions}, \xpgvalue{headings}, \xpgvalue{headers}, \xpgvalue{hheaders}, or \xpgvalue{none}}
 	       In Hungarian, some caption strings need to be in a different order than in other languages
 	       (\eg \emph{1. fejezet} instead of \emph{Chapter 1}). By default, \pkg{polyglossia} tries hard to
 	       provide the correct order for different classes and packages (standard classes, \pkg{KOMA-script},
@@ -893,7 +1198,7 @@
 \subsection{italian}\label{italian}
 \paragraph*{Options:}
 \begin{itemize}
-  \item \TB{babelshorthands} = \textit{false} or true. \new{v1.2.0cc}% TODO: check version
+  \item \xpgboolkeyfalse[1.2.0cc]{babelshorthands}% TODO: check version
   Activates the ¦"¦ character as a switch to perform etymological
   hyphenation when followed by a letter. Furthermore, the following shorthands are activated:
   \begin{shorthands}
@@ -900,34 +1205,59 @@
   	\item[¦""¦] double raised open quotes (the Italian keyboard misses the backtick).
   	\item[¦"<¦] open guillemet (looks like <<).
   	\item[¦">¦] closing guillemet (looks like >>).
-  	\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to ¦\slash¦,
+  	\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[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-               in the hyphenation patterns (as opposed to ¦\-¦).
+               in the hyphenation patterns (as opposed to \cmd\-).
   \end{shorthands}
 \end{itemize}
 
-\subsection[korean]{korean\new{v1.40.0}}\label{korean}
+\subsection[korean]{korean\new{1.40.0}}\label{korean}
 \paragraph*{Options:}
   \begin{itemize}
-  \item \TB{variant} = \textit{plain}, classic or modern:
-    for spacing before/after CJK punctuations.
-    `classic' is suitable for text with no interword spaces,
-    `modern' for text with interword spaces.
-  \item \TB{captions} = \textit{hangul} or hanja
+	\item \xpgchoicekey{variant}{\xpgpresetvalue{plain}, \xpgvalue{classic}, or \xpgvalue{modern}}
+    These variants control spacing before/after CJK punctuations.
+      \begin{itemize}
+        \item ¦plain¦: Do nothing
+        \item ¦classic¦: Suitable for text with no interword spaces.
+          This option forces CJK punctuations to half-width, and
+          inserts half-width glue around them.
+        \item ¦modern¦: Suitable for text with interword spaces.
+          This option forces CJK punctuations to half-width, and
+          inserts small (half of interword space) glue around them.
+      \end{itemize}
+	\item \xpgchoicekey{captions}{\xpgpresetvalue{hangul} or \xpgvalue{hanja}}
+	\item \xpgchoicekey[1.47]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
+	\xpgvalue{headers}, \xpgvalue{headings}, or \xpgvalue{none}}
+    With this option, Korean-style part and chapter headings, and
+    running headers are available.
+    It is similar to Hungarian (see \ref{hungarian}) except that
+    figure and table captions are not touched.
+      \begin{itemize}
+        \item ¦all¦: Redefine part and chapter headings, and running headers
+          (=~default setting)
+        \item ¦headings¦: Redefine part and chapter headings only
+        \item ¦headers¦: Redefine running headers only
+        \item ¦none¦: Do not redefine anything
+      \end{itemize}
   \end{itemize}
 
-\subsection[kurdish]{kurdish\new{v1.45}}\label{kurdish}
+\subsection[kurdish]{kurdish\new{1.45}}\label{kurdish}
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant} = kurmanji or \textit{sorani}
-	\item \TB{script} = Arabic or Latin. Defaults are ¦Arabic¦ for Sorani and ¦Latin¦ for Kurmanji.
-	\item \TB{numerals} = western or eastern. Defaults are ¦western¦ for Latin and ¦eastern¦ for Arabic script, depending on the selection above.
-	\item \TB{abjadjimnotail} = \textit{false} or true.
-	Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
-%	\item \TB{locale} (not yet implemented)
-%	\item \TB{calendar} (not yet implemented)
+	\item \xpgchoicekey{variant}{\xpgvalue{kurmanji} or \xpgpresetvalue{sorani}}
+	\item \xpgchoicekey{script}{\xpgvalue{Arabic} or \xpgvalue{Latin}}
+		Defaults are \xpgvalue{Arabic} for Sorani and \xpgvalue{Latin} for Kurmanji.
+	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgvalue{eastern}}
+		Defaults are \xpgvalue{western} for Latin and \xpgvalue{eastern} for Arabic script, depending
+		on the selection above.
+	\item \xpgboolkeyfalse{abjadjimnotail}
+		Set this to true if you want the \textit{abjad} form of the number three to
+		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
+		modern usage \textarabic{ج}.
+%	\item \xpgchoicekey{locale}{} (not yet implemented)
+%	\item \xpgchoicekey{calendar}{} (not yet implemented)
 \end{itemize}
 \condbreak{2\baselineskip}
 \paragraph*{Commands:}
@@ -938,19 +1268,18 @@
 	\item \Cmd\aemph (see section \ref{arabic})
 \end{itemize}
 
-\subsection[lao]{lao\new{v1.2.0}}\label{lao}
+\subsection[lao]{lao\new{1.2.0}}\label{lao}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{numerals} = lao or \textit{arabic}
+	\item \xpgchoicekey{numerals}{\xpgvalue{lao} or \xpgpresetvalue{arabic}}
 	\end{itemize}
 
 \subsection{latin}\label{latin}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant} = classic, medieval, \emph{modern}, or ecclesiastic\new{v.1.46}
-
-			These variants refer to different spelling conventions. The ¦classic¦
-			and the ¦medieval¦ variant do not use the letters \emph{U} and
+	\item \xpgchoicekey{variant}{\xpgvalue{classic}, \xpgvalue{medieval}, \xpgpresetvalue{modern}, or \xpgvalue{ecclesiastic}\new{1.46}}
+			These variants refer to different spelling conventions. The \xpgvalue{classic}
+			and the \xpgvalue{medieval} variant do not use the letters \emph{U} and
 			\emph{v}, but only \emph{V} and \emph{u}. This concerns predefined terms like
 			month names as well as the behaviour of the \cmd\MakeUppercase\ and the
 			\cmd\MakeLowercase\ command. The ¦medieval¦ and the
@@ -957,7 +1286,7 @@
 			¦ecclesiastic¦ variant use the ligatures \emph{\ae} and \emph{\oe}.
 			See table \ref{tab:latin-spelling} for examples.
 
-			Furthermore, the \texttt{ecclesiastic} variant takes care for a punctuation
+			Furthermore, the \xpgvalue{ecclesiastic} variant takes care for a punctuation
 			spacing similar to French, but with smaller spaces, as provided for
 			PDF\TeX\ by the \pkg{ecclesiastic} package.
 			\begin{table}
@@ -964,8 +1293,8 @@
 			\centering
 			\caption{\label{tab:latin-spelling}Spelling differences between the Latin
 				language variants.\newline The capitalization of month names and the use of
-				\emph{i/j} may be affected by the \texttt{capitalizemonth} and the
-				\texttt{usej} option.}
+				\emph{i/j} may be affected by the \xpgvalue{capitalizemonth} and the
+				\xpgvalue{usej} option.}
 			\begin{tabular}{llll}
 			\toprule
 			\textbf{classic} & \textbf{medieval} & \textbf{modern} & \textbf{ecclesiastic} \\
@@ -978,8 +1307,7 @@
 			\bottomrule
 			\end{tabular}
 			\end{table}
-	\item \TB{hyphenation}\new{v.1.46} = classic, modern, or liturgical
-
+	\item \xpgchoicekey[1.46]{hyphenation}{\xpgvalue{classic}, \xpgvalue{modern}, or \xpgvalue{liturgical}}
 			There are three different sets of hyphenation patterns for Latin. Separate
 			documention for them is available on the
 			Internet.\footnote{\url{https://github.com/gregorio-project/hyphen-la/blob/master/doc/README.md\#hyphenation-styles}}
@@ -988,7 +1316,7 @@
 			¦hyphenation¦ option if the default style does not fit your needs.
 			Note that the liturgical hyphenation patterns are the default of none of the
 			language variants. To use them, you have to say
-			¦hyphenation=liturgical¦ in any case.
+			\xpgvalue{hyphenation=liturgical} in any case.
 			\begin{table}
 			\caption{\label{tab:latin-hyphenation}Latin default hyphenation styles}
 			\centering
@@ -1003,8 +1331,7 @@
 			\bottomrule
 			\end{tabular}
 			\end{table}
-	\item \TB{ecclesiasticfootnotes}\new{v.1.46} = true or \emph{false}
-
+	\item \xpgboolkeyfalse[1.46]{ecclesiasticfootnotes}
 			Use footnotes as provided by the \pkg{ecclesiastic} package, which typesets
 			footnotes with ordinary instead of superior numbers and without indentation.
 			As many ecclesiastic documents and liturgical books use footnotes that are
@@ -1013,8 +1340,7 @@
 		
 			Note that this option is only possible if Latin is the main language of your
 			document.
-	\item \TB{usej}\new{v.1.46} = true or \emph{false}
-
+	\item \xpgboolkeyfalse[1.46]{usej}
 			Use \emph{J/j} in predefined terms. The letter \emph{j} is not of ancient
 			origin. In early modern times, it was used to distinguish the consonantic
 			\emph{i} from the vocalic~\emph{i}. Nowadays, the use of \emph{j} has
@@ -1021,8 +1347,7 @@
 			disappeared from most Latin publications. So ¦false¦ is the default
 			value for all four language variants. Use this option if you prefer
 			\emph{Januarii} and \emph{Maji} to \emph{Ianuarii} and \emph{Maii}.
-			\item \TB{capitalizemonth}\new{v.1.46} = true or false
-		
+	\item \xpgboolkey[1.46]{capitalizemonth}
 			Capitalize the month name when printing dates (using the \cmd\today\
 			command).  Traditionally, month names are capitalized. However, in recent
 			liturgical books they are lowercase. So ¦true¦ is the default value for
@@ -1029,8 +1354,7 @@
 			the variants ¦classic¦, ¦medieval¦, and ¦modern¦,
 			whereas ¦false¦ is the default value for the ¦ecclesiastic¦
 			variant.
-	\item \TB{babelshorthands} = true or \emph{false}
-
+	\item \xpgboolkeyfalse{babelshorthands}
 			Enable the following shorthands inherited from \pkg{babel-latin} and the
 			\pkg{ecclesiastic} package.
 			\begin{shorthands}
@@ -1056,14 +1380,12 @@
 				\item[¦'Ae¦] for Ǽ (AE ligature with acute), also available for \'Œ
 				\item[¦'AE¦] for Ǽ (AE ligature with acute), also available for \'Œ
 			\end{shorthands}
-	\item \TB{prosodicshorthands}\new{v.1.46} = true or \emph{false}
-
+	\item \xpgboolkeyfalse[1.46]{prosodicshorthands}
 			Enable shorthands for prosodic marks (macrons and breves) very similiar to
 			those provided by \pkg{babel-latin} using the ¦withprosodicmarks¦
 			modifier.
-		
 			Note that the active ¦=¦ character used for macrons will cause problems with
-			commands using \texttt{key=value} interfaces, \eg
+			commands using \texttt{key=value} interfaces, such as the command
 			¦\includegraphics[scale=2]{...}¦. Use \cmd{\shorthandoff\{=\}} before
 			such commands (and \cmd{\shorthandon\{=\}} thereafter) within every
 			environment with prosodic shorthands enabled.
@@ -1096,20 +1418,25 @@
 \subsection{malay}\label{malay}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant}\new{v1.45} = \textit{indonesian} (=~bahasai in \pkg{babel}) or
-	malaysian (=~bahasam in \pkg{babel})
+	\item \xpgchoicekey[1.45]{variant}{\xpgpresetvalue{indonesian} or \xpgvalue{malaysian}}
 \end{itemize}
 
-\subsection[mongolian]{mongolian\new{v1.45}}\label{mongolian}
+\subsection{marathi}\label{marathi}
+\paragraph*{Options:}
+\begin{itemize}
+	\item \xpgchoicekey{numerals}{\xpgpresetvalue{Devanagari} or \xpgvalue{Western}}
+\end{itemize}
+
+\subsection[mongolian]{mongolian\new{1.45}}\label{mongolian}
 Currently, only the Khalkha variety in Cyrillic script is supported.
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true.
+	\item \xpgboolkeyfalse{babelshorthands}
 	If this is turned on, the following shorthands are activated:
 	\begin{shorthands}
         \item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		           in the hyphenation patterns (as opposed to ¦\-¦).
+		           in the hyphenation patterns (as opposed to \cmd\-).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 		           cases where the hyphen should stick at the following syllable.
 		\item[¦"|¦] disables a ligature at this position.
@@ -1123,32 +1450,44 @@
 		\item[¦"<¦] for French left double quotes (looks like <<).
 		\item[¦">¦] for French right double quotes (looks like >>).
 	\end{shorthands}
-	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-	alphanumerical numbering.
+	\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}
+	           \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+	                 \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+	                 It supports numbers up to 999\,999.
+          \end{itemize}
 \end{itemize}
 %
 \paragraph*{Commands:}
 \begin{itemize}
-	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-	environments such as ¦enumerate¦. The command takes a counter as argument,
-	\eg ¦\textmongolian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-	\item \Cmd\asbuk: same in lowercase
+    \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+          It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+          The command takes a counter as argument, \eg ¦\textmongolian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+    \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+    \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+          numbers up to 999\,999.\\
+          \Eg ¦\textmongolian{\AsbukTrad{section}}¦ produces \textrussian{\AsbukTrad{section}}.
+    \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 \end{itemize}
 
 \subsection{norwegian}\label{norwegian}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant}\new{v1.45} = bokmal (=~`norsk' in \pkg{babel}) or \textit{nynorsk}
+	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{bokmal} or \xpgpresetvalue{nynorsk}}
 \end{itemize}
 
 \subsection{persian}\label{persian}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{numerals} = western or \textit{eastern}
-	\item \TB{abjadjimnotail} = \textit{false} or true. \new{v1.0.3}
-	Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
-%	\item \TB{locale} (not yet implemented)
-%	\item \TB{calendar} (not yet implemented)
+	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{eastern}}
+	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
+		Set this to \xpgvalue{true} if you want the \textit{abjad} form of the number three to
+		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
+		modern usage \textarabic{ج}.
+%	\item \xpgchoicekey{locale}{} (not yet implemented)
+%	\item \xpgchoicekey{calendar}{} (not yet implemented)
 \end{itemize}
 \paragraph*{Commands:}
 \begin{itemize}
@@ -1159,17 +1498,17 @@
 \subsection{portuguese}\label{portuguese}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant}\new{v1.45} = brazilian or \textit{portuguese}
+	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
 \end{itemize}
 
 \subsection{russian}\label{russian}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true.
+	\item \xpgboolkeyfalse{babelshorthands}
 	If this is turned on, the following shorthands are activated:
 	\begin{shorthands}
 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-		           in the hyphenation patterns (as opposed to ¦\-¦).
+		           in the hyphenation patterns (as opposed to \cmd\-).
 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 		           cases where the hyphen should stick at the following syllable.
 		\item[¦"|¦] disables a ligature at this position.
@@ -1184,48 +1523,72 @@
 %		\item[¦"<¦] for French left double quotes (looks like <<).
 %		\item[¦">¦] for French right double quotes (looks like >>).
 	\end{shorthands}
-    \item \TB{indentfirst}\new{v1.46} = \textit{true} or false. By default, all paragraphs are indented in Russian,
-          also those after a chapter or section heading. If this option is false, the latter paragraphs
-          are not indented, as normal in \LaTeX. 
-	\item \TB{spelling} = \textit{modern} or old (for captions and date only, not for hyphenation)
-	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-	alphanumerical numbering.
+	\item \xpgboolkeytrue[1.46]{indentfirst}
+		By default, all paragraphs are indented in Russian, also those after a
+		chapter or section heading. If this option is false, the latter paragraphs
+		are not indented, as normal in \LaTeX.
+	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{old}}
+		This option is for captions and date only, not for hyphenation.
+	\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}
+			\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+			\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+			      \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+			      It supports numbers up to 999\,999.
+		\end{itemize}
 	\end{itemize}
 %
 \paragraph*{Commands:}
 	\begin{itemize}
-	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-	environments such as ¦enumerate¦. The command takes a counter as argument,
-	\eg ¦\textrussian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-	\item \Cmd\asbuk: same in lowercase
+	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+	      It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+	      The command takes a counter as argument, \eg ¦\textrussian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+	      numbers up to 999\,999.\\
+	      \Eg ¦\textrussian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 	\end{itemize}
 
-\subsection[sami]{sami\new{v1.45}}\label{sami}
+\subsection[sami]{sami\new{1.45}}\label{sami}
 Currently support for Sami is limited to Northern Sami.
 
 \subsection{sanskrit}\label{sanskrit}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{script} = \textit{Devanagari}\new{v1.0.2}, Gujarati, Malayalam, Bengali, Kannada,
-	Telugu or Latin.
-	The value is passed to \pkg{fontspec} in cases where the respective ¦\⟨script⟩font¦ is not defined.
-	This can be useful if you typeset Sanskrit texts in scripts other than Devanagari.
-	\item \TB{numerals} = \textit{Devanagari}\new{v1.45} or Western
+	\item \xpgchoicekey[1.0.2]{script}{\xpgpresetvalue{Devanagari}, \xpgvalue{Gujarati},
+	\xpgvalue{Malayalam}, \xpgvalue{Bengali}, \xpgvalue{Kannada}, \xpgvalue{Telugu}, or \xpgvalue{Latin}}
+		The value is passed to \pkg{fontspec} in cases where the respective
+		\cmd{\⟨script⟩font} is not defined.  This can be useful if you typeset Sanskrit
+		texts in scripts other than Devanagari.
+	\item \xpgchoicekey[1.45]{numerals}{\xpgpresetvalue{Devanagari} or \xpgvalue{Western}}
 	\end{itemize}
- 
+
 \subsection{serbian}\label{serbian}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{script} = \textit{Cyrillic} or Latin.
-	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-	      alphanumerical numbering.
-	\end{itemize}
+	\item \xpgchoicekey{script}{\xpgpresetvalue{Cyrillic} or \xpgvalue{Latin}}
+	\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}
+               \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+	                  \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+	                  It supports numbers up to 999\,999.
+          \end{itemize}
+\end{itemize}
+%
 \paragraph*{Commands:}
 \begin{itemize}
-	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-	environments such as ¦enumerate¦. The command takes a counter as argument,\\
-	Example: ¦\textserbian[numerals=cyrillic]{\Asbuk{page}}¦ produces \textserbian[numerals=cyrillic]{\Asbuk{page}}.
-	\item \Cmd\asbuk: same in lowercase
+    \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+          It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+          The command takes a counter as argument, \eg ¦\textserbian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+    \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+    \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+          numbers up to 999\,999.\\
+          \Eg ¦\textserbian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+    \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 \end{itemize}
 
 
@@ -1233,9 +1596,9 @@
 
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.46}
-	if this is turned on, the following shorthands for Slovak are activated:
-	\begin{shorthands}
+	\item \xpgboolkeyfalse[1.46]{babelshorthands}
+		If this is turned on, the following shorthands for Slovak are activated:
+		\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¦).
@@ -1243,16 +1606,16 @@
         \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 ¦\-¦).
+                    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 ¦\slash¦, hyphenation at the breakpoints
+        \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 Slovak left double quotes (looks like ,,).
         \item[¦"’¦] for Slovak right double quotes (looks like “).
         \item[¦">¦] for Slovak left double guillemets (looks like >>).
         \item[¦"<¦] for Slovak right double guillemets (looks like <<).
-	\end{shorthands}
-	\item \TB{splithyphens} = \textit{false} or true. \new{v1.46}
+		\end{shorthands}
+	\item \xpgboolkeytrue[1.46]{splithyphens}
 	      According to Slovak 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}).
@@ -1259,7 +1622,7 @@
 	      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 \TB{vlna} = \textit{false} or true. \new{v1.46}
+	\item \xpgboolkeytrue[1.46]{vlna}
 	      According to Slovak typesetting conventions, single-letter words (non-syllable prepositions)
 	      must not occur at line ends.
 	      \pkg{Polyglossia} takes care of this automatically by default (if you are using \LuaTeX, the
@@ -1270,26 +1633,31 @@
 \subsection{slovenian}\label{slovenian}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{localalph} = true or \textit{false}
+	\item \xpgboolkeyfalse{localalph}
+	      If \xpgvalue{true}, alpha-numeric counters will use a localized version including characters with caron
+	      (a, b, c, č, d, \ldots).
 	\end{itemize}
 
 \subsection{sorbian}\label{sorbian}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant}\new{v1.45} = lower or \textit{upper}
-	\item \TB{olddate}\new{v1.45} = true or \textit{false} (default value = true). If true, ¦\today¦
-	      will use traditional Sorbian month names (\ie it will be synonymous to ¦\oldtoday¦ below)
+	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{lower} or \xpgpresetvalue{upper}}
+	\item \xpgboolkeyfalse[1.45]{olddate}
+		If \xpgvalue{true}, \cmd\today\ will use traditional Sorbian month names (\ie it will be
+		synonymous to \cmd\oldtoday\ below).
 \end{itemize}
 \paragraph*{Commands:}
 \begin{itemize}
-	\item \Cmd\oldtoday: outputs the current date using traditional Sorbian month names, even if \TB{olddate} is false.
+	\item \Cmd\oldtoday: outputs the current date using traditional Sorbian month names, even if
+	       \xpgvalue{olddate} is \xpgvalue{false}.
 \end{itemize}
 
 \subsection{spanish}\label{spanish}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{variant} = \textit{spanish} or mexican.\new{v1.46}
-	\item \TB{spanishoperators} = all, accented, spaced or none or \textit{false} (default value = all).\new{v1.46}
+	\item \xpgchoicekey[1.46]{variant}{\xpgpresetvalue{spanish} or \xpgvalue{mexican}}
+	\item \xpgchoicekey[1.46]{spanishoperators}{\xpgdefaultvalue{all}, \xpgvalue{accented},
+	\xpgvalue{spaced}, \xpgvalue{none}, or \xpgpresetvalue{false}}
 	      Determines of and how math operators are localized to Spanish.
 	      \begin{itemize}
 	      	\item ¦accented¦ causes some math operators to use accents where usual in Spanish (\emph{lím},
@@ -1297,20 +1665,20 @@
 	      	\item ¦spaced¦ causes some math operators to use spaces where usual in Spanish (\emph{arc\,cos},
 	      	      \emph{arc\,sen}, \emph{arc\,tg}).
 	      	\item ¦all¦ activates ¦accented¦ and ¦spaced¦ and furthermore provides Spanish localizations of
-	      	      ¦\sin¦ (\emph{sen}), ¦\tan¦ (\emph{tg}), ¦\sinh¦ (\emph{senh}), and ¦\tanh¦ (\emph{tgh}).
-	      	\item ¦none¦ does no localization at all (default setting). 
+	      	      \cmd\sin\ (\emph{sen}), \cmd\tan\ (\emph{tg}), \cmd\sinh\ (\emph{senh}), and \cmd\tanh\ (\emph{tgh}).
+	      	\item ¦none¦ does no localization at all (default setting).
 	      \end{itemize}
 \end{itemize}
-\paragraph*{\color{black}Commands:}\new{v1.46}
+\paragraph*{\color{black}Commands:}\new{1.46}
 \begin{itemize}
-	\item \Cmd\arcsen: alias to ¦\arcsin¦ (\pkg{babel} compatibility)
-	\item \Cmd\arctg: alias to ¦\arctan¦ (\pkg{babel} compatibility)
-	\item \Cmd\sen: alias to ¦\sin¦ (\pkg{babel} compatibility)
-	\item \Cmd\senh: alias to ¦\sinh¦ (\pkg{babel} compatibility)
-	\item \Cmd\tg: alias to ¦\tan¦ (\pkg{babel} compatibility)
-	\item \Cmd\tgh: alias to ¦\tanh¦ (\pkg{babel} compatibility)
+	\item \Cmd\arcsen: alias to \cmd\arcsin\ (\pkg{babel} compatibility)
+	\item \Cmd\arctg: alias to \cmd\arctan\ (\pkg{babel} compatibility)
+	\item \Cmd\sen: alias to \cmd\sin\ (\pkg{babel} compatibility)
+	\item \Cmd\senh: alias to \cmd\sinh\ (\pkg{babel} compatibility)
+	\item \Cmd\tg: alias to \cmd\tan\ (\pkg{babel} compatibility)
+	\item \Cmd\tgh: alias to \cmd\tanh\ (\pkg{babel} compatibility)
 	\item \Cmd\spanishoperator: allows you to define further localized operators. For instance, ¦\spanishoperator{cotg}¦
-	      defines a command ¦\cotg¦ that outputs \emph{cotg} in math. The optional argument of the command lets you specify the
+	      defines a command \cmd\cotg\ that outputs \emph{cotg} in math. The optional argument of the command lets you specify the
 	      spelling, if needed, \eg ¦\spanishoperator[arc\,ctg]{arcctg}¦.
 \end{itemize}
 
@@ -1317,9 +1685,9 @@
 \subsection{syriac}\label{syriac}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{numerals} = \textit{western} (i.e., 1234567890), eastern
-		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}),
-		or abjad. \new{v1.0.1}.
+	\item \xpgchoicekey[1.0.1]{numerals}{\xpgpresetvalue{western} (\ie 1234567890), \xpgvalue{eastern}
+		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}), or
+		\xpgvalue{abjad}}
 	\end{itemize}
 \paragraph*{Commands:}
 	\begin{itemize}
@@ -1330,7 +1698,7 @@
 \subsection{thai}\label{thai}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{numerals} = thai or \textit{arabic}
+	\item \xpgchoicekey{numerals}{\xpgvalue{thai} or \xpgpresetvalue{arabic}}
 	\end{itemize}
 %
 To insert word breaks, you need to use an external processor.
@@ -1340,21 +1708,58 @@
 \subsection{tibetan}\label{tibetan}
 \paragraph*{Options:}
 \begin{itemize}
-	\item \TB{numerals} = tibetan or \textit{arabic}
+	\item \xpgchoicekey{numerals}{\xpgvalue{tibetan} or \xpgpresetvalue{arabic}}
 \end{itemize}
 
 \subsection{ukrainian}\label{ukrainian}
-\paragraph*{Commands:}
+
+\paragraph*{Options:}
+\begin{itemize}
+	\item \xpgboolkeyfalse{babelshorthands}
+	If this is turned on, the following shorthands are activated:
+	\begin{shorthands}
+		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
+		in the hyphenation patterns (as opposed to \cmd\-).
+		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+		cases where the hyphen should stick at the following syllable.
+		\item[¦"|¦] disables a ligature at this position.
+		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+		\item[¦"---¦] Cyrillic emdash in plain text.
+		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
+		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
+		% These are commented out in gloss-ukrainian
+		%		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
+		%		\item[¦"‘¦] for German left double quotes (looks like ,,).
+		%		\item[¦"’¦] for German right double quotes (looks like “).
+		%		\item[¦"<¦] for French left double quotes (looks like <<).
+		%		\item[¦">¦] for French right double quotes (looks like >>).
+	\end{shorthands}
+	\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}
-	\item \Cmd\Asbuk: produces the uppercase Ukrainian alphabet, for
-	environments such as ¦enumerate¦
-	\item \Cmd\asbuk: same in lowercase
+		\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+		\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+		\footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+		It supports numbers up to 999\,999.
 	\end{itemize}
+\end{itemize}
+%
+\paragraph*{Commands:}
+\begin{itemize}
+	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+	It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+	The command takes a counter as argument, \eg ¦\textukrainian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+	numbers up to 999\,999.\\
+	\Eg ¦\textukrainian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
+\end{itemize}
 
 \subsection{welsh}\label{welsh}
 \paragraph*{Options:}
 	\begin{itemize}
-	\item \TB{date} = long or \textit{short}
+	\item \xpgchoicekey{date}{\xpgvalue{long} or \xpgpresetvalue{short}}
 	\end{itemize}
 
 
@@ -1362,24 +1767,24 @@
 
 \pkg{Polyglossia} uses the following macros to define language-specific captions
 (\ie strings such as ``chapter''), date formats and additional language settings
-(¦⟨lang⟩¦ is to be replaces with the respective language name):
+(\meta{lang} is to be replaces with the respective language name):
 
 \begin{itemize}
-	\item \Cmd{\captions⟨lang⟩} stores definitions of caption strings
+	\item \Cmd{\captions\meta{lang}} stores definitions of caption strings
 	           (such as, in the case of English, ¦\def\chaptername{Chapter}¦)
-	\item \Cmd{\date⟨lang⟩} stores definitions of date formats (usually redefinitions
-	           of ¦\today¦, in some cases also definitions of additional date commands)
-	\item \Cmd{\blockextras⟨lang⟩} stores macros that are to be executed when the language
-              ⟨lang⟩ is activated via ¦\selectlanguage¦ command or the ¦⟨lang⟩¦ environment
-	\item \Cmd{\inlineextras⟨lang⟩} stores macros that are to be executed when the language
-	          ⟨lang⟩ is activated locally via ¦\text⟨lang⟩¦ command
-	\item \Cmd{\noextras⟨lang⟩} stores macros that are to be executed when the language
-	          ¦⟨lang⟩¦ is closed 
-\end{itemize} 
+	\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
+              \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
+	          \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
+	          \meta{lang} is closed
+\end{itemize}
 %
-In order to redefine internal macros, we recommend to use the command ¦\gappto¦.
-For compatibility with \pkg{babel} the command ¦\addto¦ is also available
-to the same effect. For instance, to change the ¦\chaptername¦ for language ¦lingua¦,
+In order to redefine internal macros, we recommend to use the command \cmd\gappto.
+For compatibility with \pkg{babel} the command \cmd\addto\ is also available
+to the same effect. For instance, to change the \cmd\chaptername\ for language ¦lingua¦,
 you can do this:
 \begin{verbatim}
 \gappto\captionslingua{\def\chaptername{Caput}}
@@ -1386,7 +1791,7 @@
 \end{verbatim}
 %
 Note that this needs to be done after the respective language has been loaded with
-¦\setmainlanguage¦ or ¦\setotherlanguage¦.
+\cmd\setmainlanguage\ or \cmd\setotherlanguage.
 
 Specifically for package authors, analogous commands are provided which are only executed
 if a specific language \emph{variety} is used. As opposed to the macros above, these refer
@@ -1393,17 +1798,17 @@
 to babel names. Other than that, the function is identical:
 
 \begin{itemize}
-	\item \Cmd{\captions at bbl@⟨babelname⟩} 
-	\item \Cmd{\date at bbl@⟨babelname⟩}
-	\item \Cmd{\blockextras at bbl@⟨babelname⟩}
-	\item \Cmd{\inlineextras at bbl@⟨babelname⟩}
-	\item \Cmd{\noextras at bbl@⟨babelname⟩} 
+	\item \Cmd{\captions at bbl@\meta{babelname}}
+	\item \Cmd{\date at bbl@\meta{babelname}}
+	\item \Cmd{\blockextras at bbl@\meta{babelname}}
+	\item \Cmd{\inlineextras at bbl@\meta{babelname}}
+	\item \Cmd{\noextras at bbl@\meta{babelname}}
 \end{itemize}
 %
 By default, these macros are undefined. If they are defined (\eg by an external package),
-they will be executed after their respective ¦⟨lang⟩¦ counterpart and thus can be used to
-overwrite definitions of the former. Again, use ¦\gappto¦ to define\slash modify these macros.
-For instance, to add a new caption ¦\footnotename¦ to the Swiss variety of German (babel name
+they will be executed after their respective \meta{lang} counterpart and thus can be used to
+overwrite definitions of the former. Again, use \cmd\gappto\ to define\slash modify these macros.
+For instance, to add a new caption \cmd\footnotename\ to the Swiss variety of German (babel name
 ¦nswissgerman¦), you can do this:
 \begin{verbatim}
 \gappto\captions at bbl@nswissgerman{\def\footnotename{Fussnote}}
@@ -1410,7 +1815,7 @@
 \end{verbatim}
 %
 If you do this in a document preamble rather than in a package, you need to embrace the redefinition
-by ¦\makeatletter¦ and ¦\makeatother¦ due to the ¦@¦ in the macro names.
+by \cmd\makeatletter\ and \cmd\makeatother\ due to the ¦@¦ in the macro names.
 
 \section{Script-specific numbering}
 
@@ -1436,25 +1841,27 @@
 ¦\localnumeral{42}¦ yields \textarabic{\localnumeral{42}}, whereas in an Hebrew environment, it
 results in \texthebrew[numerals=hebrew]{\localnumeral{42}} with ¦numerals=hebrew¦, and \texthebrew{\localnumeral{42}}
 with ¦numerals=arabic¦. Note that, as opposed to the various ¦digits¦ macros (described in sec.~\ref{sec:decdigit}),
-the argument of ¦\localnumeral¦ must consist of numbers only.
+the argument of \cmd\localnumeral\ must consist of numbers only.
 
 For\new{1.45} the conversion of counters, the starred version \Cmd{\localnumeral*} is provided. This takes a counter as argument.
 For instance in an Arabic environment ¦\localnumeral*{page}¦ yields \textarabic{\localnumeral*{page}}.
 
-For scripts with alphanumeric numbering, the variants \Cmd{\Localnumeral} and \Cmd{\Localnumeral*} provide the uppercased 
+For scripts with alphanumeric numbering, the variants \Cmd{\Localnumeral} and \Cmd{\Localnumeral*} provide the uppercased
 versions.\medskip
 
 \noindent All these macros provide the following options:
 
 \begin{itemize}
-	\item \TB{lang} =\DescribeMacro{[lang=]}\ \textit{local}, main, or <language>.\\
-	Output number in the local form of the currently active language for ¦local¦, the main language of the document for ¦main¦,
-    and any (loaded) language for ¦<language>¦ (\eg ¦\localnumeral[lang=arabic]{42}}¦).
+	\item \DescribeMacro{[lang=]}\xpgchoicekey{lang}{\xpgpresetvalue{local}, \xpgvalue{main},
+	or \xpgvalue{\meta{language}}}
+		Output number in the local form of the currently active language for
+		¦local¦, the main language of the document for ¦main¦, and any (loaded)
+		language for \meta{language} (\eg ¦\localnumeral[lang=arabic]{42}}¦).
 \end{itemize}
 
 \subsection{Non-Western decimal digits}\label{sec:decdigit}
 
-In addition\new{v1.1.1} to the generic macros described above, \pkg{polyglossia} provides language-specific conversion macros
+In addition\new{1.1.1} to the generic macros described above, \pkg{polyglossia} provides language-specific conversion macros
 which can be used if the generic ones do not suit the need.\footnote{%
 A third method are so-called TECKit fontmappings.
 Those can be activated with the \pkg{fontspec} ¦Mapping¦ option,
@@ -1463,7 +1870,7 @@
 typing \cmd{\textarabic\{2010\}} results in \textarabic{٢٠١٠}. Note that this method has some drawbacks, though,
 for instance when the value of a counter has to be written and read from auxiliary files.
 So please use this with care.}
-The macros have the form ¦\<script>digits¦. They convert Arabic numerical input and leave every other input untouched.
+The macros have the form \cmd{\⟨script⟩digits}. They convert Arabic numerical input and leave every other input untouched.
 In an Arabic context, for instance, ¦\arabicdigits{9182/738543-X}¦ yields \textarabic{\arabicdigits{9182/738543-X}}.
 
 Currently, the following macros are provided:
@@ -1490,9 +1897,9 @@
 	\url{http://en.wikipedia.org/wiki/Hebrew_numerals},
 	and \url{http://en.wikipedia.org/wiki/Syriac_alphabet}.}, dedicated macros are provided.
 
-They work in a similar way than the ¦\<script>digits¦ macros described above: They take Arabic numerical input
+They work in a similar way than the \cmd{\⟨script⟩digits} macros described above: They take Arabic numerical input
 and output the respective value in the local alphabetic numbering scheme (most of these macros are equivalent
-to ¦\localnumeral¦ and ¦\Localnumeral¦ in the respective context).
+to \cmd\localnumeral\ and \cmd\Localnumeral\ in the respective context).
 
 The following macros are provided:
 
@@ -1509,6 +1916,13 @@
 	
 	\item \Cmd\armeniannumeral produces Armenian alphabetic numbering.
 	          Example: ¦\armeniannumeral{1863}¦ yields \textarmenian{\armeniannumeral{1863}}.
+	          
+	\item \Cmd\belarusiannumeral produces Belarusian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Belarusiannumeral.
+	          Depending on the ¦numerals¦ option in the Belarusian language selection, this is either Arabic digit or Cyrillic
+	          alphanumercial output.\\
+	          Example: With ¦numerals=latin¦ ¦\belarusiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+	          with ¦numerals=cyrillic-trad¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+	          with ¦numerals=cyrillic-alph¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 
 	\item \Cmd\georgiannumeral produces Georgian alphabetic numbering.\\
               Example: ¦\georgiannumeral{1863}¦ yields \textgeorgian{\georgiannumeral{1863}}.
@@ -1518,24 +1932,40 @@
 			¦\Greeknumeral{1863}¦ results in \textgreek{\Greeknumeral{1863}}.
 
 	\item \Cmd\hebrewnumeral, \Cmd\Hebrewnumeral and \Cmd\Hebrewnumeralfinal generate variants of Hebrew alphanumeric numerals.
-			The commands behave exactly as they do in \pkg{babel}: ¦\hebrewnumeral¦ outputs the numbers without any decoration,
-			¦\Hebrewnumeral¦ adds \textit{gereshayim} before the last letter, ¦\Hebrewnumeralfinal¦ uses in addition the final forms of Hebrew letters.
+			The commands behave exactly as they do in \pkg{babel}: \cmd\hebrewnumeral\ outputs the numbers without any decoration,
+			\cmd\Hebrewnumeral\ adds \textit{gereshayim} before the last letter, \cmd\Hebrewnumeralfinal\ uses in addition the final forms of Hebrew letters.
 			Examples:
 			¦\hebrewnumeral{1750}¦ yields \texthebrew{\hebrewnumeral{1750}},
 			¦\Hebrewnumeral{1750}¦ yields \texthebrew{\Hebrewnumeral{1750}},
 			and ¦\Hebrewnumeralfinal{1750}¦ yields \texthebrew{\Hebrewnumeralfinal{1750}}.
+			
+	\item \Cmd\mongoliannumeral produces Mongolian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Mongoliannumeral.
+            Depending on the ¦numerals¦ option in the Mongolian language selection, this is either Arabic digit or Cyrillic
+            alphanumercial output.\\
+            Example: With ¦numerals=latin¦ ¦\mongoliannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+            with ¦numerals=cyrillic-trad¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+            with ¦numerals=cyrillic-alph¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 	
 	\item \Cmd\russiannumeral produces Russian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Russiannumeral.
 	        Depending on the ¦numerals¦ option in the Russian language selection, this is either Arabic digit or Cyrillic
 	        alphanumercial output.\\
 	        Example: With ¦numerals=latin¦ ¦\russiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
-	        with ¦numerals=cyrillic¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic]{\russiannumeral{19}}.
+	        with ¦numerals=cyrillic-trad¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+	        with ¦numerals=cyrillic-alph¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 			
 	\item \Cmd\serbiannumeral produces Serbian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Serbiannumeral.
 		    Depending on the ¦numerals¦ option in the Serbian language selection, this is either Arabic digit or Cyrillic
 		    alphanumercial output.\\
-		    Example: With ¦numerals=latin¦ ¦\serbiannumeral{19}¦ yields \textserbian{\serbiannumeral{19}},
-			with ¦numerals=cyrillic¦ ¦\serbiannumeral{19}¦ results in \textserbian[numerals=cyrillic]{\serbiannumeral{19}}.
+		    Example: With ¦numerals=latin¦ ¦\serbiannumeral{19}¦ yields \textrussian{\serbiannumeral{19}},
+			with ¦numerals=cyrillic-trad¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\serbiannumeral{19}},\\
+			with ¦numerals=cyrillic-alph¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\serbiannumeral{19}}.
+			
+	\item \Cmd\ukrainiannumeral produces Ukrainian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Ukrainiannumeral.
+			Depending on the ¦numerals¦ option in the Ukrainian language selection, this is either Arabic digit or Cyrillic
+			alphanumercial output.\\
+			Example: With ¦numerals=latin¦ ¦\ukrainiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+			with ¦numerals=cyrillic-trad¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+			with ¦numerals=cyrillic-alph¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 \end{itemize}
 
 
@@ -1548,14 +1978,14 @@
 
 \subsection{Horizontal footnote position}
 
-When right-to-left languages are used, the ¦\footnote¦ command becomes sensitive to the text directionality. The footnote is
+When right-to-left languages are used, the \cmd\footnote\ command becomes sensitive to the text directionality. The footnote is
 always placed on the side that is currently the origin of direction: on the left side of the page in LTR paragraphs and
 on the right in RTL paragraphs.
 
 For cases where this is not desired, two additional footnote commands are provided: \Cmd\RTLfootnote and \Cmd\LTRfootnote.
-¦\LTRfootnote¦ always places the footnote on the left side, notwithstanding the current
-directionality. Likewise, ¦\RTLfootnote¦ always places it on the right side. Like ¦\footnote¦, ¦\RTLfootnote¦
-and ¦\LTRfootnote¦ provide an optional argument to customize the number.
+\cmd\LTRfootnote\ always places the footnote on the left side, notwithstanding the current
+directionality. Likewise, \cmd\RTLfootnote\ always places it on the right side. Like \cmd\footnote, \cmd\RTLfootnote\
+and \cmd\LTRfootnote\ provide an optional argument to customize the number.
 
 
 \subsection{Footnote rule length and position}
@@ -1572,12 +2002,13 @@
 	\item Put \Cmd\autofootnoterule in the preamble to have automatic placement depending on the context (see below for elaboration).
 	\item Put \Cmd\textwidthfootnoterule in the preamble to have a rule that spans the whole text width.
 \end{itemize}
-With ¦\autofootnoterule¦, the first footnote on the current page determines the placement. Note that this automatic can fail with
-footnotes at page boundaries that differ in directionality from the first footnote on the page. You can work around such cases by switching to ¦\rightfootnoterule¦ or ¦\leftfootnoterule¦ on these pages.
+With \cmd\autofootnoterule, the first footnote on the current page determines the placement. Note that this automatic can fail with
+footnotes at page boundaries that differ in directionality from the first footnote on the page. You can work around such cases by switching to \cmd\rightfootnoterule\ or \cmd\leftfootnoterule\ on these pages.
 
 Note also that the rule switches might interfere in bad ways with packages or classes that redefine footnotes themselves. This is also the reason
-why ¦\autofootnoterule¦ is not used by default.
+why \cmd\autofootnoterule\ is not used by default.
 
+\condbreak{5\baselineskip}
 \section{Calendars}
 
 \subsection{Hebrew calendar (hebrewcal.sty)}
@@ -1594,24 +2025,24 @@
 	(Cambridge University Press, 2001).\label{reingold}}
 It provides two macros for the end-user.
 The command
-	\displaycmd{\HijriFromGregorian\{⟨year⟩\}\{⟨month⟩\}\{⟨day⟩\}}{\HijriFromGregorian}
+	\displaycmd{\HijriFromGregorian\marg{year}\marg{month}\marg{day}}{\HijriFromGregorian}
 sets the counters ¦Hijriday¦, ¦Hijrimonth¦ and ¦Hijriyear¦.
 \Cmd\Hijritoday\ formats the Hijri date for the current day.
-This command is now locale-aware\new{v1.1.1}: its output will differ depending on the
+This command is now locale-aware\new{1.1.1}: its output will differ depending on the
 currently active language. Presently \pkg{polyglossia}’s language definition files
-for Arabic, Farsi, Urdu, Turkish and Malay provide a localized version of ¦\Hijritoday¦.
+for Arabic, Farsi, Urdu, Turkish and Malay provide a localized version of \cmd\Hijritoday.
 If the formatting macro for the current language is undefined, the Hijri date will be formatted
 in Arabic or in roman transliteration, depending of the current writing direction.
 You can define a new format or redefine one with the command
-  \displaycmd{\DefineHijriDateFormat\{<lang>\}\{<code>\}.}{\DefineHijriDateFormat}
+  \displaycmd{\DefineHijriDateFormat\marg{lang}\marg{code}.}{\DefineHijriDateFormat}
 
-The command ¦\Hijritoday¦ also accepts an optional argument to add or subtract a correction
+The command \cmd\Hijritoday\ also accepts an optional argument to add or subtract a correction
 (in days) to the date computed by the arithmetical algorithm.\footnote{ %
 	The Islamic calendar is indeed a purely lunar calendar based on the observation
 	of the first visibility of the lunar crescent at the beginning of the lunar month,
 	so there can be differences between different localities, as well as between
 	civil and religious authorities.}
-For instance if ¦\Hijritoday¦ yields the date “7 Rajab 1429” (which is the date that was
+For instance if \cmd\Hijritoday\ yields the date “7 Rajab 1429” (which is the date that was
 displayed on the front page of \href{http://www.aljazeera.net}{aljazeera.net} on
 11th July 2008), ¦\Hijritoday[1]¦ would rather print “8 Rajab 1429” (the date
 indicated the same day on the site \href{http://www.gulfnews.com}{gulfnews.com}).
@@ -1619,19 +2050,26 @@
 \subsection{Farsi (jalālī) calendar (farsical.sty)}
 This package is an almost verbatim copy of ¦Arabiftoday.sty¦ (in the \pkg{Arabi} package),
 itself a slight modification of ¦ftoday.sty¦ in Farsi\TeX.\footnote{ %
-	One day I may rewrite \pkg{farsical} from scratch using the algorithm in
-	Reingold \& Gershowitz (ref.~n.~\ref{reingold}).}
+	One day we may rewrite \pkg{farsical} from scratch using the algorithm in
+	Reingold \& Gershowitz (ref.~n.\,\ref{reingold}).}
 Here we have renamed the command \cmd\ftoday\ to
 \Cmd\Jalalitoday.
 Example: today is \Jalalitoday.
 
 
-%\section{Varia}
+\section{Auxiliary commands}
 
+The macro \displaycmd{\charifavailable\marg{char code}\marg{substitution}}{\charifavailable}\new{1.47} checks whether
+the character with the specified \meta{char code} (\ie unicode utf-16 code without preceding ¦0x¦) exists in
+the current font. If so, the character is printed, if not, the \meta{substitution} is printed.
+
+Example: ¦\charifavailable{1E9E}{SS}¦ prints the capital version of the German letter ⟨ß⟩ if available
+(\ie \charifavailable{1E9E}{SS}), else it prints the substitution digraph SS.
+
+
 \section{Accessing language information}
 
 The following is specifically relevant to package authors who need information about the languages in use.
-
 In order to get such information, \pkg{polyglossia} provides the following macros:
 
 \begin{itemize}
@@ -1646,21 +2084,37 @@
 	      Note that this macro is also defined for languages that are not supported in \pkg{babel}. In that
 	      case, they are equal to the polyglossia language name.
 	\item \Cmd\mainbabelname\ analogously stores the name of document's main language (variant) in \pkg{babel}.
+	\item \Cmd{\languageid\marg{type}}\new{1.47} stores the identifier tag of the current language. Currently supported \meta{types}:
+	      \begin{itemize}
+	      	\item ¦bcp-47¦ (alias ¦bcp47¦): IETF BCP-47 language identifier
+	      \end{itemize}
+	 \item \Cmd{\mainlanguageid\marg{type}}\new{1.47} stores identifier tag of the main language. Currently supported \meta{types}:
+	      see \cmd\languageid.
 \end{itemize}
-%
-If you want to have a full list of loaded languages/variants, use the following macros:
+\bigskip
+
+\noindent If you want to have a full list of loaded languages/variants, use the following macros:
 \begin{itemize}
 	\item \Cmd{\xpg at loaded}\ stores a comma-separated list of all loaded languages (polyglossia name)
 	\item \Cmd{\xpg at vloaded}\ stores a comma-separated list of all loaded variants
-	\item \Cmd{\xpg at bloaded}\ stores a comma-separated list of \pkg{babel} names of all language variants 
+	\item \Cmd{\xpg at bloaded}\ stores a comma-separated list of \pkg{babel} names of all language variants
+	\item \Cmd{\xpg at bcp@loaded}\new{1.47}\ stores a comma-separated list of the BCP-47 IDs of all language variants
 \end{itemize}
-%
-Finally, you can test whether a language is loaded by
-\displaycmd{\iflanguageloaded\{⟨lang⟩\}\{⟨true⟩\}\{⟨false⟩\}}{\iflanguageloaded}
-where \texttt{⟨lang⟩} is a \pkg{polyglossia} language name, or
-\displaycmd{\ifbabellanguageloaded\{⟨lang⟩\}\{⟨true⟩\}\{⟨false⟩\}}{\ifbabellanguageloaded}
-where \texttt{⟨lang⟩} is a \pkg{babel} language name.
+\bigskip
 
+\noindent Whether a language is loaded can be tested by
+\displaycmd{\iflanguageloaded\marg{lang}\marg{true}\marg{false}}{\iflanguageloaded}
+where \texttt{\meta{lang}} is a \pkg{polyglossia} language name, by
+\displaycmd{\ifbabellanguageloaded\marg{lang}\marg{true}\marg{false}}{\ifbabellanguageloaded}
+where \texttt{\meta{lang}} is a \pkg{babel} language name (see table~\ref{tab:bbllang} on p.~\pageref{tab:bbllang}), or by
+\displaycmd{\iflanguageidloaded\marg{type}\marg{id}\marg{true}\marg{false}}{\iflanguageidloaded}\new{1.47}
+where \meta{type} is a supported language id type (such as ¦bcp-47¦) and \meta{id} is a language id
+(such as ¦en-US¦; see table~\ref{tab:BCP47-polyglossia} on p.~\pageref{tab:BCP47-polyglossia}).
+\bigskip
+
+\noindent Finally, if you want to know whether a specific language option has been set, you can use
+\displaycmd{\iflanguageoption\marg{lang}\marg{opt. key}\marg{opt. value}\marg{true}\marg{false}}{\iflanguageoption}\new{1.47}
+
 \section{Acknowledgements (by François Charette)}
 \pkg{Polyglossia} is notable for being a recycle box of previous contributions
 by other people. I take this opportunity to thank the following individuals,
@@ -1675,7 +2129,7 @@
 (Sanskrit), \TA{Zdenĕk Wagner} (Hindi), \TA{Mikhal Oren} (Hebrew), \TA{Sergey Astanin} (Russian),
 \TA{Khaled Hosny} (Arabic), \TA{Sertaç Ö. Yıldız} (Turkish), \TA{Kamal Abdali} (Urdu),
 and several other members of the \XeTeX\ user community, notably \TA{Enrico Gregorio}, who
-has sent me many useful suggestions and corrections and contributed the ¦\newXeTeXintercharclass¦
+has sent me many useful suggestions and corrections and contributed the \cmd\newXeTeXintercharclass\
 mechanism in xelatex.ini which is now used by polyglossia.
 More recently, \TA{Kevin Godby} of the \href{http://ubuntu-manual.org}{Ubuntu Manual} project has
 contributed very useful feedback, bug hunting and, with the help of translators,
@@ -1692,9 +2146,9 @@
 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{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{Yevgen Pogribnyi}, \TA{Maïeul Rouquette},
-\TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg}, \TA{Philipp Stephani}, \TA{Keno Wehr}, \TA{Dominik Wujastyk},
-\TA{Sertaç Ö. Yıldız}, \TA{Maksim Zholudev}, \TA{Yan Zhou}, and \TA{Stefan Zlatinov}.
+\TA{Ivan Kokan}, \TA{Caleb Maclennan}, \TA{José Mancera}, \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}, \TA{Keno Wehr},
+\TA{Dominik Wujastyk}, \TA{Sertaç Ö. Yıldız}, \TA{Maksim Zholudev}, \TA{Yan Zhou}, and \TA{Stefan Zlatinov}.
 Their respective contributions can be identified from the contributor statistics on
 \href{https://github.com/reutenauer/polyglossia/graphs/contributors}{GitHub}.
 

Modified: trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/source/latex/polyglossia/polyglossia.dtx	2020-01-29 22:37:53 UTC (rev 53592)
@@ -11,7 +11,7 @@
 
    ¦----------------------------------------------¦
    ¦                                              ¦
-   ¦       THE POLYGLOSSIA PACKAGE v1.46          ¦
+   ¦       THE POLYGLOSSIA PACKAGE v1.47          ¦
    ¦                                              ¦
    ¦     Modern multilingual typesetting          ¦
    ¦        with XeLaTeX and LuaLaTeX             ¦
@@ -44,8 +44,8 @@
 
 LICENSE
 
-Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2019 Arthur Reutenauer,
-Copyright (c) 2019 Bastien Roucariès, 2019 Jürgen Spitzmüller
+Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2020 Arthur Reutenauer,
+Copyright (c) 2019-2020 Bastien Roucariès, 2019-2020 Jürgen Spitzmüller
 
 Except where otherwise noted, Polyglossia is placed under the terms of the MIT licence
 (https://opensource.org/licenses/MIT).
@@ -74,7 +74,7 @@
 
   The polyglossia package         
   (C) 2008–2010 François Charette    
-  (C) 2011-2019 Arthur Reutenauer
+  (C) 2011-2020 Arthur Reutenauer
   (C) 2013 Elie Roux
   License information appended
 
@@ -82,7 +82,7 @@
 \endpreamble
 \postamble
 
- Copyright (C) 2019 by Arthur Reutenauer <arthur 'dot' reutenauer 'at' normalesup 'dot' org> 
+ Copyright (C) 2020 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
@@ -101,61 +101,168 @@
 \let\MetaPrefix\DoubleperCent
 \askforoverwritefalse
 \generate{\file{gloss-acadien.ldf}{\from{polyglossia.dtx}{gloss-acadien.ldf}}}
+\generate{\file{gloss-aeb.ldf}{\from{polyglossia.dtx}{gloss-aeb.ldf}}}
+\generate{\file{gloss-af.ldf}{\from{polyglossia.dtx}{gloss-af.ldf}}}
+\generate{\file{gloss-afb.ldf}{\from{polyglossia.dtx}{gloss-afb.ldf}}}
 \generate{\file{gloss-afrikaans.ldf}{\from{polyglossia.dtx}{gloss-afrikaans.ldf}}}
 \generate{\file{gloss-albanian.ldf}{\from{polyglossia.dtx}{gloss-albanian.ldf}}}
+\generate{\file{gloss-am.ldf}{\from{polyglossia.dtx}{gloss-am.ldf}}}
 \generate{\file{gloss-american.ldf}{\from{polyglossia.dtx}{gloss-american.ldf}}}
 \generate{\file{gloss-amharic.ldf}{\from{polyglossia.dtx}{gloss-amharic.ldf}}}
+\generate{\file{gloss-apd.ldf}{\from{polyglossia.dtx}{gloss-apd.ldf}}}
+\generate{\file{gloss-ar-IQ.ldf}{\from{polyglossia.dtx}{gloss-ar-IQ.ldf}}}
+\generate{\file{gloss-ar-JO.ldf}{\from{polyglossia.dtx}{gloss-ar-JO.ldf}}}
+\generate{\file{gloss-ar-LB.ldf}{\from{polyglossia.dtx}{gloss-ar-LB.ldf}}}
+\generate{\file{gloss-ar-MR.ldf}{\from{polyglossia.dtx}{gloss-ar-MR.ldf}}}
+\generate{\file{gloss-ar-PS.ldf}{\from{polyglossia.dtx}{gloss-ar-PS.ldf}}}
+\generate{\file{gloss-ar-SY.ldf}{\from{polyglossia.dtx}{gloss-ar-SY.ldf}}}
+\generate{\file{gloss-ar-YE.ldf}{\from{polyglossia.dtx}{gloss-ar-YE.ldf}}}
+\generate{\file{gloss-ar.ldf}{\from{polyglossia.dtx}{gloss-ar.ldf}}}
 \generate{\file{gloss-arabic.ldf}{\from{polyglossia.dtx}{gloss-arabic.ldf}}}
 \generate{\file{gloss-armenian.ldf}{\from{polyglossia.dtx}{gloss-armenian.ldf}}}
+\generate{\file{gloss-arq.ldf}{\from{polyglossia.dtx}{gloss-arq.ldf}}}
+\generate{\file{gloss-ary.ldf}{\from{polyglossia.dtx}{gloss-ary.ldf}}}
+\generate{\file{gloss-arz.ldf}{\from{polyglossia.dtx}{gloss-arz.ldf}}}
+\generate{\file{gloss-ast.ldf}{\from{polyglossia.dtx}{gloss-ast.ldf}}}
 \generate{\file{gloss-asturian.ldf}{\from{polyglossia.dtx}{gloss-asturian.ldf}}}
 \generate{\file{gloss-australian.ldf}{\from{polyglossia.dtx}{gloss-australian.ldf}}}
 \generate{\file{gloss-austrian.ldf}{\from{polyglossia.dtx}{gloss-austrian.ldf}}}
+\generate{\file{gloss-ayl.ldf}{\from{polyglossia.dtx}{gloss-ayl.ldf}}}
 \generate{\file{gloss-bahasa.ldf}{\from{polyglossia.dtx}{gloss-bahasa.ldf}}}
 \generate{\file{gloss-bahasai.ldf}{\from{polyglossia.dtx}{gloss-bahasai.ldf}}}
 \generate{\file{gloss-bahasam.ldf}{\from{polyglossia.dtx}{gloss-bahasam.ldf}}}
 \generate{\file{gloss-basque.ldf}{\from{polyglossia.dtx}{gloss-basque.ldf}}}
+\generate{\file{gloss-be-tarask.ldf}{\from{polyglossia.dtx}{gloss-be-tarask.ldf}}}
+\generate{\file{gloss-be.ldf}{\from{polyglossia.dtx}{gloss-be.ldf}}}
 \generate{\file{gloss-belarusian.ldf}{\from{polyglossia.dtx}{gloss-belarusian.ldf}}}
 \generate{\file{gloss-bengali.ldf}{\from{polyglossia.dtx}{gloss-bengali.ldf}}}
+\generate{\file{gloss-bg.ldf}{\from{polyglossia.dtx}{gloss-bg.ldf}}}
+\generate{\file{gloss-bn.ldf}{\from{polyglossia.dtx}{gloss-bn.ldf}}}
+\generate{\file{gloss-bo.ldf}{\from{polyglossia.dtx}{gloss-bo.ldf}}}
 \generate{\file{gloss-bosnian.ldf}{\from{polyglossia.dtx}{gloss-bosnian.ldf}}}
+\generate{\file{gloss-br.ldf}{\from{polyglossia.dtx}{gloss-br.ldf}}}
 \generate{\file{gloss-brazil.ldf}{\from{polyglossia.dtx}{gloss-brazil.ldf}}}
 \generate{\file{gloss-breton.ldf}{\from{polyglossia.dtx}{gloss-breton.ldf}}}
 \generate{\file{gloss-british.ldf}{\from{polyglossia.dtx}{gloss-british.ldf}}}
+\generate{\file{gloss-bs.ldf}{\from{polyglossia.dtx}{gloss-bs.ldf}}}
 \generate{\file{gloss-bulgarian.ldf}{\from{polyglossia.dtx}{gloss-bulgarian.ldf}}}
+\generate{\file{gloss-ca.ldf}{\from{polyglossia.dtx}{gloss-ca.ldf}}}
 \generate{\file{gloss-canadian.ldf}{\from{polyglossia.dtx}{gloss-canadian.ldf}}}
 \generate{\file{gloss-canadien.ldf}{\from{polyglossia.dtx}{gloss-canadien.ldf}}}
 \generate{\file{gloss-catalan.ldf}{\from{polyglossia.dtx}{gloss-catalan.ldf}}}
+\generate{\file{gloss-ckb-Arab.ldf}{\from{polyglossia.dtx}{gloss-ckb-Arab.ldf}}}
+\generate{\file{gloss-ckb-Latn.ldf}{\from{polyglossia.dtx}{gloss-ckb-Latn.ldf}}}
+\generate{\file{gloss-ckb.ldf}{\from{polyglossia.dtx}{gloss-ckb.ldf}}}
+\generate{\file{gloss-cop.ldf}{\from{polyglossia.dtx}{gloss-cop.ldf}}}
 \generate{\file{gloss-coptic.ldf}{\from{polyglossia.dtx}{gloss-coptic.ldf}}}
 \generate{\file{gloss-croatian.ldf}{\from{polyglossia.dtx}{gloss-croatian.ldf}}}
+\generate{\file{gloss-cy.ldf}{\from{polyglossia.dtx}{gloss-cy.ldf}}}
+\generate{\file{gloss-cz.ldf}{\from{polyglossia.dtx}{gloss-cz.ldf}}}
 \generate{\file{gloss-czech.ldf}{\from{polyglossia.dtx}{gloss-czech.ldf}}}
+\generate{\file{gloss-da.ldf}{\from{polyglossia.dtx}{gloss-da.ldf}}}
 \generate{\file{gloss-danish.ldf}{\from{polyglossia.dtx}{gloss-danish.ldf}}}
+\generate{\file{gloss-de-AT-1901.ldf}{\from{polyglossia.dtx}{gloss-de-AT-1901.ldf}}}
+\generate{\file{gloss-de-AT-1996.ldf}{\from{polyglossia.dtx}{gloss-de-AT-1996.ldf}}}
+\generate{\file{gloss-de-AT.ldf}{\from{polyglossia.dtx}{gloss-de-AT.ldf}}}
+\generate{\file{gloss-de-CH-1901.ldf}{\from{polyglossia.dtx}{gloss-de-CH-1901.ldf}}}
+\generate{\file{gloss-de-CH-1996.ldf}{\from{polyglossia.dtx}{gloss-de-CH-1996.ldf}}}
+\generate{\file{gloss-de-CH.ldf}{\from{polyglossia.dtx}{gloss-de-CH.ldf}}}
+\generate{\file{gloss-de-DE-1901.ldf}{\from{polyglossia.dtx}{gloss-de-DE-1901.ldf}}}
+\generate{\file{gloss-de-DE-1996.ldf}{\from{polyglossia.dtx}{gloss-de-DE-1996.ldf}}}
+\generate{\file{gloss-de-DE.ldf}{\from{polyglossia.dtx}{gloss-de-DE.ldf}}}
+\generate{\file{gloss-de-Latf-AT-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT-1901.ldf}}}
+\generate{\file{gloss-de-Latf-AT-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT-1996.ldf}}}
+\generate{\file{gloss-de-Latf-AT.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT.ldf}}}
+\generate{\file{gloss-de-Latf-CH-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH-1901.ldf}}}
+\generate{\file{gloss-de-Latf-CH-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH-1996.ldf}}}
+\generate{\file{gloss-de-Latf-CH.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH.ldf}}}
+\generate{\file{gloss-de-Latf-DE-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE-1901.ldf}}}
+\generate{\file{gloss-de-Latf-DE-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE-1996.ldf}}}
+\generate{\file{gloss-de-Latf-DE.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE.ldf}}}
+\generate{\file{gloss-de-Latf.ldf}{\from{polyglossia.dtx}{gloss-de-Latf.ldf}}}
+\generate{\file{gloss-de.ldf}{\from{polyglossia.dtx}{gloss-de.ldf}}}
 \generate{\file{gloss-divehi.ldf}{\from{polyglossia.dtx}{gloss-divehi.ldf}}}
+\generate{\file{gloss-dsb.ldf}{\from{polyglossia.dtx}{gloss-dsb.ldf}}}
 \generate{\file{gloss-dutch.ldf}{\from{polyglossia.dtx}{gloss-dutch.ldf}}}
+\generate{\file{gloss-dv.ldf}{\from{polyglossia.dtx}{gloss-dv.ldf}}}
+\generate{\file{gloss-el-monoton.ldf}{\from{polyglossia.dtx}{gloss-el-monoton.ldf}}}
+\generate{\file{gloss-el-polyton.ldf}{\from{polyglossia.dtx}{gloss-el-polyton.ldf}}}
+\generate{\file{gloss-el.ldf}{\from{polyglossia.dtx}{gloss-el.ldf}}}
+\generate{\file{gloss-en-AU.ldf}{\from{polyglossia.dtx}{gloss-en-AU.ldf}}}
+\generate{\file{gloss-en-CA.ldf}{\from{polyglossia.dtx}{gloss-en-CA.ldf}}}
+\generate{\file{gloss-en-GB.ldf}{\from{polyglossia.dtx}{gloss-en-GB.ldf}}}
+\generate{\file{gloss-en-NZ.ldf}{\from{polyglossia.dtx}{gloss-en-NZ.ldf}}}
+\generate{\file{gloss-en-US.ldf}{\from{polyglossia.dtx}{gloss-en-US.ldf}}}
+\generate{\file{gloss-en.ldf}{\from{polyglossia.dtx}{gloss-en.ldf}}}
 \generate{\file{gloss-english.ldf}{\from{polyglossia.dtx}{gloss-english.ldf}}}
+\generate{\file{gloss-eo.ldf}{\from{polyglossia.dtx}{gloss-eo.ldf}}}
+\generate{\file{gloss-es-ES.ldf}{\from{polyglossia.dtx}{gloss-es-ES.ldf}}}
+\generate{\file{gloss-es-MX.ldf}{\from{polyglossia.dtx}{gloss-es-MX.ldf}}}
+\generate{\file{gloss-es.ldf}{\from{polyglossia.dtx}{gloss-es.ldf}}}
 \generate{\file{gloss-esperanto.ldf}{\from{polyglossia.dtx}{gloss-esperanto.ldf}}}
 \generate{\file{gloss-estonian.ldf}{\from{polyglossia.dtx}{gloss-estonian.ldf}}}
+\generate{\file{gloss-et.ldf}{\from{polyglossia.dtx}{gloss-et.ldf}}}
+\generate{\file{gloss-eu.ldf}{\from{polyglossia.dtx}{gloss-eu.ldf}}}
+\generate{\file{gloss-fa.ldf}{\from{polyglossia.dtx}{gloss-fa.ldf}}}
 \generate{\file{gloss-farsi.ldf}{\from{polyglossia.dtx}{gloss-farsi.ldf}}}
+\generate{\file{gloss-fi.ldf}{\from{polyglossia.dtx}{gloss-fi.ldf}}}
 \generate{\file{gloss-finnish.ldf}{\from{polyglossia.dtx}{gloss-finnish.ldf}}}
+\generate{\file{gloss-fr-CA.ldf}{\from{polyglossia.dtx}{gloss-fr-CA.ldf}}}
+\generate{\file{gloss-fr-CH.ldf}{\from{polyglossia.dtx}{gloss-fr-CH.ldf}}}
+\generate{\file{gloss-fr-FR.ldf}{\from{polyglossia.dtx}{gloss-fr-FR.ldf}}}
+\generate{\file{gloss-fr.ldf}{\from{polyglossia.dtx}{gloss-fr.ldf}}}
 \generate{\file{gloss-french.ldf}{\from{polyglossia.dtx}{gloss-french.ldf}}}
 \generate{\file{gloss-friulan.ldf}{\from{polyglossia.dtx}{gloss-friulan.ldf}}}
 \generate{\file{gloss-friulian.ldf}{\from{polyglossia.dtx}{gloss-friulian.ldf}}}
+\generate{\file{gloss-fur.ldf}{\from{polyglossia.dtx}{gloss-fur.ldf}}}
+\generate{\file{gloss-ga.ldf}{\from{polyglossia.dtx}{gloss-ga.ldf}}}
 \generate{\file{gloss-gaelic.ldf}{\from{polyglossia.dtx}{gloss-gaelic.ldf}}}
 \generate{\file{gloss-galician.ldf}{\from{polyglossia.dtx}{gloss-galician.ldf}}}
+\generate{\file{gloss-gd.ldf}{\from{polyglossia.dtx}{gloss-gd.ldf}}}
 \generate{\file{gloss-georgian.ldf}{\from{polyglossia.dtx}{gloss-georgian.ldf}}}
 \generate{\file{gloss-german.ldf}{\from{polyglossia.dtx}{gloss-german.ldf}}}
 \generate{\file{gloss-germanb.ldf}{\from{polyglossia.dtx}{gloss-germanb.ldf}}}
+\generate{\file{gloss-gl.ldf}{\from{polyglossia.dtx}{gloss-gl.ldf}}}
+\generate{\file{gloss-grc.ldf}{\from{polyglossia.dtx}{gloss-grc.ldf}}}
 \generate{\file{gloss-greek.ldf}{\from{polyglossia.dtx}{gloss-greek.ldf}}}
+\generate{\file{gloss-he.ldf}{\from{polyglossia.dtx}{gloss-he.ldf}}}
 \generate{\file{gloss-hebrew.ldf}{\from{polyglossia.dtx}{gloss-hebrew.ldf}}}
+\generate{\file{gloss-hi.ldf}{\from{polyglossia.dtx}{gloss-hi.ldf}}}
 \generate{\file{gloss-hindi.ldf}{\from{polyglossia.dtx}{gloss-hindi.ldf}}}
+\generate{\file{gloss-hr.ldf}{\from{polyglossia.dtx}{gloss-hr.ldf}}}
+\generate{\file{gloss-hsb.ldf}{\from{polyglossia.dtx}{gloss-hsb.ldf}}}
+\generate{\file{gloss-hu.ldf}{\from{polyglossia.dtx}{gloss-hu.ldf}}}
 \generate{\file{gloss-hungarian.ldf}{\from{polyglossia.dtx}{gloss-hungarian.ldf}}}
+\generate{\file{gloss-hy.ldf}{\from{polyglossia.dtx}{gloss-hy.ldf}}}
+\generate{\file{gloss-ia.ldf}{\from{polyglossia.dtx}{gloss-ia.ldf}}}
 \generate{\file{gloss-icelandic.ldf}{\from{polyglossia.dtx}{gloss-icelandic.ldf}}}
+\generate{\file{gloss-id.ldf}{\from{polyglossia.dtx}{gloss-id.ldf}}}
 \generate{\file{gloss-interlingua.ldf}{\from{polyglossia.dtx}{gloss-interlingua.ldf}}}
 \generate{\file{gloss-irish.ldf}{\from{polyglossia.dtx}{gloss-irish.ldf}}}
+\generate{\file{gloss-is.ldf}{\from{polyglossia.dtx}{gloss-is.ldf}}}
+\generate{\file{gloss-it.ldf}{\from{polyglossia.dtx}{gloss-it.ldf}}}
 \generate{\file{gloss-italian.ldf}{\from{polyglossia.dtx}{gloss-italian.ldf}}}
+\generate{\file{gloss-ja.ldf}{\from{polyglossia.dtx}{gloss-ja.ldf}}}
 \generate{\file{gloss-japanese.ldf}{\from{polyglossia.dtx}{gloss-japanese.ldf}}}
+\generate{\file{gloss-ka.ldf}{\from{polyglossia.dtx}{gloss-ka.ldf}}}
 \generate{\file{gloss-kannada.ldf}{\from{polyglossia.dtx}{gloss-kannada.ldf}}}
 \generate{\file{gloss-khmer.ldf}{\from{polyglossia.dtx}{gloss-khmer.ldf}}}
+\generate{\file{gloss-km.ldf}{\from{polyglossia.dtx}{gloss-km.ldf}}}
+\generate{\file{gloss-kmr-Arab.ldf}{\from{polyglossia.dtx}{gloss-kmr-Arab.ldf}}}
+\generate{\file{gloss-kmr-Latn.ldf}{\from{polyglossia.dtx}{gloss-kmr-Latn.ldf}}}
+\generate{\file{gloss-kmr.ldf}{\from{polyglossia.dtx}{gloss-kmr.ldf}}}
+\generate{\file{gloss-kn.ldf}{\from{polyglossia.dtx}{gloss-kn.ldf}}}
+\generate{\file{gloss-ko.ldf}{\from{polyglossia.dtx}{gloss-ko.ldf}}}
 \generate{\file{gloss-korean.ldf}{\from{polyglossia.dtx}{gloss-korean.ldf}}}
+\generate{\file{gloss-ku-Arab.ldf}{\from{polyglossia.dtx}{gloss-ku-Arab.ldf}}}
+\generate{\file{gloss-ku-Latn.ldf}{\from{polyglossia.dtx}{gloss-ku-Latn.ldf}}}
+\generate{\file{gloss-ku.ldf}{\from{polyglossia.dtx}{gloss-ku.ldf}}}
 \generate{\file{gloss-kurdish.ldf}{\from{polyglossia.dtx}{gloss-kurdish.ldf}}}
+\generate{\file{gloss-kurmanji.ldf}{\from{polyglossia.dtx}{gloss-kurmanji.ldf}}}
+\generate{\file{gloss-la-x-classic.ldf}{\from{polyglossia.dtx}{gloss-la-x-classic.ldf}}}
+\generate{\file{gloss-la-x-ecclesia.ldf}{\from{polyglossia.dtx}{gloss-la-x-ecclesia.ldf}}}
+\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}}}
@@ -164,15 +271,23 @@
 \generate{\file{gloss-latinmedieval.ldf}{\from{polyglossia.dtx}{gloss-latinmedieval.ldf}}}
 \generate{\file{gloss-latvian.ldf}{\from{polyglossia.dtx}{gloss-latvian.ldf}}}
 \generate{\file{gloss-lithuanian.ldf}{\from{polyglossia.dtx}{gloss-lithuanian.ldf}}}
+\generate{\file{gloss-lo.ldf}{\from{polyglossia.dtx}{gloss-lo.ldf}}}
 \generate{\file{gloss-lowersorbian.ldf}{\from{polyglossia.dtx}{gloss-lowersorbian.ldf}}}
 \generate{\file{gloss-lsorbian.ldf}{\from{polyglossia.dtx}{gloss-lsorbian.ldf}}}
+\generate{\file{gloss-lt.ldf}{\from{polyglossia.dtx}{gloss-lt.ldf}}}
+\generate{\file{gloss-lv.ldf}{\from{polyglossia.dtx}{gloss-lv.ldf}}}
 \generate{\file{gloss-macedonian.ldf}{\from{polyglossia.dtx}{gloss-macedonian.ldf}}}
 \generate{\file{gloss-magyar.ldf}{\from{polyglossia.dtx}{gloss-magyar.ldf}}}
 \generate{\file{gloss-malay.ldf}{\from{polyglossia.dtx}{gloss-malay.ldf}}}
 \generate{\file{gloss-malayalam.ldf}{\from{polyglossia.dtx}{gloss-malayalam.ldf}}}
 \generate{\file{gloss-marathi.ldf}{\from{polyglossia.dtx}{gloss-marathi.ldf}}}
+\generate{\file{gloss-mk.ldf}{\from{polyglossia.dtx}{gloss-mk.ldf}}}
+\generate{\file{gloss-ml.ldf}{\from{polyglossia.dtx}{gloss-ml.ldf}}}
+\generate{\file{gloss-mn.ldf}{\from{polyglossia.dtx}{gloss-mn.ldf}}}
 \generate{\file{gloss-mongolian.ldf}{\from{polyglossia.dtx}{gloss-mongolian.ldf}}}
+\generate{\file{gloss-mr.ldf}{\from{polyglossia.dtx}{gloss-mr.ldf}}}
 \generate{\file{gloss-naustrian.ldf}{\from{polyglossia.dtx}{gloss-naustrian.ldf}}}
+\generate{\file{gloss-nb.ldf}{\from{polyglossia.dtx}{gloss-nb.ldf}}}
 \generate{\file{gloss-newzealand.ldf}{\from{polyglossia.dtx}{gloss-newzealand.ldf}}}
 \generate{\file{gloss-ngerman.ldf}{\from{polyglossia.dtx}{gloss-ngerman.ldf}}}
 \generate{\file{gloss-nko.ldf}{\from{polyglossia.dtx}{gloss-nko.ldf}}}
@@ -249,19 +364,19 @@
 % !TeX TS-program = xelatex
 \documentclass[11pt]{ltxdoc}
 \usepackage{color}
-\usepackage{xspace,fancyvrb,booktabs}
+\usepackage{xspace,fancyvrb,longtable,booktabs}
 \usepackage[neverdecrease]{paralist}
 \usepackage[format=hang,labelfont=bf,labelsep=period]{caption}
-\definecolor{myblue}{rgb}{0.02,0.04,0.48}
+\definecolor{xpgblue}{rgb}{0.02,0.04,0.48}
 \definecolor{lightblue}{rgb}{0.61,.8,.8}
-\definecolor{myred}{rgb}{0.65,0.04,0.07}
+\definecolor{xpgred}{rgb}{0.65,0.04,0.07}
 \usepackage[
     unicode=true,
     bookmarks=true,
     colorlinks=true,
-    linkcolor=myblue,
-    urlcolor=myblue,
-    citecolor=myblue,
+    linkcolor=xpgblue,
+    urlcolor=xpgblue,
+    citecolor=xpgblue,
     hyperindex=false,
     hyperfootnotes=false,
     pdftitle={Polyglossia: Modern multilingual typesetting with XeLaTeX and LuaLaTeX},
@@ -277,13 +392,13 @@
 \setotherlanguages{arabic,armenian,hebrew,syriac,greek,russian,serbian,catalan,georgian}
 \usepackage[protrusion]{microtype}
 \newcommand*\Cmd[1]{\cmd{#1}\DescribeMacro{#1}\xspace}
-\newcommand*\pkg[1]{\textsf{\color{myblue}#1}}
-\newcommand*\file[1]{\texttt{\color{myblue}#1}}
-\newcommand*\TR[1]{\textcolor{myred}{#1}}
-\newcommand*\TX[1]{\hyperref[#1]{\textcolor{myred}{#1}}}
-\newcommand*\TB[1]{\textcolor{myblue}{\bf #1}}
-\newcommand*\TA[1]{\textsc{\color{myblue}#1}}
+\newcommand*\pkg[1]{\textsf{\color{xpgblue}#1}}
+\newcommand*\file[1]{\texttt{\color{xpgblue}#1}}
+\newcommand*\TR[1]{\textcolor{xpgred}{#1}}
+\newcommand*\TX[1]{\hyperref[#1]{\textcolor{xpgred}{#1}}}
+\newcommand*\TA[1]{\textsc{\color{xpgblue}#1}}
 \newcommand*\link[1]{\href{#1}{#1}}
+\renewcommand*\meta[1]{\texttt{⟨#1⟩}}
 \def\eg{\textit{e.g.,}\xspace}
 \def\ie{\textit{i.e.,}\xspace}
 \def\ca{\textit{ca.}\@\xspace}
@@ -291,14 +406,37 @@
 \def\Ie{\textit{I.e.,}\xspace}
 \def\etc{\@ifnextchar.{\textit{etc}}{\textit{etc.}\@\xspace}}
 
+%% Commands for documenting options
+\newcommand*\xpgoption[1]{\textcolor{xpgblue}{\ttfamily\bfseries #1}}
+\newcommand*\xpgvalue[1]{\texttt{#1}}
+\newcommand*\xpgpresetvalue[1]{\texttt{\textit{#1}}}
+\newcommand*\xpgdefaultvalue[1]{\texttt{*#1}}
+
+% arguments: #1 version number, #2 key name, #3 footnote, #4 possible values
+\NewDocumentCommand\xpgchoicekey{omom}{%
+	\xpgoption{#2}\IfValueT{#3}{\footnote{#3}}%
+    \IfValueT{#1}{\new{#1}} \xpgvalue{=} #4\par%
+}
+
+% arguments: #1 version number, #2 key name, #3 footnote
+\NewDocumentCommand\xpgboolkey{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgvalue{false}}}
+\NewDocumentCommand\xpgboolkeytrue{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{\xpgpresetvalue{true}} or \xpgvalue{false}}}
+\NewDocumentCommand\xpgboolkeyfalse{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgpresetvalue{false}}}
+
+% arguments: #1 version number, #2 key name, #3 default code
+\NewDocumentCommand\xpgcodekey{omv}{%
+	\xpgoption{#2}\IfValueT{#1}{\new{#1}}
+     \xpgvalue{=} \meta{code} (default value: \texttt{#3})\par%
+}
+
 %% Sidenotes  << copied from fontspec.dtx
 \newcommand\new[1]{%
-  \edef\thisversion{#1}%
+  \edef\thisversion{v#1}%
   \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
   $\leftarrow$}%
   \marginpar{\centering
     \small\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
-    \textsf{#1}}}
+    \textsf{v#1}}}
 \newcommand\displaycmd[2]{%
   \\\DescribeMacro{#2}\centerline{\cmd{#1}}}
 \renewenvironment{itemize}{\begin{compactitem}[\char"2023]}%[{\fontspec{DejaVu Sans}\char"25BB}]}%
@@ -318,7 +456,7 @@
 \pretocmd{\subsection}{\condbreak{2\baselineskip}}{}{}
 
 %% fontspec declarations:
-\setmainfont{Linux Libertine O}
+\setmainfont{Linux Libertine O}[Numbers=OldStyle]
 \setsansfont{Linux Biolinum O}
 \setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
 \newfontfamily\arabicfont[Script=Arabic]{Amiri}
@@ -348,12 +486,12 @@
 % \errorcontextlines=999
 % \makeatletter
 % 
-% \hyphenation{Kha-li-ghi Reu-ten-auer}
+% \hyphenation{Kha-li-ghi Reu-ten-auer new-zea-land}
 % \GetFileInfo{polyglossia.sty}
 % 
 % \title{\textcolor{lightblue}{\Huge\fontspec[LetterSpace=40]{GFS Ambrosia} Πολυγλωσσια}
 % \\[16pt]
-% \color{myblue}Polyglossia: Modern multilingual typesetting with \XeLaTeX\ and \LuaLaTeX}
+% \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\\
@@ -376,7 +514,7 @@
 % \section{Introduction}
 % 
 % \pkg{Polyglossia} is a package for facilitating multilingual typesetting with
-% \XeLaTeX\ and (with some exceptions) \LuaLaTeX.  Basically, it
+% \XeLaTeX\ and (with some exceptions) \LuaLaTeX. Basically, it
 % can be used as an alternative to \pkg{babel} for performing the following
 % tasks automatically:
 % 
@@ -400,7 +538,7 @@
 %       that are written from right to left (via the package \pkg{bidi},
 %       available separately).
 % \end{enumerate}
-% 
+% ^^A
 % Several features of \pkg{babel} that do not make sense in the \XeTeX\ world (like font
 % encodings, shorthands, etc.) are not supported.
 % Generally speaking, \pkg{polyglossia} aims to remain as compatible as possible
@@ -412,7 +550,7 @@
 % macros defined in the \pkg{etoolbox} package by \TA{Philipp Lehmann} and \TA{Joseph Wright}.
 % Being designed for \XeLaTeX\ and \LuaLaTeX, it obviously also relies on \pkg{fontspec} by
 % \TA{Will Robertson}. For languages written from right to left, it needs the package \pkg{bidi}
-% (for \XeTeX) or  \pkg{luabidi} (for \LuaTeX) by \TA{Vafa Khalighi} (\textarabic{وفا خليقي}) and
+% (for \XeTeX) or \pkg{luabidi} (for \LuaTeX) by \TA{Vafa Khalighi} (\textarabic{وفا خليقي}) and
 % the \pkg{bidi-tex GitHub Organisation}.
 % Polyglossia also bundles three packages for calendaric computations (\pkg{hebrewcal},
 % \pkg{hijrical}, and \pkg{farsical}).
@@ -423,16 +561,16 @@
 % \subsection{Activating languages}
 % 
 % The default language of a document is specified by means of the command
-% 	\displaycmd{\setdefaultlanguage[⟨options⟩]\{⟨lang⟩\}}{\setdefaultlanguage}
+% 	\displaycmd{\setdefaultlanguage\oarg{options}\marg{lang}}{\setdefaultlanguage}
 % (or, equivalently, \Cmd\setmainlanguage).
 % Secondary languages are specified with
-% 	\displaycmd{\setotherlanguage[⟨options⟩]\{⟨lang⟩\}.}{\setotherlanguage}
+% 	\displaycmd{\setotherlanguage\oarg{options}\marg{lang}.}{\setotherlanguage}
 % All these commands allow you to set language-specific options.\footnote{%
 % 	Section~\ref{specific} documents these options for the respective languages.}
 % It is also possible to load a series of secondary languages at once (but without options)
 % using
-% 	\displaycmd{\setotherlanguages\{⟨lang1⟩,⟨lang2⟩,⟨lang3⟩,…\}.}{\setotherlanguages}
-% 
+% 	\displaycmd{\setotherlanguages\marg{lang1⟩,⟨lang2⟩,⟨lang3⟩,⟨…}.}{\setotherlanguages}
+% ^^A
 % All language-specific options can be modified locally by means of the
 % language-switching commands described in section \ref{languageswitching}.
 % 
@@ -453,7 +591,7 @@
 % ^^A Edited by hand -- JS, 2019-11-01
 % \begin{tabular}{lllll}
 % \toprule
-% \TX{afrikaans}  & danish         & \TX{hungarian} & marathi         & \TX{slovenian} \\
+% \TX{afrikaans}  & danish         & \TX{hungarian} & \TX{marathi}    & \TX{slovenian} \\
 % albanian        & divehi         & icelandic      & \TX{mongolian}  & \TX{sorbian}   \\
 % amharic         & \TX{dutch}     & interlingua    & nko             & \TX{spanish}   \\
 % \TX{arabic}     & \TX{english}   & \TX{italian}   & \TX{norwegian}  & swedish        \\
@@ -467,7 +605,7 @@
 % bulgarian       & \TX{georgian}  & latvian        & \TX{russian}    & \TX{ukrainian} \\
 % \TX{catalan}    & \TX{german}    & lithuanian     & \TX{sami}       & urdu           \\
 % coptic          & \TX{greek}     & macedonian     & \TX{sanskrit}   & vietnamese     \\
-% croatian        & \TX{hebrew}    & \TX{malay}     & \TX{serbian}    & \TX{welsh}     \\
+% \TX{croatian}   & \TX{hebrew}    & \TX{malay}     & \TX{serbian}    & \TX{welsh}     \\
 % \TX{czech}      & \TX{hindi}     & malayalam      & \TX{slovak}     &                \\
 % \bottomrule
 % \end{tabular}
@@ -474,19 +612,19 @@
 % 
 % \end{table}
 % 
-% \paragraph{Version Notes} The support for Amharic\new{v1.0.1} should be considered an experimental attempt to
+% \paragraph{Version Notes} The support for Amharic\new{1.0.1} should be considered an experimental attempt to
 % port the package \pkg{ethiop}; feedback is welcome.
-% Version 1.1.1\new{v1.1.1} added support for Asturian, %\footnote{ Provided by Kevin Godby and Xuacu Saturio.}, 
+% Version 1.1.1\new{1.1.1} added support for Asturian, %\footnote{ Provided by Kevin Godby and Xuacu Saturio.},
 % Lithuanian, %\footnote{ Provided by Kevin Godby and Paulius Sladkevičius.},
 % and Urdu. %\footnote{ Provided by Kamal Abdali.}
 % ^^A
-% Version 1.2\new{v1.2.0} introduced Armenian, Occitan, Bengali,
+% Version 1.2\new{1.2.0} introduced Armenian, Occitan, Bengali,
 % Lao, Malayalam, Marathi, Tamil, Telugu, and Turkmen.\footnote{%
 %   See acknowledgements at the end for due credit to the various contributors.}
-% Version 1.43\new{v1.43} brought basic support for Japanese (this
+% Version 1.43\new{1.43} brought basic support for Japanese (this
 % is considered experimental, feedback is appreciated).
-% In version 1.45\new{v1.45}, support for Kurdish and Mongolian as well as some new
-% variants (Canadian French and English) have been added. Furthermore,  for consistency reasons, some language have
+% In version 1.45\new{1.45}, support for Kurdish and Mongolian as well as some new
+% variants (Canadian French and English) have been added. Furthermore, for consistency reasons, some language have
 % been renamed (\emph{farsi}\textrightarrow\emph{persian}, \emph{friulan}\textrightarrow\emph{friulian},
 % \emph{magyar}\textrightarrow\emph{hungarian}, \emph{portuges}\textrightarrow\emph{portuguese},
 % \emph{samin}\textrightarrow\emph{sami}) or merged (\emph{bahasai}\slash\emph{bahasam}\textrightarrow\emph{malay},
@@ -495,10 +633,10 @@
 % \emph{irish}\slash\emph{scottish}\textrightarrow\emph{gaelic},
 % \emph{norsk}\slash\emph{nynorsk}\textrightarrow\emph{norwegian}). The old names are still supported for backwards
 % compatibility reasons.
-% Version 1.46\new{v1.46} introduces support for Afrikaans, Belarusian, Bosnian and Georgian.
+% Version 1.46\new{1.46} introduces support for Afrikaans, Belarusian, Bosnian and Georgian.
 % 
 % 
-% \subsection{Relation to and use of Babel language names}
+% \subsection{Relation to and use of Babel language names}\label{sec:babelnames}
 % 
 % If you are familiar with the \pkg{babel} package, you will note that \pkg{polyglossia}'s language naming
 % slightly differs. Whereas \pkg{babel} has a unique name for each language variety (\eg\emph{american} and \emph{british}),
@@ -507,7 +645,7 @@
 % Furthermore, \pkg{babel} sometimes uses abbreviated language names (\eg\emph{bahasam} for Bahasa Malayu) as well
 % as endonyms, \ie language names coming from the designated languages (such as \emph{bahasa}, \emph{canadien} or \emph{magyar}).
 % As opposed to this, \pkg{polyglossia} always uses spelled-out (lower-cased) English language names.
-% Please refer to table~\ref{tab:bbllang} for the differing language names in both packages. 
+% Please refer to table~\ref{tab:bbllang} for the differing language names in both packages.
 % 
 % \begin{table}
 % \caption{\label{tab:bbllang}Babel-polyglossia language name matching}
@@ -515,7 +653,7 @@
 % \begin{minipage}[t]{1\columnwidth}
 % \small\centering
 % \begin{tabular}{lll}
-% \toprule 
+% \toprule
 % \textbf{Babel name} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\tabularnewline
 % \midrule
 % acadien            & french     & variant=acadian                     \\
@@ -528,20 +666,20 @@
 % 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                     \\
 % farsi              & persian    &                                     \\
+% ecclesiasticlatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.ecclesiastic}).}
+%                    & 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                        \\
 % irish              & gaelic     & variant=irish [\emph{default}]      \\
 % kurmanji           & kurdish    & variant=kurmanji                    \\
-% latin.classic\footnote{Available in \pkg{polyglossia} as \emph{latinclassic} (as dots are invalid in command names).}
-%                    & latin      & variant=classic                     \\
-% latin.ecclesiastic\footnote{Available in \pkg{polyglossia} as \emph{latinecclesiastic} (as dots are invalid in command names).}
-%                    & latin      & variant=ecclesiastic                \\
-% latin.medieval\footnote{Available in \pkg{polyglossia} as \emph{latinmedieval} (as dots are invalid in command names).}
-%                    & latin      & variant=medieval                    \\
 % lowersorbian       & sorbian    & variant=lower                       \\
 % magyar             & hungarian  &                                     \\
+% medievallatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.medieval}).}
+%                    & latin      & variant=medieval                    \\
 % naustrian          & german     & variant=austrian                    \\
 % newzealand         & english    & variant=newzealand                  \\
 % ngerman            & german     & variant=german [\emph{default}]     \\
@@ -556,7 +694,7 @@
 % slovene            & slovenian  &                                     \\
 % spanishmx          & spanish    & variant=mexican                     \\
 % swissgerman        & german     & variant=swiss, spelling=old         \\
-% uppersorbian       & sorbian    & variant=upper                       \\
+% uppersorbian       & sorbian    & variant=upper [\emph{default}]      \\
 % \bottomrule
 % \end{tabular}
 % \end{minipage}
@@ -563,55 +701,240 @@
 % 	
 % \end{table}
 % 
-% For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{v1.46} (for the few justified
+% For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{1.46} (for the few justified
 % exceptions, please refer to the notes in table~\ref{tab:bbllang}).
 % The babel names listed in table~\ref{tab:bbllang} can be used instead of the corresponding polyglossia
 % name\slash options in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the \pkg{polyglossia} and
 % \pkg{babel} language switching commands\slash environments documented in section~\ref{sec:langcmds} and
-% \ref{sec:babelcmds} (\eg \cmd\textaustrian\ is synonymous to \cmd{\textgerman[variant=austrian,spelling=old]}).
+% \ref{sec:babelcmds} (\eg \cmd\textaustrian\ is synonymous to ¦\textgerman[variant=austrian,spelling=old]¦).
 % However, unless you have special reasons, we strongly encourage you to use the \pkg{polyglossia} names.
 % 
 % 
+% \subsection{Using IETF language tags}\label{sec:langtags}
+% 
+% \pkg{Polyglossia}\new{1.47} also supports the use of language tags that conform to the IETF BCP-47
+% \emph{Best Current Practice}.\footnote{Please refer to \url{https://tools.ietf.org/html/bcp47} and
+% 	\url{https://en.wikipedia.org/wiki/IETF_language_tag} for details.}
+% Thus, you can use tags such as ¦en-GB¦ (for British English) or ¦de-AT-1901¦ (for Austrian German, old spelling)
+% in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the language switching command
+% \cmd{\textlang\marg{tag}}, the environment \cmd{\begin\{lang\}\marg{tag}} \ldots\ \cmd{\end\{lang\}} and the \pkg{babel}
+% language switching commands\slash environments documented in section~\ref{sec:babelcmds}.
+% Table~\ref{tab:BCP47-polyglossia} lists the currently supported tags.
+% 
+% \bgroup\small\addfontfeatures{Numbers={Monospaced,Lining}}
+% \begin{longtable}[c]{lll}
+% 	\caption{\label{tab:BCP47-polyglossia}BCP47-polyglossia language name matching}\\
+% 	\toprule
+% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
+% 	\midrule
+% 	\endfirsthead
+% 	\caption[]{BCP47-polyglossia language name matching (\emph{continued})}\\
+% 	\toprule
+% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
+% 	\midrule
+% 	\endhead
+% 	aeb              & arabic      & locale=tunisia                                     \\
+% 	af               & afrikaans   &                                                    \\
+% 	afb              & arabic      & locale=default                                     \\
+% 	am               & amharic     &                                                    \\
+% 	apd              & arabic      & locale=default                                     \\
+% 	ar               & arabic      &                                                    \\
+% 	ar-IQ            & arabic      & locale=mashriq                                     \\
+% 	ar-JO            & arabic      & locale=mashriq                                     \\
+% 	ar-LB            & arabic      & locale=mashriq                                     \\
+% 	ar-MR            & arabic      & locale=mauritania                                  \\
+% 	ar-PS            & arabic      & locale=mashriq                                     \\
+% 	ar-SY            & arabic      & locale=mashriq                                     \\
+% 	ar-YE            & arabic      & locale=default                                     \\
+% 	arq              & arabic      & locale=algeria                                     \\
+% 	ary              & arabic      & locale=morocco                                     \\
+% 	arz              & arabic      & locale=default                                     \\
+% 	ast              & asturian    &                                                    \\
+% 	ayl              & arabic      & locale=libya                                       \\
+% 	be               & belarusian  &                                                    \\
+% 	be-tarask        & belarusian  & spelling=classic                                   \\
+% 	bg               & bulgarian   &                                                    \\
+% 	bn               & bengali     &                                                    \\
+% 	bo               & tibetan     &                                                    \\
+% 	br               & breton      &                                                    \\
+% 	bs               & bosnian     &                                                    \\
+% 	ca               & catalan     &                                                    \\
+% 	ckb              & kurdish     & variant=sorani [\emph{default}]                    \\
+% 	ckb-Arab         & kurdish     & variant=sorani, script=Arabic [\emph{default}]     \\
+% 	ckb-Latn         & kurdish     & variant=sorani, script=Latin                       \\
+% 	cop              & coptic      &                                                    \\
+% 	cy               & welsh       &                                                    \\
+% 	cz               & czech       &                                                    \\
+% 	da               & danish      &                                                    \\
+% 	de               & german      &                                                    \\
+% 	de-AT            & german      & variant=austrian, spelling=new                     \\
+% 	de-AT-1901       & german      & variant=austrian, spelling=old                     \\
+% 	de-AT-1996       & german      & variant=austrian, spelling=new                     \\
+% 	de-CH            & german      & variant=swiss, spelling=new                        \\
+% 	de-CH-1901       & german      & variant=swiss, spelling=old                        \\
+% 	de-CH-1996       & german      & variant=swiss, spelling=new                        \\
+% 	de-DE            & german      & variant=german, spelling=new                       \\
+% 	de-DE-1901       & german      & variant=german, spelling=old                       \\
+% 	de-DE-1996       & german      & variant=german, spelling=new  [\emph{default}]     \\
+% 	de-Latf          & german      & script=blackletter                                 \\
+% 	de-Latf-AT       & german      & variant=austrian, spelling=new, script=blackletter \\
+% 	de-Latf-AT-1901  & german      & variant=austrian, spelling=old, script=blackletter \\
+% 	de-Latf-AT-1996  & german      & variant=austrian, spelling=new, script=blackletter \\
+% 	de-Latf-CH       & german      & variant=swiss, spelling=new, script=blackletter    \\
+% 	de-Latf-CH-1901  & german      & variant=swiss, spelling=old, script=blackletter    \\
+% 	de-Latf-CH-1996  & german      & variant=swiss, spelling=new, script=blackletter    \\
+% 	de-Latf-DE       & german      & variant=german, spelling=new, script=blackletter   \\
+% 	de-Latf-DE-1901  & german      & variant=german, spelling=old, script=blackletter   \\
+% 	de-Latf-DE-1996  & german      & variant=german, spelling=new, script=blackletter   \\
+% 	dsb              & sorbian     & variant=lower                                      \\
+% 	dv               & divehi      &                                                    \\
+% 	el               & greek       &                                                    \\
+% 	el-monoton       & greek       & variant=monotonic  [\emph{default}]                \\
+% 	el-polyton       & greek       & varant=polytonic                                   \\
+% 	en               & english     &                                                    \\
+% 	en-AU            & english     & variant=australian                                 \\
+% 	en-CA            & english     & variant=canadian                                   \\
+% 	en-GB            & english     & variant=british                                    \\
+% 	en-NZ            & english     & variant=newzealand                                 \\
+% 	en-US            & english     & variant=us [\emph{default}]                        \\
+% 	eo               & esperanto   &                                                    \\
+% 	es               & spanish     &                                                    \\
+% 	es-ES            & spanish     & variant=spanish [\emph{default}]                   \\
+% 	es-MX            & spanish     & variant=mexican                                    \\
+% 	et               & estonian    &                                                    \\
+% 	eu               & basque      &                                                    \\
+% 	fa               & persian     &                                                    \\
+% 	fi               & finnish     &                                                    \\
+% 	fr               & french      &                                                    \\
+% 	fr-CA            & french      & variant=canadian                                   \\
+% 	fr-CH            & french      & variant=swiss                                      \\
+% 	fr-FR            & french      & variant=french [\emph{default}]                    \\
+% 	fur              & friulian    &                                                    \\
+% 	ga               & gaelic      & variant=irish [\emph{default}]                     \\
+% 	gd               & gaelic      & variant=scottish                                   \\
+% 	gl               & galician    &                                                    \\
+% 	grc              & greek       & variant=ancient                                    \\
+% 	he               & hebrew      &                                                    \\
+% 	hi               & hindi       &                                                    \\
+% 	hr               & croatian    &                                                    \\
+% 	hsb              & sorbian     & variant=upper [\emph{default}]                     \\
+% 	hu               & hungarian   &                                                    \\
+% 	hy               & armenian    &                                                    \\
+% 	ia               & interlingua &                                                    \\
+% 	id               & malay       & variant=indonesian                                 \\
+% 	is               & icelandic   &                                                    \\
+% 	it               & italian     &                                                    \\
+% 	ja               & japanese    &                                                    \\
+% 	ka               & georgian    &                                                    \\
+% 	km               & khmer       &                                                    \\
+% 	kmr              & kurdish     & variant=kurmanji                                   \\
+% 	kmr-Arab         & kurdish     & variant=kurmanji, script=Arabic                    \\
+% 	kmr-Latn         & kurdish     & variant=kurmanji, script=Latin                     \\
+% 	kn               & kannada     &                                                    \\
+% 	ko               & korean      &                                                    \\
+% 	ku               & kurdish     &                                                    \\
+% 	ku-Arab          & kurdish     & script=Arabic                                      \\
+% 	ku-Latn          & kurdish     & script=Latin                                       \\
+% 	la               & latin       &                                                    \\
+% 	la-x-classic     & latin       & variant=classic                                    \\
+% 	la-x-ecclesia    & latin       & variant=ecclesiastic                               \\
+% 	la-x-medieval    & latin       & variant=medieval                                   \\
+% 	lo               & lao         &                                                    \\
+% 	lt               & lithuanian  &                                                    \\
+% 	lv               & latvian     &                                                    \\
+% 	mk               & macedonian  &                                                    \\
+% 	ml               & malayalam   &                                                    \\
+% 	mn               & mongolian   &                                                    \\
+% 	mr               & marathi     &                                                    \\
+% 	nb               & norwegian   & variant=bokmal                                     \\
+% 	nko              & nko         &                                                    \\
+% 	nl               & dutch       &                                                    \\
+% 	nn               & norwegian   & variant=nynorsk [\emph{default}]                   \\
+% 	oc               & occitan     &                                                    \\
+% 	pl               & polish      &                                                    \\
+% 	pms              & piedmontese &                                                    \\
+% 	pt               & portuguese  &                                                    \\
+% 	pt-BR            & portuguese  & variant=brazilian                                  \\
+% 	pt-PT            & portuguese  & variant=portuguese [\emph{default}]                \\
+% 	rm               & romansh     &                                                    \\
+% 	ro               & romanian    &                                                    \\
+% 	ru               & russian     &                                                    \\
+% 	ru-luna1918      & russian     & spelling=modern [\emph{default}]                   \\
+% 	ru-petr1708      & russian     & spelling=old                                       \\
+% 	sa               & sanskrit    &                                                    \\
+% 	sa-Beng          & sanskrit    & script=Bengali                                     \\
+% 	sa-Deva          & sanskrit    & script=Devanagari [\emph{default}]                 \\
+% 	sa-Gujr          & sanskrit    & script=Gujarati                                    \\
+% 	sa-Knda          & sanskrit    & script=Kannada                                     \\
+% 	sa-Mlym          & sanskrit    & script=Malayalam                                   \\
+% 	sa-Telu          & sanskrit    & script=Telugu                                      \\
+% 	se               & sami        &                                                    \\
+% 	sk               & slovak      &                                                    \\
+% 	sl               & slovenian   &                                                    \\
+% 	sq               & albanian    &                                                    \\
+% 	sr               & serbian     &                                                    \\
+% 	sr-Cyrl          & serbian     & script=Cyrillic                                    \\
+% 	sr-Latn          & serbian     & script=Latin [\emph{default}]                      \\
+% 	sv               & swedish     &                                                    \\
+% 	syr              & syriac      &                                                    \\
+% 	ta               & tamil       &                                                    \\
+% 	te               & telugu      &                                                    \\
+% 	th               & thai        &                                                    \\
+% 	tk               & turkmen     &                                                    \\
+% 	tr               & turkish     &                                                    \\
+% 	uk               & ukrainian   &                                                    \\
+% 	ur               & urdu        &                                                    \\
+% 	vi               & vietnamese  &                                                    \\
+% 	zsm              & malay       & variant=malaysian [\emph{default}]                 \\
+% 	\bottomrule
+% \end{longtable}
+% \egroup
+% 
 % \subsection{Global options}
 % 
 % \pkg{Polyglossia} can be loaded with the following global package options:
 % 
 % \begin{itemize}
-% 	\item \TB{babelshorthands}\new{v1.1.1} globally activates \pkg{babel}
-% 		shorthands whenever available. Currently shorthands are implemented for
-% 		Afrikaans, Belarusian, Catalan, Czech, Dutch, Finnish, Georgian, German,
-% 		Italian, Latin, Mongolian, Russian, and Slovak. Please refer to the respective
-% 		language descriptions (sec.~\ref{specific}) for details.
+% 	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+% 		Globally activates \pkg{babel} shorthands whenever available. Currently
+% 		shorthands are implemented for Afrikaans, Belarusian, Catalan, Croatian,
+% 		Czech, Dutch, Finnish, Georgian, German, Italian, Latin, Mongolian,
+% 		Russian, Slovak, and Ukrainian. Please refer to the respective language descriptions
+% 		(sec.~\ref{specific}) for details.
 % 
-% 	\item \TB{localmarks} redefines the internal \LaTeX\ macros \cmd\markboth\ and
-% 		\cmd\markright. In earlier versions of \pkg{polyglossia},\new{v1.2.0} this
+% 	\item \xpgoption{localmarks} redefines the internal \LaTeX\ macros \cmd\markboth\ and
+% 		\cmd\markright. In earlier versions of \pkg{polyglossia},\new{1.2.0} this
 % 		option was set by default, but we now realize that it causes more problems
 % 		than it helps, so it is now off by default.  For backwards-compatibility, the
-% 		option \TB{nolocalmarks} which used to switch off the previous default, and
+% 		option \xpgoption{nolocalmarks} which used to switch off the previous default, and
 % 		now does nothing, is still available.
 % 
-% 	\item \TB{quiet} turns off most info messages and some of the warnings issued
+% 	\item \xpgoption{quiet} turns off most info messages and some of the warnings issued
 % 		by \LaTeX, \pkg{fontspec} and \pkg{polyglossia}.
 % \end{itemize}
 % 
+% \condbreak{5\baselineskip}
 % \section{Language-switching commands}\label{languageswitching}
 % 
 % \subsection{Recommended commands}\label{sec:langcmds}
 % For each activated language the command
-% \cmd{\text⟨lang⟩[⟨options⟩]\{…\}} \DescribeMacro{\text⟨lang⟩}
+% \cmd{\text\meta{lang}\oarg{options}\marg{…}} \DescribeMacro{\text\meta{lang}}
 % (as well as the synonymous \DescribeMacro{\textlang}%
-% \cmd{\textlang[⟨options⟩]\{⟨lang⟩\}\{…\}}\new{1.46})
+% \cmd{\textlang\oarg{options}\marg{lang}\marg{…}}\new{1.46})
 % becomes available for short insertions of text in that language.
+% 
 % For example ¦\textrussian{\today}¦ and ¦\textlang{russian}{\today}¦ yield \textrussian{\today}
 % The commands switch to the correct hyphenation patterns, they activate
 % some extra features for the selected language (such as extra spacing before
-% punctuation in French), and they translate the date when using ¦\today¦.
-% They do not, however, translate so-called \textit{caption strings},\ie
-% ``chapter'', ``figure'' etc., to the local language (these remain in the main
+% punctuation in French), and they translate the date when using \cmd\today.
+% They do not, however, translate so-called \textit{caption strings}, \ie
+% ``chapter'', ``figure'' etc., to the local language (these remain in the currently active `outer'
 % language).
 % 
-% The\DescribeEnv{⟨lang⟩}\ environment ¦⟨lang⟩¦, which is also available for any activated language,
-% is meant for longer passages of text. It behaves slightly different than the \cmd{\text⟨lang⟩} and
+% The\DescribeEnv{\meta{lang}}\ environment \meta{lang}, which is also available for any activated language
+% (as well as the equivalent \DescribeMacro{lang}%
+% \cmd{\begin\{lang\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{lang\}}\new{1.47}),
+% is meant for longer passages of text. It behaves slightly different than the \cmd{\text\meta{lang}} and
 % \cmd\textlang\ commands: It does everything the latter do, but additionally, the caption strings
 % are translated as well, and the language is also passed to auxiliary files, the table of contents
 % and the lists of figures/tables.
@@ -619,7 +942,7 @@
 % For instance the following allows us to quote the beginning
 % of Homer’s \textit{Iliad}:
 % 
-% \begin{Verbatim}[formatcom=\color{myblue}]
+% \begin{Verbatim}[formatcom=\color{xpgblue}]
 %   \begin{quote}
 %    \begin{greek}[variant=ancient]
 %      μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς
@@ -651,17 +974,17 @@
 % compiled into the \XeLaTeX\ and \LuaLaTeX\ format) are redefined, but keep a
 % similar behaviour.
 % \begin{itemize}
-% \item \DescribeMacro{\selectlanguage}\cmd{\selectlanguage[⟨options⟩]\{⟨lang⟩\}}
-% \item \DescribeMacro{\foreignlanguage}\cmd{\foreignlanguage[⟨options⟩]\{⟨lang⟩\}\{…\}}
-% \item \DescribeEnv{otherlanguage}\cmd{\begin\{otherlanguage\}[⟨options⟩]\{⟨lang⟩\}} \dots{} \cmd{\end\{otherlanguage\}}
-% \item \DescribeEnv{otherlanguage*}\cmd{\begin\{otherlanguage*\}[⟨options⟩]\{⟨lang⟩\}} \dots{} \cmd{\end\{otherlanguage*\}}
+% \item \DescribeMacro{\selectlanguage}\cmd{\selectlanguage\oarg{options}\marg{lang}}
+% \item \DescribeMacro{\foreignlanguage}\cmd{\foreignlanguage\oarg{options}\marg{lang}\marg{…}}
+% \item \DescribeEnv{otherlanguage}\cmd{\begin\{otherlanguage\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage\}}
+% \item \DescribeEnv{otherlanguage*}\cmd{\begin\{otherlanguage*\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage*\}}
 % \end{itemize}
 % ^^A
-% ¦\selectlanguage{⟨lang⟩}¦ and the ¦otherlanguage¦ environment are identical to the
-% the ¦⟨lang⟩¦ environment, except that ¦\selectlanguage{⟨lang⟩}¦
-% does not need to be explicitly closed. The command ¦\foreinlanguage{⟨lang⟩}{…}¦ and the ¦otherlanguage*¦
-% environment are identical with the use of the ¦\text⟨lang⟩¦ or ¦\textlang¦ command, with the one
-% notable exception that they do not translate the date with ¦\today¦.
+% \cmd\selectlanguage\marg{lang} and the ¦otherlanguage¦ environment are identical to the
+% the \meta{lang} environment, except that \cmd\selectlanguage\marg{lang}
+% does not need to be explicitly closed. The command \cmd\foreinlanguage\marg{lang}\marg{…} and the ¦otherlanguage*¦
+% environment are identical with the use of the \cmd\text\meta{lang} or \cmd\textlang\ command, with the one
+% notable exception that they do not translate the date with \cmd\today.
 % 
 % Since the \XeLaTeX\ and \LuaLaTeX\ format incorporate \pkg{babel}’s \file{hyphen.cfg},
 % the low-level commands for hyphenation and language switching
@@ -669,13 +992,12 @@
 % 
 % \subsection{Other commands}
 % The following commands are probably of lesser interest to the end user, but
-% ought to be mentioned here.\footnote{Note that these commands require polyglossia
-% language names; they do not support language\slash babel aliases.}
+% ought to be mentioned here.
 % \begin{itemize}
-% \item \DescribeMacro{\selectbackgroundlanguage}\cmd{\selectbackgroundlanguage\{⟨lang⟩\}}:
+% \item \DescribeMacro{\selectbackgroundlanguage}\cmd{\selectbackgroundlanguage\marg{lang}}:
 %     this selects the global font setup and the numbering definitions for the default language.
 % 
-% \item \DescribeMacro{\resetdefaultlanguage}\cmd{\resetdefaultlanguage[⟨options⟩]\{⟨lang⟩\}} (experimental):
+% \item \DescribeMacro{\resetdefaultlanguage}\cmd{\resetdefaultlanguage\oarg{options}\marg{lang}} (experimental):
 % 	completely switches the default language
 % 	to another one in the middle of a document: \textit{this may have adverse effects}!
 % 
@@ -693,43 +1015,49 @@
 % \subsection{Setting up alias commands}
 % 
 % By means of the macro
-% \displaycmd{\setlanguagealias[⟨options⟩]\{⟨language⟩\}\{⟨alias⟩\}}{\setlanguagealias}\new{v1.46}
+% \displaycmd{\setlanguagealias\oarg{options}\marg{language}\marg{alias}}{\setlanguagealias}\new{1.46}
 % you can define alias commands for specific language (variants). \Eg
 % 
 % \begin{quote}
 % \begin{verbatim}
-% \setlanguagealias[variant=austrian]{german}{deAT}
+% \setlanguagealias[variant=austrian]{german}{AT}
 % \end{verbatim}
 % \end{quote}
 % ^^A
-% will define a command \cmd{\textdeAT} as well as an environment ¦{deAT}¦ which will link towards
-% the command \cmd{\textgerman[variant=austrian]} and the environment ¦{german}[variant=austrian]¦,
+% will define a command \cmd{\textAT} as well as an environment ¦{AT}¦ which will link towards
+% the command ¦\textgerman[variant=austrian]¦ and the environment ¦{german}[variant=austrian]¦,
 % respectively. The aliases can also be used in the language switching commands described in
 % section~\ref{sec:langcmds} and \ref{sec:babelcmds}.
 % Note, though, that the usual restrictions for command names apply, so something such as
-% ¦de-AT¦ or ¦de_AT¦ will not work since ¦-¦ and ¦_¦ are not allowed in command names.
+% ¦de-AT¦ or ¦de_AT¦ will not work since ¦-¦ and ¦_¦ are not allowed in command names (the same
+% holds true for any non-ASCII character and for digits).
 % 
-% For the latter case, and for the case where an alias would clash with an existing \cmd{\text⟨...⟩}
-% command (\eg ¦\textit¦), a starred version \Cmd{\setlanguagealias*} is provided which does not define
-% a \cmd{\text⟨alias⟩} command (but which will set up the alias for everything else, including
-% \cmd{\textlang\{⟨alias⟩\}}).
+% For the latter case, and for the case where an alias would clash with an existing command
+% (\eg ¦\fi¦) or a \cmd{\text\meta{\ldots}} command (\eg \cmd\textit), a starred version \Cmd{\setlanguagealias*}
+% is provided which does neither define a \cmd{\text\meta{alias}} command nor an \meta{alias} environment,
+% but which will set up the alias for everything else, including \cmd{\textlang\marg{alias}}
+% and \cmd{\begin\{lang\}\marg{alias}}.
 % 
+% \pkg{Polyglossia} comes with some aliases predefined, namely aliases for \pkg{babel} language names
+% (see sec.~\ref{sec:babelnames}) and for IETF BCP-47 language tags (the latter via \cmd{\setlanguagealias*};
+% see sec.~\ref{sec:langtags}).
+% 
 % \section{Font setup}
 % 
 % With polyglossia it is possible to associate a specific font with any script or language
 % that occurs in the document. That font should always be defined as
-% ¦\⟨script⟩font¦\ or ¦\⟨language⟩font¦.
+% \cmd{\⟨script⟩font}\ or \cmd{\⟨language⟩font}.
 % For instance, if the default font defined by \cmd\setmainfont\
 % does not support Greek, then one can define the font used to display Greek with:\\
-% \centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,⟨…⟩]\{⟨font⟩\}}. }
+% \centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,\meta{…}]\marg{font}}. }
 % Note that polyglossia will use the font defined as is, so assure to do all necessary settings
 % (please refer to the \pkg{fontspec} documentation for details).
-% For instance, if ¦\arabicfont¦ is explicitly defined, then the option ¦Script=Arabic¦ should
+% For instance, if \cmd\arabicfont\ is explicitly defined, then the option ¦Script=Arabic¦ should
 % be included in that definition.
 % 
 % If a specific sans serif or monospace (`teletype') font is needed for a particular script or language,
-% it can be defined by means of \new{v1.2.0}
-% ¦\⟨script⟩fontsf¦\ or ¦\⟨language⟩fontsf¦ and ¦\⟨script⟩fonttt¦\ or ¦\⟨language⟩fonttt¦, respectively.
+% it can be defined by means of \new{1.2.0}
+% \cmd{\⟨script⟩fontsf} or \cmd{\⟨language⟩fontsf} and \cmd{\⟨script⟩fonttt} or \cmd{\⟨language⟩fonttt}, respectively.
 % 
 % Whenever a new language is activated, \pkg{polyglossia} will first check whether
 % a font has been defined for that language or – for languages in non-Latin scripts –
@@ -744,7 +1072,7 @@
 % 
 % \subsection{Hyphenation exceptions}
 % 
-% \TeX\ provides the command ¦\hyphenation{⟨exceptions⟩}¦ to globally define hyphenation exceptions
+% \TeX\ provides the command \cmd\hyphenation\marg{exceptions} to globally define hyphenation exceptions
 % which override the hyphenation patterns for specified words. The command takes as argument a space-separated
 % list of words where hyphenation points are marked by a dash (if no dash is used, the respective word is not
 % hyphenated at all):
@@ -756,8 +1084,8 @@
 % \end{Verbatim}
 % ^^A
 % These exceptions, however, apply to all languages. In addition to this, \pkg{polyglossia} provides
-% the command\new{v1.45}
-% \displaycmd{\pghyphenation[⟨options⟩]\{⟨lang⟩\}\{⟨exceptions⟩\}}{\pghyphenation}
+% the command\new{1.45}
+% \displaycmd{\xpghyphenation\oarg{options}\marg{lang}\marg{exceptions}}{\xpghyphenation}
 % which can be used to define exceptions that only apply to a specific language or language variant,
 % respectively.
 % 
@@ -772,25 +1100,33 @@
 % 
 % \section{Language-specific options and commands}\label{specific}
 % 
-% This section gives a list of all languages for which options and end-user commands are defined.
-% The default value of each option is given in italic.
+% This section gives a list of all languages for which options and end-user
+% commands are defined. Note the following conventions:
+% \begin{itemize}
+% 	\item The preset value of each option (\ie the setting that applies by default,
+% 	if the option is not explicitly set) is given in \xpgpresetvalue{italics}.
+% 	\item If an option key may be used without a value, the value that applies
+% 	for value-less keys is marked by a preceding \xpgdefaultvalue{asterisk}.
+% \end{itemize}
+% For instance, \texttt{babelshorthands = *true} or \texttt{\textit{false}} means that
+% \xpgvalue{babelshorthands} is \xpgvalue{false} by default in the respective language,
+% and that passing \xpgvalue{babelshorthands} (without value) is equivalent to passing
+% \xpgvalue{babelshorthands=true}.
 % 
-% ^^A\subsection{amharic}\label{amharic}
-% 
-% \subsection{afrikaans}\label{afikaans}
+% \subsection{afrikaans}\label{afrikaans}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-% 	if this is turned on, the following shorthands defined for fine-tuning hyphenation and
+% 	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+% 	If this is turned on, the following shorthands defined for fine-tuning hyphenation and
 % 	micro-typography of Afrikaans words are activated:
 % 	\begin{shorthands}
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		in the hyphenation patterns (as opposed to ¦\-¦ in default \TeX).
+% 		in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 % 		cases where the hyphen should stick at the following syllable.
 % 		\item[¦"|¦] disables a ligature at this position.
 % 		\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 ¦\slash¦,
+% 		\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}
 % \end{itemize}
@@ -798,23 +1134,23 @@
 % \subsection{arabic}\label{arabic}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{calendar} = \textit{gregorian} or islamic (= hijri)
-% 	\item \TB{locale} = \textit{default},\footnote{ %
-% 			For Egypt, Sudan, Yemen and the Gulf states.}
-% 		mashriq,\footnote{ %
-% 			For Iraq, Syria, Jordan, Lebanon and Palestine.}
-% 		libya, algeria, tunisia, morocco, or mauritania.
+% 	\item \xpgchoicekey{calendar}{\xpgpresetvalue{gregorian} or \xpgvalue{islamic} (= \xpgvalue{hijri})}
+% 	\item \xpgchoicekey{locale}{\xpgpresetvalue{default}\footnote{ %
+% 			For Egypt, Sudan, Yemen and the Gulf states.},
+% 		\xpgvalue{mashriq}\footnote{ %
+% 			For Iraq, Syria, Jordan, Lebanon and Palestine.},
+% 		\xpgvalue{libya}, \xpgvalue{algeria}, \xpgvalue{tunisia}, \xpgvalue{morocco}, \xpgvalue{mauritania}}
 % 		This setting influences the spelling of the month names for the Gregorian calendar,
 % 		as well as the form of the numerals (unless overriden by the following option).
-% 	\item \TB{numerals} = \textit{mashriq} or maghrib
-% 		(the latter is the default when locale = algeria, tunisia or morocco)
-%   \item \TB{abjadjimnotail} = \textit{false} or true. \new{v1.0.3}
+% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{mashriq} or \xpgvalue{maghrib}}
+% 		The latter is the default when \xpgvalue{locale=algeria}, \xpgvalue{tunisia}, or \xpgvalue{morocco}.
+% 	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
 %     Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
 % 	\end{itemize}
 % \paragraph*{Commands:}
 % 	\begin{itemize}
 % 	\item \Cmd\abjad and \Cmd\abjadmaghribi (see section \ref{abjad})
-%   \item \Cmd\aemph to emphasize text with ¦\overline¦.\new{v1.2.0}
+%   \item \Cmd\aemph to emphasize text with \cmd\overline.\new{1.2.0}
 %     ¦\textarabic{\aemph{اب}}¦ yields \textarabic{\aemph{اب}}.
 %     This command is also available for Farsi, Urdu, etc.
 % 	\end{itemize}
@@ -822,19 +1158,19 @@
 % \subsection{armenian}\label{armenian}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant}\new{v1.45} = eastern or \textit{western}
-% 	\item \TB{numerals}\new{v1.45} = armenian or \textit{arabic}
+%   \item \xpgchoicekey[1.45]{variant}{\xpgvalue{eastern} or \xpgpresetvalue{western}}
+% 	\item \xpgchoicekey[1.45]{numerals}{\xpgvalue{armenian} or \xpgpresetvalue{arabic}}
 % \end{itemize}
 % 
-% \subsection[belarusian]{belarusian\new{v1.46}}\label{belarusian}
+% \subsection[belarusian]{belarusian\new{1.46}}\label{belarusian}
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true.
+%   \item \xpgboolkeyfalse{babelshorthands}
 % 	If this is turned on, the following shorthands are activated:
 % 	\begin{shorthands}
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		in the hyphenation patterns (as opposed to ¦\-¦).
+% 		in the hyphenation patterns (as opposed to \cmd\-).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 % 		cases where the hyphen should stick at the following syllable.
 % 		\item[¦"|¦] disables a ligature at this position.
@@ -848,67 +1184,123 @@
 % 		\item[¦"<¦] for French left double quotes (looks like <<).
 % 		\item[¦">¦] for French right double quotes (looks like >>).
 % 	\end{shorthands}
-% 	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-% 	alphanumerical numbering.
-% 	\item \TB{spelling} = \textit{modern} or classic (=~tarask). With ¦spelling=classic¦, captions and dates
-% 	     adhere to the Taraškievica (or Belarusian classical) orthography rather than the standard orthography.
+%     \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}
+% 	          \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+% 	          \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+% 	                \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+% 	                It supports numbers up to 999\,999.
+%          \end{itemize}
+% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{classic} (= \xpgvalue{tarask})}
+% 	With ¦spelling=classic¦, captions and dates adhere to the Taraškievica (or
+% 	Belarusian classical) orthography rather than the standard orthography.
 % \end{itemize}
 % ^^A
 % \paragraph*{Commands:}
 % \begin{itemize}
-% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-% 	environments such as ¦enumerate¦. The command takes a counter as argument,
-% 	\eg ¦\textbelarusian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-% 	\item \Cmd\asbuk: same in lowercase
+%      \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+%           The command takes a counter as argument, \eg ¦\textbelarusian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
+%      \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+%      \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+%           numbers up to 999\,999.\\
+%           \Eg ¦\textbelarusian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+%      \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 % \end{itemize}
 % 
-% \subsection[bengali]{bengali\new{v1.2.0}}\label{bengali}
+% \subsection[bengali]{bengali\new{1.2.0}}\label{bengali}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 		\item \TB{numerals} = Western, Bengali or \textit{Devanagari}
-% 		\item \TB{changecounternumbering} = true or \textit{false} (use specified
-% 			numerals for headings and page numbers)
+% 	  \item \xpgchoicekey{numerals}{\xpgvalue{Western}, \xpgvalue{Bengali}, or \xpgpresetvalue{Devanagari}}
+% 		\item \xpgboolkeyfalse{changecounternumbering}
+% 		Use specified numerals for headings and page numbers.
 % 	\end{itemize}
 % 
 % \subsection{catalan}\label{catalan}
 % \paragraph*{Options:}
 % \begin{itemize}
-%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-%     Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l’s.
+%   \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+%     Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l or L.
 % \end{itemize}
 % 
 % \paragraph*{Commands:}
 % \begin{itemize}
-%   \item \Cmd{\l.l} and \Cmd{\L.L}\new{v1.1.1} can be used to type a geminated l, as in \textit{co\l.laborar},
+%   \item \Cmd{\l.l} and \Cmd{\L.L}\new{1.1.1} can be used to type a geminated l, as in \textit{co\l.laborar},
 %         similar to \pkg{babel} (the glyph U+00B7 MIDDLE DOT is used as a geminating sign).
 % \end{itemize}
 % 
+% \subsection{croatian}\label{croatian}
+% \paragraph*{Options:}
+% \begin{itemize}
+% 	\item \xpgboolkeyfalse[1.47]{babelshorthands}
+% 	If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
+% 	of Croatian words are activated.
+% 	\begin{shorthands}
+% 		\item[¦"|¦] disables a ligature at this position.
+% 		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
+% 		            other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
+% 		\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.
+% 	\end{shorthands}
+% 	Furthermore, the following shorthands generate easy access to Croatian digraphs (ligatures):
+% 	\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}).
+% 	\end{shorthands}
+% 	
+% 	Finally, there are also four shorthands for quotation marks:
+% 	\begin{shorthands}
+% 		\item[¦"`¦] for Croatian left double quotes („).
+% 		\item[¦"'¦] for Croatian right double quotes (”).
+% 		\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).
+% \end{itemize}
+% 
 % \subsection{czech}\label{czech}
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.45}
-% 	if this is turned on, the following shorthands for Czech are activated:
+% 	\item \xpgboolkeyfalse[1.45]{babelshorthands}
+% 	If this is turned on, the following shorthands for Czech are activated:
 % 	\begin{shorthands}
 % 		\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
 % 		            of the next line when hyphenated, as common in Czech typesetting
 % 		            (only needed with ¦splithyphens=false¦).
-% 		\item[¦"‘¦] for Czech left double quotes (looks like ,,).
-% 		\item[¦"’¦] for Czech right double quotes (looks like “).
-% 		\item[¦">¦] for Czech left double guillemets (looks like >>).
-% 		\item[¦"<¦] for Czech right double guillemets (looks like <<).
+% 		\item[¦"‘¦] for Czech left double quotes („).
+% 		\item[¦"’¦] for Czech right double quotes (“).
+% 		\item[¦">¦] for Czech left double guillemets (»).
+% 		\item[¦"<¦] for Czech right double guillemets («).
 % 	\end{shorthands}
-% 	\item \TB{splithyphens} = false or \textit{true}.\new{v1.45}
+% 	\item \xpgboolkeytrue[1.45]{splithyphens}
 % 	      According to Czech 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}).
-%           By default, this is done automatically\new{v1.46} (if you are using \LuaTeX, the \pkg{luavlna} package is
+%           By default, this is done automatically\new{1.46} (if you are using \LuaTeX, the \pkg{luavlna} package is
 %           loaded to achieve this).
 %           Set this option to ¦false¦ to disable the feature.
-%     \item \TB{vlna} = false or \textit{true}. \new{v1.45}
+% 	\item \xpgboolkeytrue[1.45]{vlna}
 %          According to Czech typesetting conventions, single-letter words (non-syllable prepositions)
 %          must not occur at line ends.
-%          \pkg{Polyglossia} takes care of this automatically by default\new{v1.46} (if you are using \LuaTeX, the
+%          \pkg{Polyglossia} takes care of this automatically by default\new{1.46} (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}
@@ -916,17 +1308,17 @@
 % \subsection{dutch}\label{dutch}
 % \paragraph*{Options:}
 % \begin{itemize}
-%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
-% 		if this is turned on, the following shorthands defined for fine-tuning hyphenation and
+%   \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
+% 		If this is turned on, the following shorthands defined for fine-tuning hyphenation and
 % 		micro-typography of Dutch words are activated:
 % 		\begin{shorthands}
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 			        in the hyphenation patterns (as opposed to ¦\-¦ in default \TeX).
+% 			        in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 % 			        cases where the hyphen should stick at the following syllable.
 % 		\item[¦"|¦] disables a ligature at this position.
 % 		\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 ¦\slash¦,
+% 		\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}
 %         In addition, the macro \Cmd\- is redefined to allow hyphens in the rest of the word (equivalent to ¦"-¦).
@@ -935,9 +1327,10 @@
 % \subsection{english}\label{english}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{variant} = \textit{american} (= us), usmax (same as ‘american’ but with additional hyphenation patterns),
-% 	british (= uk), australian, canadian\new{v1.45} or newzealand
-% 	\item \TB{ordinalmonthday} = true/\textit{false} (true by default only when variant = british)
+% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{american} (= \xpgvalue{us}), \xpgvalue{usmax} (same as \xpgvalue{american} but with additional hyphenation patterns),
+% 	\xpgvalue{british} (= \xpgvalue{uk}), \xpgvalue{australian}, \xpgvalue{canadian}\new{1.45}, or \xpgvalue{newzealand}}
+% 	\item \xpgboolkeyfalse{ordinalmonthday}
+% 		The default value is true for \xpgvalue{variant=british}.
 % 	\end{itemize}
 % 
 % \subsection{esperanto}\label{esperanto}
@@ -951,17 +1344,17 @@
 % \subsection{finnish}\label{finnish}
 % \paragraph*{Options:}
 % \begin{itemize}
-%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.45}
-% 		if this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
-% 		of Finnish words are activated:
+%   \item \xpgboolkeyfalse[1.45]{babelshorthands}
+% 		If this is turned on, the following shorthands for fine-tuning hyphenation
+% 		and micro-typography of Finnish words are activated:
 % 		\begin{shorthands}
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-%                     in the hyphenation patterns (as opposed to ¦\-¦).
+%                     in the hyphenation patterns (as opposed to \cmd\-).
 %         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 %                     cases where the hyphen should stick at the following syllable.
 %         \item[¦"|¦] disables a ligature at this position.
 %         \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 ¦\slash¦,
+%         \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}
 % \end{itemize}
@@ -969,90 +1362,115 @@
 % \subsection{french}\label{french}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 		\item\TB{variant} = \textit{french} or canadian (=~acadian).\new{v1.45}
-% 		Currently, the three variants do not differ; they are supported for compatibility with \pkg{babel} (where they do not differ either).
-% 		\item \TB{autospacing} = \textit{true} or false. One of the most distinct features of French typography is the addition
-% 		of extra spacing around punctuation and quotation marks (guillemets). By default, polyglossia adds these spaces automatically, so you don't need
-% 		to enter them. This options allows you to switch this feature off globally.
-% 		\item \TB{thincolonspace}\new{v1.46} = true or \textit{false}. Normally, a
-% 		full (non-breaking) interword space is inserted before a colon. Use this
-% 		option if you prefer a thinner space as used before \texttt{;}, \texttt{!},
-% 		and \texttt{?}.
-% 		\item \TB{autospaceguillemets}\footnote{Up to version 1.44, the option was
-% 		called \textit{automaticspacesaroundguillemets}. For backards compatibility
-% 		reasons, the more verbose old option is still supported.} = \textit{true}
-% 		or false. If you only want to disable the automatic addition of spacing
-% 		after opening and before closing guillemets (and not at punctuation), set
-% 		this to \textit{false}. Note that the more general option
-% 		\textit{autospacing} overrides this.
-% 		\item \TB{autospacetypewriter}\footnote{Babel's syntax \textit{OriginalTypewriter} is also supported.}\new{1.45} = true or \textit{false} (default value = true). By default, automatic spacing is disabled in typewriter font. If this is enabled, spacing in typewriter context is the same as with roman and sans serif font, depending on the \textit{autospacing} and \textit{autospaceguillemets} settings (note that this was the default up to v.~1.44).	
-% 		\item \TB{frenchfootnote} = true or \textit{false} (default value = true). If \textit{true}, footnotes start with a non-superscripted number followed by a dot, as common in French typography. Note that this might interfere with the specific footnote handling of classes or packages.
-% 		Also note that this option is only functional (by design) if French is the main language.
-% 		\item \TB{frenchitemlabels}\new{v.1.46} = true or \textit{false} (default value = true). If \textit{true}, itemize item labels use em-dashes throughout,
-% 		as common in French typography.
-% 		Note that this option is only functional (by design) if French is the main language. Also, it might interfere with list packages such as \pkg{enumitem}.
-% 		\item \TB{itemlabels}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of all levels.
-% 		\item \TB{itemlabeli}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the first level.
-% 		\item \TB{itemlabelii}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the second level.
-% 		\item \TB{itemlabeliii}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the third level.
-% 		\item \TB{itemlabeliv}\new{v.1.46} = ¦⟨cmd⟩¦ (default value = ¦\textemdash¦). If \emph{frenchitemlabels} is true, you can customize here the used item label of the fourth level.
+% 		\item \xpgchoicekey{variant}{\xpgpresetvalue{french} or \xpgvalue{canadian} (=~\xpgvalue{acadian})\new{1.45}, \xpgvalue{swiss}\new{1.47}}
+% 			Currently, the only difference between the four variants is that \xpgvalue{swiss}
+% 			uses \xpgvalue{thincolonspace=true} by default since this conforms to the Swiss
+% 			conventions.
+% 		\item \xpgboolkeytrue{autospacing}
+% 			One of the most distinct features of French typography is the addition of
+% 			extra spacing around punctuation and quotation marks (guillemets). By
+% 			default, polyglossia adds these spaces automatically, so you don't need
+% 			to enter them. This options allows you to switch this feature off
+% 			globally.
+% 		\item \xpgboolkeyfalse[1.46]{thincolonspace}
+% 			With \xpgvalue{variant=swiss}, the default value is \xpgvalue{true}. If \xpgvalue{false}, a full
+% 			(non-breaking) interword space is inserted before a colon. If \xpgvalue{true}, a
+% 			thinner space -- as before \texttt{;}, \texttt{!}, and \texttt{?} -- is
+% 			used. Note that this option must be set after the ¦variant¦ option.
+% 		\item \xpgboolkeytrue{autospaceguillemets}[Up to version 1.44, the option was
+% 		called \xpgvalue{automaticspacesaroundguillemets}. For backwards compatibility
+% 		reasons, the more verbose old option is still supported.]
+% 			If you only want to disable the automatic addition of spacing after
+% 			opening and before closing guillemets (and not at punctuation), set this
+% 			to \textit{false}. Note that the more general option \textit{autospacing}
+% 			overrides this.
+% 		\item \xpgboolkeyfalse[1.45]{autospacetypewriter}[Babel's syntax \xpgvalue{OriginalTypewriter}
+% 		is also supported.]
+% 			By default, automatic spacing is disabled in typewriter font. If this is
+% 			enabled, spacing in typewriter context is the same as with roman and sans
+% 			serif font, depending on the \xpgvalue{autospacing} and
+% 			\xpgvalue{autospaceguillemets} settings (note that this was the default up
+% 			to v.~1.44).	
+% 		\item \xpgboolkeyfalse{frenchfootnote}
+% 			If \xpgvalue{true}, footnotes start with a non-superscripted number
+% 			followed by a dot, as common in French typography. Note that this might
+% 			interfere with the specific footnote handling of classes or packages.
+% 			Also note that this option is only functional (by design) if French is
+% 			the main language.
+% 		\item \xpgboolkeyfalse[1.46]{frenchitemlabels}
+% 			If \textit{true}, itemize item labels use em-dashes throughout, as common
+% 			in French typography.  Note that this option is only functional (by
+% 			design) if French is the main language. Also, it might interfere with
+% 			list packages such as \pkg{enumitem}.
+% 		\item \xpgcodekey[1.46]{itemlabels}¦\textemdash¦
+% 			If \emph{frenchitemlabels} is true, you can customize here the used item
+% 			label of all levels.
+% 		\item \xpgcodekey[1.46]{itemlabeli}¦\textemdash¦
+% 			If \emph{frenchitemlabels} is true, you can customize here the used item
+% 			label of the first level.
+% 		\item \xpgcodekey[1.46]{itemlabelii}¦\textemdash¦
+% 			If \emph{frenchitemlabels} is true, you can customize here the used item
+% 			label of the second level.
+% 		\item \xpgcodekey[1.46]{itemlabeliii}¦\textemdash¦
+% 			If \emph{frenchitemlabels} is true, you can customize here the used item
+% 			label of the third level.
+% 		\item \xpgcodekey[1.46]{itemlabeliv}¦\textemdash¦
+% 			If \emph{frenchitemlabels} is true, you can customize here the used item
+% 			label of the fourth level.
 % 	\end{itemize}
 % \paragraph*{Commands:}
 % \begin{itemize}
-% 	\item \Cmd\NoAutoSpacing\new{v1.45} disables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\NoAutoSpacing foo:bar}¦
-% 	\item \Cmd\AutoSpacing\new{v1.45} enables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\AutoSpacing regarde!}¦
+% 	\item \Cmd\NoAutoSpacing\new{1.45} disables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\NoAutoSpacing foo:bar}¦
+% 	\item \Cmd\AutoSpacing\new{1.45} enables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\AutoSpacing regarde!}¦
 % \end{itemize}
 % 
-% \subsection[gaelic]{gaelic\new{v1.45}}\label{gaelic}
+% \subsection[gaelic]{gaelic\new{1.45}}\label{gaelic}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant} = \textit{irish} or scottish
+% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{irish} or \xpgvalue{scottish}}
 % \end{itemize}
 % 
-% \subsection[georgian]{georgian\new{v1.46}}\label{georgian}
+% \subsection[georgian]{georgian\new{1.46}}\label{georgian}
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true.
-% 	If this is turned on, the following shorthands are activated:
-% 	\begin{shorthands}
-% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		in the hyphenation patterns (as opposed to ¦\-¦).
-% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
-% 		cases where the hyphen should stick at the following syllable.
-% 		\item[¦"|¦] disables a ligature at this position.
-% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
-% 		\item[¦"---¦] Cyrillic emdash in plain text.
-% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
-% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
-% 		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
-% 		\item[¦"‘¦] for German left double quotes (looks like ,,).
-% 		\item[¦"’¦] for German right double quotes (looks like “).
-% 		\item[¦"<¦] for French left double quotes (looks like <<).
-% 		\item[¦">¦] for French right double quotes (looks like >>).
-% 	\end{shorthands}
-% 	\item \TB{numerals} = \textit{arabic} or georgian. Uses either Arabic numerals or Georgian
-% 	      alphanumerical numbering.
-%     \item \TB{oldmonthnames} = \textit{true} or false (default: false). Uses traditional Georgian
-%           month names.
+% 	\item \xpgboolkeyfalse{babelshorthands}
+% 		If this is turned on, the following shorthands are activated:
+% 		\begin{shorthands}
+% 			\item[¦"-¦] adds a hyphenation point that does still allow for
+% 			hyphenation at the points preset in the hyphenation patterns (as opposed
+% 			to \cmd\-).
+% 			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+% 			cases where the hyphen should stick at the following syllable.
+% 			\item[¦"|¦] disables a ligature at this position.
+% 			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+% 			\item[¦"---¦] Cyrillic emdash in plain text.
+% 			\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
+% 			\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
+% 			\item[¦",¦] thinspace for initials with a breakpoint in following surname.
+% 			\item[¦"‘¦] for German left double quotes (looks like ,,).
+% 			\item[¦"’¦] for German right double quotes (looks like “).
+% 			\item[¦"<¦] for French left double quotes (looks like <<).
+% 			\item[¦">¦] for French right double quotes (looks like >>).
+% 		\end{shorthands}
+% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic} or \xpgvalue{georgian}}
+% 		Uses either Arabic numerals or Georgian alphanumerical numbering.
+% 	\item \xpgboolkeyfalse{oldmonthnames}
+% 		Uses traditional Georgian month names.
 % \end{itemize}
 % 
 % \subsection{german}\label{german}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item\TB{variant} = \textit{german}, austrian or swiss.\new{v1.33.4}
-% 		Setting variant=austrian or variant=swiss uses some lexical variants.
-% 		With spelling=old, variant=swiss furthermore loads specific hyphenation
+% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{german}, austrian, or swiss\new{1.33.4}}
+% 		Setting \xpgvalue{variant=austrian} or \xpgvalue{variant=swiss} uses some lexical variants.
+% 		With \xpgvalue{spelling=old}, \xpgvalue{variant=swiss} furthermore loads specific hyphenation
 % 		patterns.
-% 	\item \TB{spelling} = \textit{new} (= 1996) or old (= 1901):
-% 		indicates whether hyphenation patterns for traditional (1901) or reformed
+% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{new} (= \xpgvalue{1996}) or \xpgvalue{old} (= \xpgvalue{1901})}
+% 		Indicates whether hyphenation patterns for traditional (1901) or reformed
 % 		(1996) orthography should be used. The latter is the default.
-% 	\item \TB{latesthyphen} = \textit{false} or true: if this option is set to true,
-% 		the latest (experimental) hyphenation patterns ‘(n)german-x-latest’
-% 		will be loaded instead of ‘german’ or ‘ngerman’. NB: This is based on
-% 		the file \texttt{language.dat} that comes with \TeX Live 2008 and later.
-% 	\item\TB{babelshorthands} = \textit{false} or true: \new{v1.0.3}
-% 		if this is turned on, all shorthands defined in \pkg{babel}
+% 	\item \xpgboolkeyfalse[1.0.3]{babelshorthands}
+% 		If this is turned on, all shorthands defined in \pkg{babel}
 % 		for fine-tuning hyphenation and micro-typography of German words are activated.
 % 		\begin{shorthands}
 % 		\item[¦"ck¦] for ¦ck¦ to be hyphenated as ¦k-k¦ (1901 spelling).
@@ -1062,12 +1480,12 @@
 % 		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
 % 		           other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
-% 		           cases where the hyphen should stick at the following syllable,\eg ¦bergauf und "~ab¦.
+% 		           cases where the hyphen should stick at the following syllable, \eg ¦bergauf und "~ab¦.
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		           in the hyphenation patterns (as opposed to ¦\-¦).
-% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign); 
+% 		           in the hyphenation patterns (as opposed to \cmd\-).
+% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign);
 % 		           \eg ¦(pseudo"~)""wissenschaftlich¦.
-% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to ¦\slash¦, hyphenation at the breakpoints
+% 		\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}
 % 
@@ -1078,7 +1496,7 @@
 % 		\item[¦"<¦] for French left double quotes («)
 % 		\item[¦">¦] for French right double quotes (»).
 % 		\end{shorthands}
-% 	\item\TB{script} = \textit{latin} or blackletter\new{v1.46} (=~fraktur\new{v1.2.0}).
+% 	\item \xpgchoicekey[1.2.0]{script}{\xpgpresetvalue{latin} or \xpgvalue{blackletter}\new{1.46} (= \xpgvalue{fraktur})}
 % 		Setting ¦script=blackletter¦ adapts the captions for typesetting German in blackletter type (using the long s (ſ)
 % 		where appropriate).
 % 	\end{itemize}
@@ -1086,9 +1504,9 @@
 % \subsection{greek}\label{greek}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{variant} = \textit{monotonic} (= mono), polytonic (= poly), or ancient
-% 	\item \TB{numerals} = \textit{greek} or arabic
-% 	\item \TB{attic} = \textit{false}/true
+% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{monotonic} (= \xpgvalue{mono}), \xpgvalue{polytonic} (= \xpgvalue{poly}), or \xpgvalue{ancient}}
+% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{greek} or \xpgvalue{arabic}}
+% 	\item \xpgboolkeyfalse{attic}
 % 	\end{itemize}
 % \paragraph*{Commands:}
 % 	\begin{itemize}
@@ -1103,10 +1521,12 @@
 % \subsection{hebrew}\label{hebrew}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{numerals} = hebrew or \textit{arabic}
-% 	\item \TB{calendar} = hebrew or \textit{gregorian}
-% 	\item \TB{marcheshvan} = true or \textit{false} (default value = true). If true, the second month of the civil year will be output as \texthebrew{מרחשון} (Marcheshvan)
-% 	rather than \texthebrew{חשון} (Heshvan), which is the default.
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{hebrew} or \xpgpresetvalue{arabic}}
+% 	\item \xpgchoicekey{calendar}{\xpgvalue{hebrew} or \xpgpresetvalue{gregorian}}
+% 	\item \xpgboolkeyfalse{marcheshvan}
+% 		If \xpgvalue{true}, the second month of the civil year will be output as
+% 		\texthebrew{מרחשון} (Marcheshvan) rather than \texthebrew{חשון} (Heshvan),
+% 		which is the default.
 % 	\end{itemize}
 % \paragraph*{Commands:}
 % 	\begin{itemize}
@@ -1114,17 +1534,17 @@
 %   \item \Cmd\aemph (see section \ref{arabic}).
 % 	\end{itemize}
 % 
-% \subsection[hindi]{hindi\new{v1.2.0}}\label{hindi}
+% \subsection[hindi]{hindi\new{1.2.0}}\label{hindi}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-%     \item \TB{numerals} = Western or \textit{Devanagari}
+% 		\item \xpgchoicekey{numerals}{\xpgvalue{Western} or \xpgpresetvalue{Devanagari}}
 % 	\end{itemize}
 % 
 % \subsection{hungarian}\label{hungarian}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{swapstrings} = \textit{all}, captions, headings, headers, hheaders or none\new{v1.46}
-% 	      
+% 	\item \xpgchoicekey[1.46]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
+% 	\xpgvalue{captions}, \xpgvalue{headings}, \xpgvalue{headers}, \xpgvalue{hheaders}, or \xpgvalue{none}}
 % 	       In Hungarian, some caption strings need to be in a different order than in other languages
 % 	       (\eg \emph{1. fejezet} instead of \emph{Chapter 1}). By default, \pkg{polyglossia} tries hard to
 % 	       provide the correct order for different classes and packages (standard classes, \pkg{KOMA-script},
@@ -1151,7 +1571,7 @@
 % \subsection{italian}\label{italian}
 % \paragraph*{Options:}
 % \begin{itemize}
-%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.2.0cc}% TODO: check version
+%   \item \xpgboolkeyfalse[1.2.0cc]{babelshorthands}% TODO: check version
 %   Activates the ¦"¦ character as a switch to perform etymological
 %   hyphenation when followed by a letter. Furthermore, the following shorthands are activated:
 %   \begin{shorthands}
@@ -1158,34 +1578,59 @@
 %   	\item[¦""¦] double raised open quotes (the Italian keyboard misses the backtick).
 %   	\item[¦"<¦] open guillemet (looks like <<).
 %   	\item[¦">¦] closing guillemet (looks like >>).
-%   	\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to ¦\slash¦,
+%   	\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[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-%                in the hyphenation patterns (as opposed to ¦\-¦).
+%                in the hyphenation patterns (as opposed to \cmd\-).
 %   \end{shorthands}
 % \end{itemize}
 % 
-% \subsection[korean]{korean\new{v1.40.0}}\label{korean}
+% \subsection[korean]{korean\new{1.40.0}}\label{korean}
 % \paragraph*{Options:}
 %   \begin{itemize}
-%   \item \TB{variant} = \textit{plain}, classic or modern:
-%     for spacing before/after CJK punctuations.
-%     `classic' is suitable for text with no interword spaces,
-%     `modern' for text with interword spaces.
-%   \item \TB{captions} = \textit{hangul} or hanja
+% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{plain}, \xpgvalue{classic}, or \xpgvalue{modern}}
+%     These variants control spacing before/after CJK punctuations.
+%       \begin{itemize}
+%         \item ¦plain¦: Do nothing
+%         \item ¦classic¦: Suitable for text with no interword spaces.
+%           This option forces CJK punctuations to half-width, and
+%           inserts half-width glue around them.
+%         \item ¦modern¦: Suitable for text with interword spaces.
+%           This option forces CJK punctuations to half-width, and
+%           inserts small (half of interword space) glue around them.
+%       \end{itemize}
+% 	\item \xpgchoicekey{captions}{\xpgpresetvalue{hangul} or \xpgvalue{hanja}}
+% 	\item \xpgchoicekey[1.47]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
+% 	\xpgvalue{headers}, \xpgvalue{headings}, or \xpgvalue{none}}
+%     With this option, Korean-style part and chapter headings, and
+%     running headers are available.
+%     It is similar to Hungarian (see \ref{hungarian}) except that
+%     figure and table captions are not touched.
+%       \begin{itemize}
+%         \item ¦all¦: Redefine part and chapter headings, and running headers
+%           (=~default setting)
+%         \item ¦headings¦: Redefine part and chapter headings only
+%         \item ¦headers¦: Redefine running headers only
+%         \item ¦none¦: Do not redefine anything
+%       \end{itemize}
 %   \end{itemize}
 % 
-% \subsection[kurdish]{kurdish\new{v1.45}}\label{kurdish}
+% \subsection[kurdish]{kurdish\new{1.45}}\label{kurdish}
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant} = kurmanji or \textit{sorani}
-% 	\item \TB{script} = Arabic or Latin. Defaults are ¦Arabic¦ for Sorani and ¦Latin¦ for Kurmanji.
-% 	\item \TB{numerals} = western or eastern. Defaults are ¦western¦ for Latin and ¦eastern¦ for Arabic script, depending on the selection above.
-% 	\item \TB{abjadjimnotail} = \textit{false} or true.
-% 	Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
-% ^^A	\item \TB{locale} (not yet implemented)
-% ^^A	\item \TB{calendar} (not yet implemented)
+% 	\item \xpgchoicekey{variant}{\xpgvalue{kurmanji} or \xpgpresetvalue{sorani}}
+% 	\item \xpgchoicekey{script}{\xpgvalue{Arabic} or \xpgvalue{Latin}}
+% 		Defaults are \xpgvalue{Arabic} for Sorani and \xpgvalue{Latin} for Kurmanji.
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgvalue{eastern}}
+% 		Defaults are \xpgvalue{western} for Latin and \xpgvalue{eastern} for Arabic script, depending
+% 		on the selection above.
+% 	\item \xpgboolkeyfalse{abjadjimnotail}
+% 		Set this to true if you want the \textit{abjad} form of the number three to
+% 		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
+% 		modern usage \textarabic{ج}.
+% ^^A	\item \xpgchoicekey{locale}{} (not yet implemented)
+% ^^A	\item \xpgchoicekey{calendar}{} (not yet implemented)
 % \end{itemize}
 % \condbreak{2\baselineskip}
 % \paragraph*{Commands:}
@@ -1196,19 +1641,18 @@
 % 	\item \Cmd\aemph (see section \ref{arabic})
 % \end{itemize}
 % 
-% \subsection[lao]{lao\new{v1.2.0}}\label{lao}
+% \subsection[lao]{lao\new{1.2.0}}\label{lao}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{numerals} = lao or \textit{arabic}
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{lao} or \xpgpresetvalue{arabic}}
 % 	\end{itemize}
 % 
 % \subsection{latin}\label{latin}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant} = classic, medieval, \emph{modern}, or ecclesiastic\new{v.1.46}
-% 
-% 			These variants refer to different spelling conventions. The ¦classic¦
-% 			and the ¦medieval¦ variant do not use the letters \emph{U} and
+% 	\item \xpgchoicekey{variant}{\xpgvalue{classic}, \xpgvalue{medieval}, \xpgpresetvalue{modern}, or \xpgvalue{ecclesiastic}\new{1.46}}
+% 			These variants refer to different spelling conventions. The \xpgvalue{classic}
+% 			and the \xpgvalue{medieval} variant do not use the letters \emph{U} and
 % 			\emph{v}, but only \emph{V} and \emph{u}. This concerns predefined terms like
 % 			month names as well as the behaviour of the \cmd\MakeUppercase\ and the
 % 			\cmd\MakeLowercase\ command. The ¦medieval¦ and the
@@ -1215,7 +1659,7 @@
 % 			¦ecclesiastic¦ variant use the ligatures \emph{\ae} and \emph{\oe}.
 % 			See table \ref{tab:latin-spelling} for examples.
 % 
-% 			Furthermore, the \texttt{ecclesiastic} variant takes care for a punctuation
+% 			Furthermore, the \xpgvalue{ecclesiastic} variant takes care for a punctuation
 % 			spacing similar to French, but with smaller spaces, as provided for
 % 			PDF\TeX\ by the \pkg{ecclesiastic} package.
 % 			\begin{table}
@@ -1222,8 +1666,8 @@
 % 			\centering
 % 			\caption{\label{tab:latin-spelling}Spelling differences between the Latin
 % 				language variants.\newline The capitalization of month names and the use of
-% 				\emph{i/j} may be affected by the \texttt{capitalizemonth} and the
-% 				\texttt{usej} option.}
+% 				\emph{i/j} may be affected by the \xpgvalue{capitalizemonth} and the
+% 				\xpgvalue{usej} option.}
 % 			\begin{tabular}{llll}
 % 			\toprule
 % 			\textbf{classic} & \textbf{medieval} & \textbf{modern} & \textbf{ecclesiastic} \\
@@ -1236,8 +1680,7 @@
 % 			\bottomrule
 % 			\end{tabular}
 % 			\end{table}
-% 	\item \TB{hyphenation}\new{v.1.46} = classic, modern, or liturgical
-% 
+% 	\item \xpgchoicekey[1.46]{hyphenation}{\xpgvalue{classic}, \xpgvalue{modern}, or \xpgvalue{liturgical}}
 % 			There are three different sets of hyphenation patterns for Latin. Separate
 % 			documention for them is available on the
 % 			Internet.\footnote{\url{https://github.com/gregorio-project/hyphen-la/blob/master/doc/README.md\#hyphenation-styles}}
@@ -1246,7 +1689,7 @@
 % 			¦hyphenation¦ option if the default style does not fit your needs.
 % 			Note that the liturgical hyphenation patterns are the default of none of the
 % 			language variants. To use them, you have to say
-% 			¦hyphenation=liturgical¦ in any case.
+% 			\xpgvalue{hyphenation=liturgical} in any case.
 % 			\begin{table}
 % 			\caption{\label{tab:latin-hyphenation}Latin default hyphenation styles}
 % 			\centering
@@ -1261,8 +1704,7 @@
 % 			\bottomrule
 % 			\end{tabular}
 % 			\end{table}
-% 	\item \TB{ecclesiasticfootnotes}\new{v.1.46} = true or \emph{false}
-% 
+% 	\item \xpgboolkeyfalse[1.46]{ecclesiasticfootnotes}
 % 			Use footnotes as provided by the \pkg{ecclesiastic} package, which typesets
 % 			footnotes with ordinary instead of superior numbers and without indentation.
 % 			As many ecclesiastic documents and liturgical books use footnotes that are
@@ -1271,8 +1713,7 @@
 % 		
 % 			Note that this option is only possible if Latin is the main language of your
 % 			document.
-% 	\item \TB{usej}\new{v.1.46} = true or \emph{false}
-% 
+% 	\item \xpgboolkeyfalse[1.46]{usej}
 % 			Use \emph{J/j} in predefined terms. The letter \emph{j} is not of ancient
 % 			origin. In early modern times, it was used to distinguish the consonantic
 % 			\emph{i} from the vocalic~\emph{i}. Nowadays, the use of \emph{j} has
@@ -1279,8 +1720,7 @@
 % 			disappeared from most Latin publications. So ¦false¦ is the default
 % 			value for all four language variants. Use this option if you prefer
 % 			\emph{Januarii} and \emph{Maji} to \emph{Ianuarii} and \emph{Maii}.
-% 			\item \TB{capitalizemonth}\new{v.1.46} = true or false
-% 		
+% 	\item \xpgboolkey[1.46]{capitalizemonth}
 % 			Capitalize the month name when printing dates (using the \cmd\today\
 % 			command).  Traditionally, month names are capitalized. However, in recent
 % 			liturgical books they are lowercase. So ¦true¦ is the default value for
@@ -1287,8 +1727,7 @@
 % 			the variants ¦classic¦, ¦medieval¦, and ¦modern¦,
 % 			whereas ¦false¦ is the default value for the ¦ecclesiastic¦
 % 			variant.
-% 	\item \TB{babelshorthands} = true or \emph{false}
-% 
+% 	\item \xpgboolkeyfalse{babelshorthands}
 % 			Enable the following shorthands inherited from \pkg{babel-latin} and the
 % 			\pkg{ecclesiastic} package.
 % 			\begin{shorthands}
@@ -1314,14 +1753,12 @@
 % 				\item[¦'Ae¦] for Ǽ (AE ligature with acute), also available for \'Œ
 % 				\item[¦'AE¦] for Ǽ (AE ligature with acute), also available for \'Œ
 % 			\end{shorthands}
-% 	\item \TB{prosodicshorthands}\new{v.1.46} = true or \emph{false}
-% 
+% 	\item \xpgboolkeyfalse[1.46]{prosodicshorthands}
 % 			Enable shorthands for prosodic marks (macrons and breves) very similiar to
 % 			those provided by \pkg{babel-latin} using the ¦withprosodicmarks¦
 % 			modifier.
-% 		
 % 			Note that the active ¦=¦ character used for macrons will cause problems with
-% 			commands using \texttt{key=value} interfaces, \eg
+% 			commands using \texttt{key=value} interfaces, such as the command
 % 			¦\includegraphics[scale=2]{...}¦. Use \cmd{\shorthandoff\{=\}} before
 % 			such commands (and \cmd{\shorthandon\{=\}} thereafter) within every
 % 			environment with prosodic shorthands enabled.
@@ -1354,20 +1791,25 @@
 % \subsection{malay}\label{malay}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant}\new{v1.45} = \textit{indonesian} (=~bahasai in \pkg{babel}) or
-% 	malaysian (=~bahasam in \pkg{babel})
+% 	\item \xpgchoicekey[1.45]{variant}{\xpgpresetvalue{indonesian} or \xpgvalue{malaysian}}
 % \end{itemize}
 % 
-% \subsection[mongolian]{mongolian\new{v1.45}}\label{mongolian}
+% \subsection{marathi}\label{marathi}
+% \paragraph*{Options:}
+% \begin{itemize}
+% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{Devanagari} or \xpgvalue{Western}}
+% \end{itemize}
+% 
+% \subsection[mongolian]{mongolian\new{1.45}}\label{mongolian}
 % Currently, only the Khalkha variety in Cyrillic script is supported.
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true.
+% 	\item \xpgboolkeyfalse{babelshorthands}
 % 	If this is turned on, the following shorthands are activated:
 % 	\begin{shorthands}
 %         \item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		           in the hyphenation patterns (as opposed to ¦\-¦).
+% 		           in the hyphenation patterns (as opposed to \cmd\-).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 % 		           cases where the hyphen should stick at the following syllable.
 % 		\item[¦"|¦] disables a ligature at this position.
@@ -1381,32 +1823,44 @@
 % 		\item[¦"<¦] for French left double quotes (looks like <<).
 % 		\item[¦">¦] for French right double quotes (looks like >>).
 % 	\end{shorthands}
-% 	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-% 	alphanumerical numbering.
+% 	\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}
+% 	           \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+% 	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+% 	                 \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+% 	                 It supports numbers up to 999\,999.
+%           \end{itemize}
 % \end{itemize}
 % ^^A
 % \paragraph*{Commands:}
 % \begin{itemize}
-% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-% 	environments such as ¦enumerate¦. The command takes a counter as argument,
-% 	\eg ¦\textmongolian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-% 	\item \Cmd\asbuk: same in lowercase
+%     \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+%           The command takes a counter as argument, \eg ¦\textmongolian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+%     \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+%     \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+%           numbers up to 999\,999.\\
+%           \Eg ¦\textmongolian{\AsbukTrad{section}}¦ produces \textrussian{\AsbukTrad{section}}.
+%     \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 % \end{itemize}
 % 
 % \subsection{norwegian}\label{norwegian}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant}\new{v1.45} = bokmal (=~`norsk' in \pkg{babel}) or \textit{nynorsk}
+% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{bokmal} or \xpgpresetvalue{nynorsk}}
 % \end{itemize}
 % 
 % \subsection{persian}\label{persian}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{numerals} = western or \textit{eastern}
-% 	\item \TB{abjadjimnotail} = \textit{false} or true. \new{v1.0.3}
-% 	Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript tradition – instead of the modern usage \textarabic{ج}.
-% ^^A	\item \TB{locale} (not yet implemented)
-% ^^A	\item \TB{calendar} (not yet implemented)
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{eastern}}
+% 	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
+% 		Set this to \xpgvalue{true} if you want the \textit{abjad} form of the number three to
+% 		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
+% 		modern usage \textarabic{ج}.
+% ^^A	\item \xpgchoicekey{locale}{} (not yet implemented)
+% ^^A	\item \xpgchoicekey{calendar}{} (not yet implemented)
 % \end{itemize}
 % \paragraph*{Commands:}
 % \begin{itemize}
@@ -1417,17 +1871,17 @@
 % \subsection{portuguese}\label{portuguese}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant}\new{v1.45} = brazilian or \textit{portuguese}
+% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
 % \end{itemize}
 % 
 % \subsection{russian}\label{russian}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true.
+% 	\item \xpgboolkeyfalse{babelshorthands}
 % 	If this is turned on, the following shorthands are activated:
 % 	\begin{shorthands}
 % 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
-% 		           in the hyphenation patterns (as opposed to ¦\-¦).
+% 		           in the hyphenation patterns (as opposed to \cmd\-).
 % 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
 % 		           cases where the hyphen should stick at the following syllable.
 % 		\item[¦"|¦] disables a ligature at this position.
@@ -1442,48 +1896,72 @@
 % ^^A		\item[¦"<¦] for French left double quotes (looks like <<).
 % ^^A		\item[¦">¦] for French right double quotes (looks like >>).
 % 	\end{shorthands}
-%     \item \TB{indentfirst}\new{v1.46} = \textit{true} or false. By default, all paragraphs are indented in Russian,
-%           also those after a chapter or section heading. If this option is false, the latter paragraphs
-%           are not indented, as normal in \LaTeX. 
-% 	\item \TB{spelling} = \textit{modern} or old (for captions and date only, not for hyphenation)
-% 	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-% 	alphanumerical numbering.
+% 	\item \xpgboolkeytrue[1.46]{indentfirst}
+% 		By default, all paragraphs are indented in Russian, also those after a
+% 		chapter or section heading. If this option is false, the latter paragraphs
+% 		are not indented, as normal in \LaTeX.
+% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{old}}
+% 		This option is for captions and date only, not for hyphenation.
+% 	\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}
+% 			\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+% 			\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+% 			      \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+% 			      It supports numbers up to 999\,999.
+% 		\end{itemize}
 % 	\end{itemize}
 % ^^A
 % \paragraph*{Commands:}
 % 	\begin{itemize}
-% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-% 	environments such as ¦enumerate¦. The command takes a counter as argument,
-% 	\eg ¦\textrussian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
-% 	\item \Cmd\asbuk: same in lowercase
+% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+% 	      It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+% 	      The command takes a counter as argument, \eg ¦\textrussian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+% 	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+% 	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+% 	      numbers up to 999\,999.\\
+% 	      \Eg ¦\textrussian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+% 	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 % 	\end{itemize}
 % 
-% \subsection[sami]{sami\new{v1.45}}\label{sami}
+% \subsection[sami]{sami\new{1.45}}\label{sami}
 % Currently support for Sami is limited to Northern Sami.
 % 
 % \subsection{sanskrit}\label{sanskrit}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{script} = \textit{Devanagari}\new{v1.0.2}, Gujarati, Malayalam, Bengali, Kannada,
-% 	Telugu or Latin.
-% 	The value is passed to \pkg{fontspec} in cases where the respective ¦\⟨script⟩font¦ is not defined.
-% 	This can be useful if you typeset Sanskrit texts in scripts other than Devanagari.
-% 	\item \TB{numerals} = \textit{Devanagari}\new{v1.45} or Western
+% 	\item \xpgchoicekey[1.0.2]{script}{\xpgpresetvalue{Devanagari}, \xpgvalue{Gujarati},
+% 	\xpgvalue{Malayalam}, \xpgvalue{Bengali}, \xpgvalue{Kannada}, \xpgvalue{Telugu}, or \xpgvalue{Latin}}
+% 		The value is passed to \pkg{fontspec} in cases where the respective
+% 		\cmd{\⟨script⟩font} is not defined.  This can be useful if you typeset Sanskrit
+% 		texts in scripts other than Devanagari.
+% 	\item \xpgchoicekey[1.45]{numerals}{\xpgpresetvalue{Devanagari} or \xpgvalue{Western}}
 % 	\end{itemize}
-%  
+% 
 % \subsection{serbian}\label{serbian}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{script} = \textit{Cyrillic} or Latin.
-% 	\item \TB{numerals} = \textit{arabic} or cyrillic. Uses either Arabic numerals or Cyrillic
-% 	      alphanumerical numbering.
-% 	\end{itemize}
+% 	\item \xpgchoicekey{script}{\xpgpresetvalue{Cyrillic} or \xpgvalue{Latin}}
+% 	\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}
+%                \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+% 	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+% 	                  \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+% 	                  It supports numbers up to 999\,999.
+%           \end{itemize}
+% \end{itemize}
+% ^^A
 % \paragraph*{Commands:}
 % \begin{itemize}
-% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for
-% 	environments such as ¦enumerate¦. The command takes a counter as argument,\\
-% 	Example: ¦\textserbian[numerals=cyrillic]{\Asbuk{page}}¦ produces \textserbian[numerals=cyrillic]{\Asbuk{page}}.
-% 	\item \Cmd\asbuk: same in lowercase
+%     \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+%           The command takes a counter as argument, \eg ¦\textserbian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+%     \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+%     \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+%           numbers up to 999\,999.\\
+%           \Eg ¦\textserbian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+%     \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
 % \end{itemize}
 % 
 % 
@@ -1491,9 +1969,9 @@
 % 
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{babelshorthands} = \textit{false} or true. \new{v1.46}
-% 	if this is turned on, the following shorthands for Slovak are activated:
-% 	\begin{shorthands}
+% 	\item \xpgboolkeyfalse[1.46]{babelshorthands}
+% 		If this is turned on, the following shorthands for Slovak are activated:
+% 		\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¦).
@@ -1501,16 +1979,16 @@
 %         \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 ¦\-¦).
+%                     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 ¦\slash¦, hyphenation at the breakpoints
+%         \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 Slovak left double quotes (looks like ,,).
 %         \item[¦"’¦] for Slovak right double quotes (looks like “).
 %         \item[¦">¦] for Slovak left double guillemets (looks like >>).
 %         \item[¦"<¦] for Slovak right double guillemets (looks like <<).
-% 	\end{shorthands}
-% 	\item \TB{splithyphens} = \textit{false} or true. \new{v1.46}
+% 		\end{shorthands}
+% 	\item \xpgboolkeytrue[1.46]{splithyphens}
 % 	      According to Slovak 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}).
@@ -1517,7 +1995,7 @@
 % 	      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 \TB{vlna} = \textit{false} or true. \new{v1.46}
+% 	\item \xpgboolkeytrue[1.46]{vlna}
 % 	      According to Slovak typesetting conventions, single-letter words (non-syllable prepositions)
 % 	      must not occur at line ends.
 % 	      \pkg{Polyglossia} takes care of this automatically by default (if you are using \LuaTeX, the
@@ -1528,26 +2006,31 @@
 % \subsection{slovenian}\label{slovenian}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{localalph} = true or \textit{false}
+% 	\item \xpgboolkeyfalse{localalph}
+% 	      If \xpgvalue{true}, alpha-numeric counters will use a localized version including characters with caron
+% 	      (a, b, c, č, d, \ldots).
 % 	\end{itemize}
 % 
 % \subsection{sorbian}\label{sorbian}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant}\new{v1.45} = lower or \textit{upper}
-% 	\item \TB{olddate}\new{v1.45} = true or \textit{false} (default value = true). If true, ¦\today¦
-% 	      will use traditional Sorbian month names (\ie it will be synonymous to ¦\oldtoday¦ below)
+% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{lower} or \xpgpresetvalue{upper}}
+% 	\item \xpgboolkeyfalse[1.45]{olddate}
+% 		If \xpgvalue{true}, \cmd\today\ will use traditional Sorbian month names (\ie it will be
+% 		synonymous to \cmd\oldtoday\ below).
 % \end{itemize}
 % \paragraph*{Commands:}
 % \begin{itemize}
-% 	\item \Cmd\oldtoday: outputs the current date using traditional Sorbian month names, even if \TB{olddate} is false.
+% 	\item \Cmd\oldtoday: outputs the current date using traditional Sorbian month names, even if
+% 	       \xpgvalue{olddate} is \xpgvalue{false}.
 % \end{itemize}
 % 
 % \subsection{spanish}\label{spanish}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{variant} = \textit{spanish} or mexican.\new{v1.46}
-% 	\item \TB{spanishoperators} = all, accented, spaced or none or \textit{false} (default value = all).\new{v1.46}
+% 	\item \xpgchoicekey[1.46]{variant}{\xpgpresetvalue{spanish} or \xpgvalue{mexican}}
+% 	\item \xpgchoicekey[1.46]{spanishoperators}{\xpgdefaultvalue{all}, \xpgvalue{accented},
+% 	\xpgvalue{spaced}, \xpgvalue{none}, or \xpgpresetvalue{false}}
 % 	      Determines of and how math operators are localized to Spanish.
 % 	      \begin{itemize}
 % 	      	\item ¦accented¦ causes some math operators to use accents where usual in Spanish (\emph{lím},
@@ -1555,20 +2038,20 @@
 % 	      	\item ¦spaced¦ causes some math operators to use spaces where usual in Spanish (\emph{arc\,cos},
 % 	      	      \emph{arc\,sen}, \emph{arc\,tg}).
 % 	      	\item ¦all¦ activates ¦accented¦ and ¦spaced¦ and furthermore provides Spanish localizations of
-% 	      	      ¦\sin¦ (\emph{sen}), ¦\tan¦ (\emph{tg}), ¦\sinh¦ (\emph{senh}), and ¦\tanh¦ (\emph{tgh}).
-% 	      	\item ¦none¦ does no localization at all (default setting). 
+% 	      	      \cmd\sin\ (\emph{sen}), \cmd\tan\ (\emph{tg}), \cmd\sinh\ (\emph{senh}), and \cmd\tanh\ (\emph{tgh}).
+% 	      	\item ¦none¦ does no localization at all (default setting).
 % 	      \end{itemize}
 % \end{itemize}
-% \paragraph*{\color{black}Commands:}\new{v1.46}
+% \paragraph*{\color{black}Commands:}\new{1.46}
 % \begin{itemize}
-% 	\item \Cmd\arcsen: alias to ¦\arcsin¦ (\pkg{babel} compatibility)
-% 	\item \Cmd\arctg: alias to ¦\arctan¦ (\pkg{babel} compatibility)
-% 	\item \Cmd\sen: alias to ¦\sin¦ (\pkg{babel} compatibility)
-% 	\item \Cmd\senh: alias to ¦\sinh¦ (\pkg{babel} compatibility)
-% 	\item \Cmd\tg: alias to ¦\tan¦ (\pkg{babel} compatibility)
-% 	\item \Cmd\tgh: alias to ¦\tanh¦ (\pkg{babel} compatibility)
+% 	\item \Cmd\arcsen: alias to \cmd\arcsin\ (\pkg{babel} compatibility)
+% 	\item \Cmd\arctg: alias to \cmd\arctan\ (\pkg{babel} compatibility)
+% 	\item \Cmd\sen: alias to \cmd\sin\ (\pkg{babel} compatibility)
+% 	\item \Cmd\senh: alias to \cmd\sinh\ (\pkg{babel} compatibility)
+% 	\item \Cmd\tg: alias to \cmd\tan\ (\pkg{babel} compatibility)
+% 	\item \Cmd\tgh: alias to \cmd\tanh\ (\pkg{babel} compatibility)
 % 	\item \Cmd\spanishoperator: allows you to define further localized operators. For instance, ¦\spanishoperator{cotg}¦
-% 	      defines a command ¦\cotg¦ that outputs \emph{cotg} in math. The optional argument of the command lets you specify the
+% 	      defines a command \cmd\cotg\ that outputs \emph{cotg} in math. The optional argument of the command lets you specify the
 % 	      spelling, if needed, \eg ¦\spanishoperator[arc\,ctg]{arcctg}¦.
 % \end{itemize}
 % 
@@ -1575,9 +2058,9 @@
 % \subsection{syriac}\label{syriac}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{numerals} = \textit{western} (i.e., 1234567890), eastern
-% 		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}),
-% 		or abjad. \new{v1.0.1}.
+% 	\item \xpgchoicekey[1.0.1]{numerals}{\xpgpresetvalue{western} (\ie 1234567890), \xpgvalue{eastern}
+% 		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}), or
+% 		\xpgvalue{abjad}}
 % 	\end{itemize}
 % \paragraph*{Commands:}
 % 	\begin{itemize}
@@ -1588,7 +2071,7 @@
 % \subsection{thai}\label{thai}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{numerals} = thai or \textit{arabic}
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{thai} or \xpgpresetvalue{arabic}}
 % 	\end{itemize}
 % ^^A
 % To insert word breaks, you need to use an external processor.
@@ -1598,21 +2081,58 @@
 % \subsection{tibetan}\label{tibetan}
 % \paragraph*{Options:}
 % \begin{itemize}
-% 	\item \TB{numerals} = tibetan or \textit{arabic}
+% 	\item \xpgchoicekey{numerals}{\xpgvalue{tibetan} or \xpgpresetvalue{arabic}}
 % \end{itemize}
 % 
 % \subsection{ukrainian}\label{ukrainian}
-% \paragraph*{Commands:}
+% 
+% \paragraph*{Options:}
+% \begin{itemize}
+% 	\item \xpgboolkeyfalse{babelshorthands}
+% 	If this is turned on, the following shorthands are activated:
+% 	\begin{shorthands}
+% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
+% 		in the hyphenation patterns (as opposed to \cmd\-).
+% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
+% 		cases where the hyphen should stick at the following syllable.
+% 		\item[¦"|¦] disables a ligature at this position.
+% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
+% 		\item[¦"---¦] Cyrillic emdash in plain text.
+% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
+% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
+% ^^A These are commented out in gloss-ukrainian
+% ^^A		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
+% ^^A		\item[¦"‘¦] for German left double quotes (looks like ,,).
+% ^^A		\item[¦"’¦] for German right double quotes (looks like “).
+% ^^A		\item[¦"<¦] for French left double quotes (looks like <<).
+% ^^A		\item[¦">¦] for French right double quotes (looks like >>).
+% 	\end{shorthands}
+% 	\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}
-% 	\item \Cmd\Asbuk: produces the uppercase Ukrainian alphabet, for
-% 	environments such as ¦enumerate¦
-% 	\item \Cmd\asbuk: same in lowercase
+% 		\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
+% 		\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
+% 		\footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
+% 		It supports numbers up to 999\,999.
 % 	\end{itemize}
+% \end{itemize}
+% ^^A
+% \paragraph*{Commands:}
+% \begin{itemize}
+% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
+% 	It steps through the Cyrillic alphabet and thus it can only be used up to 30.
+% 	The command takes a counter as argument, \eg ¦\textukrainian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
+% 	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
+% 	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
+% 	numbers up to 999\,999.\\
+% 	\Eg ¦\textukrainian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
+% 	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
+% \end{itemize}
 % 
 % \subsection{welsh}\label{welsh}
 % \paragraph*{Options:}
 % 	\begin{itemize}
-% 	\item \TB{date} = long or \textit{short}
+% 	\item \xpgchoicekey{date}{\xpgvalue{long} or \xpgpresetvalue{short}}
 % 	\end{itemize}
 % 
 % 
@@ -1620,24 +2140,24 @@
 % 
 % \pkg{Polyglossia} uses the following macros to define language-specific captions
 % (\ie strings such as ``chapter''), date formats and additional language settings
-% (¦⟨lang⟩¦ is to be replaces with the respective language name):
+% (\meta{lang} is to be replaces with the respective language name):
 % 
 % \begin{itemize}
-% 	\item \Cmd{\captions⟨lang⟩} stores definitions of caption strings
+% 	\item \Cmd{\captions\meta{lang}} stores definitions of caption strings
 % 	           (such as, in the case of English, ¦\def\chaptername{Chapter}¦)
-% 	\item \Cmd{\date⟨lang⟩} stores definitions of date formats (usually redefinitions
-% 	           of ¦\today¦, in some cases also definitions of additional date commands)
-% 	\item \Cmd{\blockextras⟨lang⟩} stores macros that are to be executed when the language
-%               ⟨lang⟩ is activated via ¦\selectlanguage¦ command or the ¦⟨lang⟩¦ environment
-% 	\item \Cmd{\inlineextras⟨lang⟩} stores macros that are to be executed when the language
-% 	          ⟨lang⟩ is activated locally via ¦\text⟨lang⟩¦ command
-% 	\item \Cmd{\noextras⟨lang⟩} stores macros that are to be executed when the language
-% 	          ¦⟨lang⟩¦ is closed 
-% \end{itemize} 
+% 	\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
+%               \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
+% 	          \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
+% 	          \meta{lang} is closed
+% \end{itemize}
 % ^^A
-% In order to redefine internal macros, we recommend to use the command ¦\gappto¦.
-% For compatibility with \pkg{babel} the command ¦\addto¦ is also available
-% to the same effect. For instance, to change the ¦\chaptername¦ for language ¦lingua¦,
+% In order to redefine internal macros, we recommend to use the command \cmd\gappto.
+% For compatibility with \pkg{babel} the command \cmd\addto\ is also available
+% to the same effect. For instance, to change the \cmd\chaptername\ for language ¦lingua¦,
 % you can do this:
 % \begin{verbatim}
 % \gappto\captionslingua{\def\chaptername{Caput}}
@@ -1644,7 +2164,7 @@
 % \end{verbatim}
 % ^^A
 % Note that this needs to be done after the respective language has been loaded with
-% ¦\setmainlanguage¦ or ¦\setotherlanguage¦.
+% \cmd\setmainlanguage\ or \cmd\setotherlanguage.
 % 
 % Specifically for package authors, analogous commands are provided which are only executed
 % if a specific language \emph{variety} is used. As opposed to the macros above, these refer
@@ -1651,17 +2171,17 @@
 % to babel names. Other than that, the function is identical:
 % 
 % \begin{itemize}
-% 	\item \Cmd{\captions at bbl@⟨babelname⟩} 
-% 	\item \Cmd{\date at bbl@⟨babelname⟩}
-% 	\item \Cmd{\blockextras at bbl@⟨babelname⟩}
-% 	\item \Cmd{\inlineextras at bbl@⟨babelname⟩}
-% 	\item \Cmd{\noextras at bbl@⟨babelname⟩} 
+% 	\item \Cmd{\captions at bbl@\meta{babelname}}
+% 	\item \Cmd{\date at bbl@\meta{babelname}}
+% 	\item \Cmd{\blockextras at bbl@\meta{babelname}}
+% 	\item \Cmd{\inlineextras at bbl@\meta{babelname}}
+% 	\item \Cmd{\noextras at bbl@\meta{babelname}}
 % \end{itemize}
 % ^^A
 % By default, these macros are undefined. If they are defined (\eg by an external package),
-% they will be executed after their respective ¦⟨lang⟩¦ counterpart and thus can be used to
-% overwrite definitions of the former. Again, use ¦\gappto¦ to define\slash modify these macros.
-% For instance, to add a new caption ¦\footnotename¦ to the Swiss variety of German (babel name
+% they will be executed after their respective \meta{lang} counterpart and thus can be used to
+% overwrite definitions of the former. Again, use \cmd\gappto\ to define\slash modify these macros.
+% For instance, to add a new caption \cmd\footnotename\ to the Swiss variety of German (babel name
 % ¦nswissgerman¦), you can do this:
 % \begin{verbatim}
 % \gappto\captions at bbl@nswissgerman{\def\footnotename{Fussnote}}
@@ -1668,7 +2188,7 @@
 % \end{verbatim}
 % ^^A
 % If you do this in a document preamble rather than in a package, you need to embrace the redefinition
-% by ¦\makeatletter¦ and ¦\makeatother¦ due to the ¦@¦ in the macro names.
+% by \cmd\makeatletter\ and \cmd\makeatother\ due to the ¦@¦ in the macro names.
 % 
 % \section{Script-specific numbering}
 % 
@@ -1694,25 +2214,27 @@
 % ¦\localnumeral{42}¦ yields \textarabic{\localnumeral{42}}, whereas in an Hebrew environment, it
 % results in \texthebrew[numerals=hebrew]{\localnumeral{42}} with ¦numerals=hebrew¦, and \texthebrew{\localnumeral{42}}
 % with ¦numerals=arabic¦. Note that, as opposed to the various ¦digits¦ macros (described in sec.~\ref{sec:decdigit}),
-% the argument of ¦\localnumeral¦ must consist of numbers only.
+% the argument of \cmd\localnumeral\ must consist of numbers only.
 % 
 % For\new{1.45} the conversion of counters, the starred version \Cmd{\localnumeral*} is provided. This takes a counter as argument.
 % For instance in an Arabic environment ¦\localnumeral*{page}¦ yields \textarabic{\localnumeral*{page}}.
 % 
-% For scripts with alphanumeric numbering, the variants \Cmd{\Localnumeral} and \Cmd{\Localnumeral*} provide the uppercased 
+% For scripts with alphanumeric numbering, the variants \Cmd{\Localnumeral} and \Cmd{\Localnumeral*} provide the uppercased
 % versions.\medskip
 % 
 % \noindent All these macros provide the following options:
 % 
 % \begin{itemize}
-% 	\item \TB{lang} =\DescribeMacro{[lang=]}\ \textit{local}, main, or <language>.\\
-% 	Output number in the local form of the currently active language for ¦local¦, the main language of the document for ¦main¦,
-%     and any (loaded) language for ¦<language>¦ (\eg ¦\localnumeral[lang=arabic]{42}}¦).
+% 	\item \DescribeMacro{[lang=]}\xpgchoicekey{lang}{\xpgpresetvalue{local}, \xpgvalue{main},
+% 	or \xpgvalue{\meta{language}}}
+% 		Output number in the local form of the currently active language for
+% 		¦local¦, the main language of the document for ¦main¦, and any (loaded)
+% 		language for \meta{language} (\eg ¦\localnumeral[lang=arabic]{42}}¦).
 % \end{itemize}
 % 
 % \subsection{Non-Western decimal digits}\label{sec:decdigit}
 % 
-% In addition\new{v1.1.1} to the generic macros described above, \pkg{polyglossia} provides language-specific conversion macros
+% In addition\new{1.1.1} to the generic macros described above, \pkg{polyglossia} provides language-specific conversion macros
 % which can be used if the generic ones do not suit the need.\footnote{%
 % A third method are so-called TECKit fontmappings.
 % Those can be activated with the \pkg{fontspec} ¦Mapping¦ option,
@@ -1721,7 +2243,7 @@
 % typing \cmd{\textarabic\{2010\}} results in \textarabic{٢٠١٠}. Note that this method has some drawbacks, though,
 % for instance when the value of a counter has to be written and read from auxiliary files.
 % So please use this with care.}
-% The macros have the form ¦\<script>digits¦. They convert Arabic numerical input and leave every other input untouched.
+% The macros have the form \cmd{\⟨script⟩digits}. They convert Arabic numerical input and leave every other input untouched.
 % In an Arabic context, for instance, ¦\arabicdigits{9182/738543-X}¦ yields \textarabic{\arabicdigits{9182/738543-X}}.
 % 
 % Currently, the following macros are provided:
@@ -1748,9 +2270,9 @@
 % 	\url{http://en.wikipedia.org/wiki/Hebrew_numerals},
 % 	and \url{http://en.wikipedia.org/wiki/Syriac_alphabet}.}, dedicated macros are provided.
 % 
-% They work in a similar way than the ¦\<script>digits¦ macros described above: They take Arabic numerical input
+% They work in a similar way than the \cmd{\⟨script⟩digits} macros described above: They take Arabic numerical input
 % and output the respective value in the local alphabetic numbering scheme (most of these macros are equivalent
-% to ¦\localnumeral¦ and ¦\Localnumeral¦ in the respective context).
+% to \cmd\localnumeral\ and \cmd\Localnumeral\ in the respective context).
 % 
 % The following macros are provided:
 % 
@@ -1767,6 +2289,13 @@
 % 	
 % 	\item \Cmd\armeniannumeral produces Armenian alphabetic numbering.
 % 	          Example: ¦\armeniannumeral{1863}¦ yields \textarmenian{\armeniannumeral{1863}}.
+% 	          
+% 	\item \Cmd\belarusiannumeral produces Belarusian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Belarusiannumeral.
+% 	          Depending on the ¦numerals¦ option in the Belarusian language selection, this is either Arabic digit or Cyrillic
+% 	          alphanumercial output.\\
+% 	          Example: With ¦numerals=latin¦ ¦\belarusiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+% 	          with ¦numerals=cyrillic-trad¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+% 	          with ¦numerals=cyrillic-alph¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 % 
 % 	\item \Cmd\georgiannumeral produces Georgian alphabetic numbering.\\
 %               Example: ¦\georgiannumeral{1863}¦ yields \textgeorgian{\georgiannumeral{1863}}.
@@ -1776,24 +2305,40 @@
 % 			¦\Greeknumeral{1863}¦ results in \textgreek{\Greeknumeral{1863}}.
 % 
 % 	\item \Cmd\hebrewnumeral, \Cmd\Hebrewnumeral and \Cmd\Hebrewnumeralfinal generate variants of Hebrew alphanumeric numerals.
-% 			The commands behave exactly as they do in \pkg{babel}: ¦\hebrewnumeral¦ outputs the numbers without any decoration,
-% 			¦\Hebrewnumeral¦ adds \textit{gereshayim} before the last letter, ¦\Hebrewnumeralfinal¦ uses in addition the final forms of Hebrew letters.
+% 			The commands behave exactly as they do in \pkg{babel}: \cmd\hebrewnumeral\ outputs the numbers without any decoration,
+% 			\cmd\Hebrewnumeral\ adds \textit{gereshayim} before the last letter, \cmd\Hebrewnumeralfinal\ uses in addition the final forms of Hebrew letters.
 % 			Examples:
 % 			¦\hebrewnumeral{1750}¦ yields \texthebrew{\hebrewnumeral{1750}},
 % 			¦\Hebrewnumeral{1750}¦ yields \texthebrew{\Hebrewnumeral{1750}},
 % 			and ¦\Hebrewnumeralfinal{1750}¦ yields \texthebrew{\Hebrewnumeralfinal{1750}}.
+% 			
+% 	\item \Cmd\mongoliannumeral produces Mongolian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Mongoliannumeral.
+%             Depending on the ¦numerals¦ option in the Mongolian language selection, this is either Arabic digit or Cyrillic
+%             alphanumercial output.\\
+%             Example: With ¦numerals=latin¦ ¦\mongoliannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+%             with ¦numerals=cyrillic-trad¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+%             with ¦numerals=cyrillic-alph¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 % 	
 % 	\item \Cmd\russiannumeral produces Russian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Russiannumeral.
 % 	        Depending on the ¦numerals¦ option in the Russian language selection, this is either Arabic digit or Cyrillic
 % 	        alphanumercial output.\\
 % 	        Example: With ¦numerals=latin¦ ¦\russiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
-% 	        with ¦numerals=cyrillic¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic]{\russiannumeral{19}}.
+% 	        with ¦numerals=cyrillic-trad¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+% 	        with ¦numerals=cyrillic-alph¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 % 			
 % 	\item \Cmd\serbiannumeral produces Serbian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Serbiannumeral.
 % 		    Depending on the ¦numerals¦ option in the Serbian language selection, this is either Arabic digit or Cyrillic
 % 		    alphanumercial output.\\
-% 		    Example: With ¦numerals=latin¦ ¦\serbiannumeral{19}¦ yields \textserbian{\serbiannumeral{19}},
-% 			with ¦numerals=cyrillic¦ ¦\serbiannumeral{19}¦ results in \textserbian[numerals=cyrillic]{\serbiannumeral{19}}.
+% 		    Example: With ¦numerals=latin¦ ¦\serbiannumeral{19}¦ yields \textrussian{\serbiannumeral{19}},
+% 			with ¦numerals=cyrillic-trad¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\serbiannumeral{19}},\\
+% 			with ¦numerals=cyrillic-alph¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\serbiannumeral{19}}.
+% 			
+% 	\item \Cmd\ukrainiannumeral produces Ukrainian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Ukrainiannumeral.
+% 			Depending on the ¦numerals¦ option in the Ukrainian language selection, this is either Arabic digit or Cyrillic
+% 			alphanumercial output.\\
+% 			Example: With ¦numerals=latin¦ ¦\ukrainiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
+% 			with ¦numerals=cyrillic-trad¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
+% 			with ¦numerals=cyrillic-alph¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
 % \end{itemize}
 % 
 % 
@@ -1806,14 +2351,14 @@
 % 
 % \subsection{Horizontal footnote position}
 % 
-% When right-to-left languages are used, the ¦\footnote¦ command becomes sensitive to the text directionality. The footnote is
+% When right-to-left languages are used, the \cmd\footnote\ command becomes sensitive to the text directionality. The footnote is
 % always placed on the side that is currently the origin of direction: on the left side of the page in LTR paragraphs and
 % on the right in RTL paragraphs.
 % 
 % For cases where this is not desired, two additional footnote commands are provided: \Cmd\RTLfootnote and \Cmd\LTRfootnote.
-% ¦\LTRfootnote¦ always places the footnote on the left side, notwithstanding the current
-% directionality. Likewise, ¦\RTLfootnote¦ always places it on the right side. Like ¦\footnote¦, ¦\RTLfootnote¦
-% and ¦\LTRfootnote¦ provide an optional argument to customize the number.
+% \cmd\LTRfootnote\ always places the footnote on the left side, notwithstanding the current
+% directionality. Likewise, \cmd\RTLfootnote\ always places it on the right side. Like \cmd\footnote, \cmd\RTLfootnote\
+% and \cmd\LTRfootnote\ provide an optional argument to customize the number.
 % 
 % 
 % \subsection{Footnote rule length and position}
@@ -1830,12 +2375,13 @@
 % 	\item Put \Cmd\autofootnoterule in the preamble to have automatic placement depending on the context (see below for elaboration).
 % 	\item Put \Cmd\textwidthfootnoterule in the preamble to have a rule that spans the whole text width.
 % \end{itemize}
-% With ¦\autofootnoterule¦, the first footnote on the current page determines the placement. Note that this automatic can fail with
-% footnotes at page boundaries that differ in directionality from the first footnote on the page. You can work around such cases by switching to ¦\rightfootnoterule¦ or ¦\leftfootnoterule¦ on these pages.
+% With \cmd\autofootnoterule, the first footnote on the current page determines the placement. Note that this automatic can fail with
+% footnotes at page boundaries that differ in directionality from the first footnote on the page. You can work around such cases by switching to \cmd\rightfootnoterule\ or \cmd\leftfootnoterule\ on these pages.
 % 
 % Note also that the rule switches might interfere in bad ways with packages or classes that redefine footnotes themselves. This is also the reason
-% why ¦\autofootnoterule¦ is not used by default.
+% why \cmd\autofootnoterule\ is not used by default.
 % 
+% \condbreak{5\baselineskip}
 % \section{Calendars}
 % 
 % \subsection{Hebrew calendar (hebrewcal.sty)}
@@ -1852,24 +2398,24 @@
 % 	(Cambridge University Press, 2001).\label{reingold}}
 % It provides two macros for the end-user.
 % The command
-% 	\displaycmd{\HijriFromGregorian\{⟨year⟩\}\{⟨month⟩\}\{⟨day⟩\}}{\HijriFromGregorian}
+% 	\displaycmd{\HijriFromGregorian\marg{year}\marg{month}\marg{day}}{\HijriFromGregorian}
 % sets the counters ¦Hijriday¦, ¦Hijrimonth¦ and ¦Hijriyear¦.
 % \Cmd\Hijritoday\ formats the Hijri date for the current day.
-% This command is now locale-aware\new{v1.1.1}: its output will differ depending on the
+% This command is now locale-aware\new{1.1.1}: its output will differ depending on the
 % currently active language. Presently \pkg{polyglossia}’s language definition files
-% for Arabic, Farsi, Urdu, Turkish and Malay provide a localized version of ¦\Hijritoday¦.
+% for Arabic, Farsi, Urdu, Turkish and Malay provide a localized version of \cmd\Hijritoday.
 % If the formatting macro for the current language is undefined, the Hijri date will be formatted
 % in Arabic or in roman transliteration, depending of the current writing direction.
 % You can define a new format or redefine one with the command
-%   \displaycmd{\DefineHijriDateFormat\{<lang>\}\{<code>\}.}{\DefineHijriDateFormat}
+%   \displaycmd{\DefineHijriDateFormat\marg{lang}\marg{code}.}{\DefineHijriDateFormat}
 % 
-% The command ¦\Hijritoday¦ also accepts an optional argument to add or subtract a correction
+% The command \cmd\Hijritoday\ also accepts an optional argument to add or subtract a correction
 % (in days) to the date computed by the arithmetical algorithm.\footnote{ %
 % 	The Islamic calendar is indeed a purely lunar calendar based on the observation
 % 	of the first visibility of the lunar crescent at the beginning of the lunar month,
 % 	so there can be differences between different localities, as well as between
 % 	civil and religious authorities.}
-% For instance if ¦\Hijritoday¦ yields the date “7 Rajab 1429” (which is the date that was
+% For instance if \cmd\Hijritoday\ yields the date “7 Rajab 1429” (which is the date that was
 % displayed on the front page of \href{http://www.aljazeera.net}{aljazeera.net} on
 % 11th July 2008), ¦\Hijritoday[1]¦ would rather print “8 Rajab 1429” (the date
 % indicated the same day on the site \href{http://www.gulfnews.com}{gulfnews.com}).
@@ -1877,19 +2423,26 @@
 % \subsection{Farsi (jalālī) calendar (farsical.sty)}
 % This package is an almost verbatim copy of ¦Arabiftoday.sty¦ (in the \pkg{Arabi} package),
 % itself a slight modification of ¦ftoday.sty¦ in Farsi\TeX.\footnote{ %
-% 	One day I may rewrite \pkg{farsical} from scratch using the algorithm in
-% 	Reingold \& Gershowitz (ref.~n.~\ref{reingold}).}
+% 	One day we may rewrite \pkg{farsical} from scratch using the algorithm in
+% 	Reingold \& Gershowitz (ref.~n.\,\ref{reingold}).}
 % Here we have renamed the command \cmd\ftoday\ to
 % \Cmd\Jalalitoday.
 % Example: today is \Jalalitoday.
 % 
 % 
-% ^^A\section{Varia}
+% \section{Auxiliary commands}
 % 
+% The macro \displaycmd{\charifavailable\marg{char code}\marg{substitution}}{\charifavailable}\new{1.47} checks whether
+% the character with the specified \meta{char code} (\ie unicode utf-16 code without preceding ¦0x¦) exists in
+% the current font. If so, the character is printed, if not, the \meta{substitution} is printed.
+% 
+% Example: ¦\charifavailable{1E9E}{SS}¦ prints the capital version of the German letter ⟨ß⟩ if available
+% (\ie \charifavailable{1E9E}{SS}), else it prints the substitution digraph SS.
+% 
+% 
 % \section{Accessing language information}
 % 
 % The following is specifically relevant to package authors who need information about the languages in use.
-% 
 % In order to get such information, \pkg{polyglossia} provides the following macros:
 % 
 % \begin{itemize}
@@ -1904,21 +2457,37 @@
 % 	      Note that this macro is also defined for languages that are not supported in \pkg{babel}. In that
 % 	      case, they are equal to the polyglossia language name.
 % 	\item \Cmd\mainbabelname\ analogously stores the name of document's main language (variant) in \pkg{babel}.
+% 	\item \Cmd{\languageid\marg{type}}\new{1.47} stores the identifier tag of the current language. Currently supported \meta{types}:
+% 	      \begin{itemize}
+% 	      	\item ¦bcp-47¦ (alias ¦bcp47¦): IETF BCP-47 language identifier
+% 	      \end{itemize}
+% 	 \item \Cmd{\mainlanguageid\marg{type}}\new{1.47} stores identifier tag of the main language. Currently supported \meta{types}:
+% 	      see \cmd\languageid.
 % \end{itemize}
-% ^^A
-% If you want to have a full list of loaded languages/variants, use the following macros:
+% \bigskip
+% 
+% \noindent If you want to have a full list of loaded languages/variants, use the following macros:
 % \begin{itemize}
 % 	\item \Cmd{\xpg at loaded}\ stores a comma-separated list of all loaded languages (polyglossia name)
 % 	\item \Cmd{\xpg at vloaded}\ stores a comma-separated list of all loaded variants
-% 	\item \Cmd{\xpg at bloaded}\ stores a comma-separated list of \pkg{babel} names of all language variants 
+% 	\item \Cmd{\xpg at bloaded}\ stores a comma-separated list of \pkg{babel} names of all language variants
+% 	\item \Cmd{\xpg at bcp@loaded}\new{1.47}\ stores a comma-separated list of the BCP-47 IDs of all language variants
 % \end{itemize}
-% ^^A
-% Finally, you can test whether a language is loaded by
-% \displaycmd{\iflanguageloaded\{⟨lang⟩\}\{⟨true⟩\}\{⟨false⟩\}}{\iflanguageloaded}
-% where \texttt{⟨lang⟩} is a \pkg{polyglossia} language name, or
-% \displaycmd{\ifbabellanguageloaded\{⟨lang⟩\}\{⟨true⟩\}\{⟨false⟩\}}{\ifbabellanguageloaded}
-% where \texttt{⟨lang⟩} is a \pkg{babel} language name.
+% \bigskip
 % 
+% \noindent Whether a language is loaded can be tested by
+% \displaycmd{\iflanguageloaded\marg{lang}\marg{true}\marg{false}}{\iflanguageloaded}
+% where \texttt{\meta{lang}} is a \pkg{polyglossia} language name, by
+% \displaycmd{\ifbabellanguageloaded\marg{lang}\marg{true}\marg{false}}{\ifbabellanguageloaded}
+% where \texttt{\meta{lang}} is a \pkg{babel} language name (see table~\ref{tab:bbllang} on p.~\pageref{tab:bbllang}), or by
+% \displaycmd{\iflanguageidloaded\marg{type}\marg{id}\marg{true}\marg{false}}{\iflanguageidloaded}\new{1.47}
+% where \meta{type} is a supported language id type (such as ¦bcp-47¦) and \meta{id} is a language id
+% (such as ¦en-US¦; see table~\ref{tab:BCP47-polyglossia} on p.~\pageref{tab:BCP47-polyglossia}).
+% \bigskip
+% 
+% \noindent Finally, if you want to know whether a specific language option has been set, you can use
+% \displaycmd{\iflanguageoption\marg{lang}\marg{opt. key}\marg{opt. value}\marg{true}\marg{false}}{\iflanguageoption}\new{1.47}
+% 
 % \section{Acknowledgements (by François Charette)}
 % \pkg{Polyglossia} is notable for being a recycle box of previous contributions
 % by other people. I take this opportunity to thank the following individuals,
@@ -1933,7 +2502,7 @@
 % (Sanskrit), \TA{Zdenĕk Wagner} (Hindi), \TA{Mikhal Oren} (Hebrew), \TA{Sergey Astanin} (Russian),
 % \TA{Khaled Hosny} (Arabic), \TA{Sertaç Ö. Yıldız} (Turkish), \TA{Kamal Abdali} (Urdu),
 % and several other members of the \XeTeX\ user community, notably \TA{Enrico Gregorio}, who
-% has sent me many useful suggestions and corrections and contributed the ¦\newXeTeXintercharclass¦
+% has sent me many useful suggestions and corrections and contributed the \cmd\newXeTeXintercharclass\
 % mechanism in xelatex.ini which is now used by polyglossia.
 % More recently, \TA{Kevin Godby} of the \href{http://ubuntu-manual.org}{Ubuntu Manual} project has
 % contributed very useful feedback, bug hunting and, with the help of translators,
@@ -1950,9 +2519,9 @@
 % 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{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{Yevgen Pogribnyi}, \TA{Maïeul Rouquette},
-% \TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg}, \TA{Philipp Stephani}, \TA{Keno Wehr}, \TA{Dominik Wujastyk},
-% \TA{Sertaç Ö. Yıldız}, \TA{Maksim Zholudev}, \TA{Yan Zhou}, and \TA{Stefan Zlatinov}.
+% \TA{Ivan Kokan}, \TA{Caleb Maclennan}, \TA{José Mancera}, \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}, \TA{Keno Wehr},
+% \TA{Dominik Wujastyk}, \TA{Sertaç Ö. Yıldız}, \TA{Maksim Zholudev}, \TA{Yan Zhou}, and \TA{Stefan Zlatinov}.
 % Their respective contributions can be identified from the contributor statistics on
 % \href{https://github.com/reutenauer/polyglossia/graphs/contributors}{GitHub}.
 % 
@@ -1986,6 +2555,51 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-acadien.ldf>
+%<*gloss-aeb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-aeb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-aeb.ldf}[polyglossia: module for aeb (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-aeb.ldf>
+%<*gloss-af.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-af.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-af.ldf}[polyglossia: module for af (afrikaans)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{afrikaans}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-af.ldf>
+%<*gloss-afb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-afb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-afb.ldf}[polyglossia: module for afb (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-afb.ldf>
 %<*gloss-afrikaans.ldf>
 % \fi
 % \clearpage
@@ -1995,6 +2609,7 @@
 \ProvidesFile{gloss-afrikaans.ldf}[polyglossia: module for afrikaans]
 
 \PolyglossiaSetup{afrikaans}{
+  bcp47=af,
   hyphennames={afrikaans,dutch},
   hyphenmins={2,2},
   langtag=AFK,
@@ -2002,8 +2617,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{afrikaans}{af}
+
 \define at boolkey{afrikaans}[afrikaans@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{afrikaans}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{afrikaans}{babelshorthands=true}
 \else
@@ -2089,6 +2710,7 @@
 \ProvidesFile{gloss-albanian.ldf}[polyglossia: module for albanian]
 
 \PolyglossiaSetup{albanian}{
+  bcp47=sq,
   hyphennames={albanian},
   langtag=SQI,
   hyphenmins={2,2},
@@ -2096,6 +2718,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{albanian}{sq}
+
 \def\captionsalbanian{%
    \def\refname{Referencat}%
    \def\abstractname{Përmbledhja}%
@@ -2129,6 +2754,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-albanian.ldf>
+%<*gloss-am.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-am.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-am.ldf}[polyglossia: module for am (amharic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{amharic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-am.ldf>
 %<*gloss-american.ldf>
 % \fi
 % \clearpage
@@ -2152,6 +2792,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-amharic.ldf}[polyglossia: module for amharic]
 \PolyglossiaSetup{amharic}{
+  bcp47=am,
   script=Ethiopic,
   scripttag=ethi,
   langtag=AMH,
@@ -2161,6 +2802,9 @@
   %TODO localalph=ethnum
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{amharic}{am}
+
 \def\captionsamharic{%
    \def\refname{የነሥ ጹሁፍ ምንጭ}%
    \def\abstractname{አኅጽተሮ ጽሁፍ}%
@@ -2356,6 +3000,141 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-amharic.ldf>
+%<*gloss-apd.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-apd.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-apd.ldf}[polyglossia: module for apd (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-apd.ldf>
+%<*gloss-ar-IQ.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-IQ.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-IQ.ldf}[polyglossia: module for ar-IQ (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-IQ.ldf>
+%<*gloss-ar-JO.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-JO.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-JO.ldf}[polyglossia: module for ar-JO (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-JO.ldf>
+%<*gloss-ar-LB.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-LB.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-LB.ldf}[polyglossia: module for ar-LB (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-LB.ldf>
+%<*gloss-ar-MR.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-MR.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-MR.ldf}[polyglossia: module for ar-MR (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-MR.ldf>
+%<*gloss-ar-PS.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-PS.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-PS.ldf}[polyglossia: module for ar-PS (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-PS.ldf>
+%<*gloss-ar-SY.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-SY.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-SY.ldf}[polyglossia: module for ar-SY (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-SY.ldf>
+%<*gloss-ar-YE.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar-YE.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar-YE.ldf}[polyglossia: module for ar-YE (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar-YE.ldf>
+%<*gloss-ar.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ar.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ar.ldf}[polyglossia: module for ar (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ar.ldf>
 %<*gloss-arabic.ldf>
 % \fi
 % \clearpage
@@ -2374,6 +3153,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{arabic}{
+  bcp47=ar,
   script=Arabic,
   direction=RL,
   langtag=ARA,
@@ -2385,6 +3165,23 @@
   %TODO localalph={abjad,abjad}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{arabic}{ar}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-IQ}
+\setlanguagealias*[locale=default]{arabic}{ar-YE}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-LB}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-JO}
+\setlanguagealias*[locale=default]{arabic}{afb}
+\setlanguagealias*[locale=mauritania]{arabic}{ar-MR}
+\setlanguagealias*[locale=default]{arabic}{arz}
+\setlanguagealias*[locale=morocco]{arabic}{ary}
+\setlanguagealias*[locale=algeria]{arabic}{arq}
+\setlanguagealias*[locale=tunisia]{arabic}{aeb}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-SY}
+\setlanguagealias*[locale=libya]{arabic}{ayl}
+\setlanguagealias*[locale=default]{arabic}{apd}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-PS}
+
 \newif\ifeastern at numerals
 \def\tmp at mashriq{mashriq}
 \def\tmp at maghrib{maghrib}
@@ -2411,9 +3208,11 @@
   \def\@tmpa{#1}%
   \ifx\@tmpa\tmp at morocco%
     \eastern at numeralsfalse%
+    \SetLanguageKeys{arabic}{bcp47=ary}%
   \else
     \ifx\@tmpa\tmp at algeria%
       \eastern at numeralsfalse%
+      \SetLanguageKeys{arabic}{bcp47=arq}%
     \fi%
   \fi%
   \gdef\@@arabic at month{\@arabic at month{#1}}}
@@ -2433,8 +3232,10 @@
 \define at key{arabic}{hijricorrection}[0]{%
   \gdef\@hijri at correction{#1}}%
 
-% This should set the defaults
-\setkeys{arabic}{locale,calendar,numerals,hijricorrection,abjadjimnotail=false}
+% Register default options
+\xpg at initialize@gloss at options{arabic}{locale=default,calendar=gregorian,numerals=mashriq,hijricorrection=0,abjadjimnotail=false}
+% Register alias options
+\xpg at set@alias at values{arabic}{calendar}{islamic}{hijri}
 
 \def\arabicgregmonth at default#1{\ifcase#1%
   % Egypt, Sudan, Yemen and Golf states
@@ -2596,6 +3397,7 @@
 \ProvidesFile{gloss-armenian.ldf}[polyglossia: module for armenian]
 
 \PolyglossiaSetup{armenian}{
+  bcp47=hy,
   script=Armenian,
   scripttag=armn,
   langtag=HYE,
@@ -2605,6 +3407,9 @@
   localnumeral=armeniannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{armenian}{hy}
+
 \newif\if at eastern@armenian
 \@eastern at armenianfalse
 \define at choicekey*+{armenian}{variant}[\val\nr]{western,eastern}[western]{%
@@ -2624,6 +3429,9 @@
   \ifstrequal{#1}{arabic}{\@armenian at numeralsfalse}{\@armenian at numeralstrue}%
 }
 
+% Register default options
+\xpg at initialize@gloss at options{armenian}{numerals=armenian,variant=western}
+
 % Taken from ArmTeX. Audit!
 \def\captionsarmenian{%
    \def\refname{Հղումներ}%
@@ -2765,6 +3573,66 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-armenian.ldf>
+%<*gloss-arq.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-arq.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-arq.ldf}[polyglossia: module for arq (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-arq.ldf>
+%<*gloss-ary.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ary.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ary.ldf}[polyglossia: module for ary (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ary.ldf>
+%<*gloss-arz.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-arz.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-arz.ldf}[polyglossia: module for arz (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-arz.ldf>
+%<*gloss-ast.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ast.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ast.ldf}[polyglossia: module for ast (asturian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{asturian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ast.ldf>
 %<*gloss-asturian.ldf>
 % \fi
 % \clearpage
@@ -2776,6 +3644,7 @@
 %
 \ProvidesFile{gloss-asturian.ldf}[polyglossia: module for asturian]
 \PolyglossiaSetup{asturian}{
+  bcp47=ast,
   hyphennames={asturian,catalan},
   hyphenmins={2,2},
   langtag=AST,
@@ -2784,6 +3653,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{asturian}{ast}
+
 \def\captionsasturian{%
    \def\prefacename{Entamu}%
    \def\refname{Referencies}%
@@ -2838,7 +3710,7 @@
 % 
 % \subsection{gloss-austrian.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for austrian german (old spelling)]
+\ProvidesFile{gloss-austrian.ldf}[polyglossia: module for austrian german (old spelling)]
 
 % We provide this as a babel alias
 
@@ -2847,6 +3719,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-austrian.ldf>
+%<*gloss-ayl.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ayl.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ayl.ldf}[polyglossia: module for ayl (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ayl.ldf>
 %<*gloss-bahasa.ldf>
 % \fi
 % \clearpage
@@ -2853,11 +3740,11 @@
 % 
 % \subsection{gloss-bahasa.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-kurmanji.ldf}[polyglossia: module for kurmanji kurdish]
+\ProvidesFile{gloss-bahasa.ldf}[polyglossia: module for bahasa indonesia]
 
 % We provide this as a babel alias
 
-\xpg at load@master at language{kurdish}
+\xpg at load@master at language{malay}
 
 %    \end{macrocode}
 % \iffalse
@@ -2902,6 +3789,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-basque.ldf}[polyglossia: module for basque]
 \PolyglossiaSetup{basque}{
+  bcp47=eu,
   hyphennames={basque},
   hyphenmins={2,2},
   langtag=EUQ,
@@ -2909,6 +3797,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{basque}{eu}
+
 \def\captionsbasque{%
    \def\refname{Erreferentziak}%
    \def\abstractname{Laburpena}%
@@ -2943,6 +3834,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-basque.ldf>
+%<*gloss-be-tarask.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-be-tarask.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-be-tarask.ldf}[polyglossia: module for be-tarask (belarusian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{belarusian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-be-tarask.ldf>
+%<*gloss-be.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-be.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-be.ldf}[polyglossia: module for be (belarusian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{belarusian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-be.ldf>
 %<*gloss-belarusian.ldf>
 % \fi
 % \clearpage
@@ -2954,6 +3875,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{belarusian}{
+  bcp47=be,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=BEL,
@@ -2965,30 +3887,56 @@
   Localnumeral=Belarusiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[spelling=classic]{belarusian}{be-tarask}
+\setlanguagealias*{belarusian}{be}
+
 \def\belarusian at spelling{modern}
 \define at choicekey*+{belarusian}{spelling}[\val\nr]{modern,classic,tarask}[modern]{%
    \ifcase\nr\relax
       % modern:
-      \def\belarusian at spelling{modern}
+      \def\belarusian at spelling{modern}%
+      \SetLanguageKeys{belarusian}{bcp47=be}%
    \or
       % classic:
-      \def\belarusian at spelling{tarask}
+      \def\belarusian at spelling{tarask}%
+      \SetLanguageKeys{belarusian}{bcp47=be-tarask}%
    \or
       % tarask:
-      \def\belarusian at spelling{tarask}
+      \def\belarusian at spelling{tarask}%
+      \SetLanguageKeys{belarusian}{bcp47=be-tarask}%
    \fi
 }{\xpg at warning{Unknown Belarusian spelling `#1'}}
 
 \newif\ifcyrillic at numerals
-\define at key{belarusian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{belarusian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Belarusian, numerals=\val}%
+}{\xpg at warning{Unknown Belarusian numerals value `#1'}}
 
-\define at boolkey{belarusian}[belarusian@]{babelshorthands}[false]{}
+\define at boolkey{belarusian}[belarusian@]{babelshorthands}[true]{}
 
-\setkeys{belarusian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{belarusian}{babelshorthands=false,numerals=arabic,spelling=modern}
+% Register alias options
+\xpg at set@alias at values{belarusian}{spelling}{classic}{tarask}
 
 \ifsystem at babelshorthands
   \setkeys{belarusian}{babelshorthands=true}
@@ -3153,7 +4101,11 @@
 
 \def\belarusiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \belarusian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -3161,7 +4113,11 @@
 
 \def\Belarusiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \belarusian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -3170,25 +4126,31 @@
 \let\belarusiannumeral=\belarusiannumber
 \let\Belarusiannumeral=\Belarusiannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\belarusian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\belarusian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
+
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\belarusian 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 Я%
+   \else\xpg at ill@value{#1}{belarusian at asbuk@Alph}\fi%
+}
 
-%\def\belarusian at 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 Я\else\xpg at ill@value{#1}{belarusian at Alph}\fi}
+\def\belarusian 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 я%
+   \else\xpg at ill@value{#1}{belarusian at asbuk@alph}\fi%
+}
 
-%\def\belarusian at 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 я\else\xpg at ill@value{#1}{belarusian at alph}\fi}
-
 \def\belarusian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph
@@ -3232,16 +4194,19 @@
 % TODO implement Bengali calendar
 
 \ProvidesFile{gloss-bengali.ldf}[polyglossia: module for bengali]
+
 \ifluatex
   \xpg at warning{Bengali is not supported with LuaTeX.\MessageBreak
-I will proceed with the compilation, but\MessageBreak
-the output is not guaranteed to be correct\MessageBreak
-and may look very wrong.}
+               I will proceed with the compilation, but\MessageBreak
+               the output is not guaranteed to be correct\MessageBreak
+               and may look very wrong.}
 \fi
+
 \RequirePackage{devanagaridigits}
 \RequirePackage{bengalidigits}
 
 \PolyglossiaSetup{bengali}{
+  bcp47=bn,
   script=Bengali,
   scripttag=beng,
   langtag=BEN,
@@ -3252,56 +4217,36 @@
   %TODO nouppercase=true,
 }
 
-\def\tmp at western{Western}
+% BCP-47 compliant aliases
+\setlanguagealias*{bengali}{bn}
+
 \newif\ifbengali at devanagari@numerals
-\bengali at devanagari@numeralstrue
-\def\tmp at bengali{Bengali}
 \newif\ifbengali at bengali@numerals
-\bengali at bengali@numeralsfalse % Implied, but you never know
+\define at choicekey*+{bengali}{numerals}[\val\nr]{Devanagari,Bengali,Western}[Devanagari]{%
+   \ifcase\nr\relax
+      % Devanagari:
+      \bengali at bengali@numeralsfalse%
+      \bengali at devanagari@numeralstrue%
+   \or
+      % Bengali:
+      \bengali at bengali@numeralstrue%
+      \bengali at devanagari@numeralsfalse%
+   \or
+      % Western:
+      \bengali at bengali@numeralsfalse%
+      \bengali at devanagari@numeralsfalse%
+   \fi
+   \xpg at info{Option: Bengali, numerals=\val}%
+}{\xpg at warning{Unknown Bengali numeral `#1'}}
 
-
-\define at key{bengali}{numerals}[Devanagari]{%
-  \def\@tmpa{#1}%
-  \ifx\@tmpa\tmp at western
-    \bengali at devanagari@numeralsfalse
-  \else\ifx\@tmpa\tmp at bengali
-    \bengali at devanagari@numeralsfalse
-    \bengali at bengali@numeralstrue\fi
-  \fi}
-
 \def\extras at bengali{}
 \def\noextras at bengali{}
 
-\define at boolkey{bengali}[bengali@]{changecounternumbering}{
-  \def\@tmpa{#1}
-  \def\@tmptrue{true}
-  \ifx\@tmpa\@tmptrue
-    \def\extras at bengali{%
-      % FIXME Tied to the article class!  And horrible coding style
-      \let\savethepage\thepage
-      \let\savethesection\thesection
-      \let\savethesubsection\thesubsection
-      \let\savethesubsubsection\thesubsubsection
-      \let\savetheparagraph\theparagraph
-      \let\savethesubparagraph\thesubparagraph
-      \def\thepage{\bengalinumeral{page}}
-      \def\thesection{\bengalinumeral{section}}
-      \def\thesubsection{\bengalinumeral{subsection}}
-      \def\thesubsubsection{\bengalinumeral{subsubsection}}
-      \def\theparagraph{\bengalinumeral{paragraph}}
-      \def\thesubparagraph{\bengalinumeral{subparagraph}}
-    }
-    \def\noextras at bengali{%
-      \let\thepage\savethepage
-      \let\thesection\savethesection
-      \let\thesubsection\savethesubsection
-      \let\thesubsubsection\savethesubsubsection
-      \let\theparagraph\savetheparagraph
-      \let\thesubparagraph\savethesubparagraph
-    }
-  \fi
-}
+\define at boolkey{bengali}[bengali@]{changecounternumbering}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{bengali}{changecounternumbering=false,numerals=Devanagari}
+
 \def\captionsbengali{%
   \def\refname{তথ্যসূত্রসমূহ}%
   \def\abstractname{সারসংক্ষেপ}%
@@ -3355,13 +4300,19 @@
     \else % Assumed Western
       \number#1%
     \fi
-  \fi}
+  \fi%
+}
 
-\def\bengalinumeral#1{\expandafter\bengalinumber\expandafter{\the##1}}% Takes counter
+% Backwards compatibility. This command was never documented, but
+% some people might use it nevertheless (see #381).
+% This takes a counter.
+\newcommand\bengalinumeral[1]{\localnumeral*[lang=bengali]{#1}}
 
 \def\bengali at globalnumbers{%
-   \let\@arabic\bengalinumber%
-   \renewcommand\thefootnote{\localnumeral*{footnote}}%
+   \ifbengali at changecounternumbering
+     \let\@arabic\bengalinumber%
+     \renewcommand\thefootnote{\localnumeral*{footnote}}%
+  \fi
 }
 
 % Store original definition
@@ -3377,6 +4328,51 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-bengali.ldf>
+%<*gloss-bg.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-bg.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-bg.ldf}[polyglossia: module for bg (bulgarian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bulgarian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-bg.ldf>
+%<*gloss-bn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-bn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-bn.ldf}[polyglossia: module for bn (bengali)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bengali}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-bn.ldf>
+%<*gloss-bo.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-bo.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-bo.ldf}[polyglossia: module for bo (tibetan)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{tibetan}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-bo.ldf>
 %<*gloss-bosnian.ldf>
 % \fi
 % \clearpage
@@ -3386,6 +4382,7 @@
 \ProvidesFile{gloss-bosnian.ldf}[polyglossia: module for bosnian]
 
 \PolyglossiaSetup{bosnian}{
+  bcp47=bs,
   langtag=BOS,
   hyphennames={bosnian,croatian},
   hyphenmins={2,2}, % adapted from gloss-croatian
@@ -3394,6 +4391,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{bosnian}{bs}
+
 % TODO: Add script=Cyrillic
 
 % from babel-bosnian
@@ -3431,6 +4431,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-bosnian.ldf>
+%<*gloss-br.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-br.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-br.ldf}[polyglossia: module for br (breton)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{breton}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-br.ldf>
 %<*gloss-brazil.ldf>
 % \fi
 % \clearpage
@@ -3456,6 +4471,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-breton.ldf}[polyglossia: module for breton]
 \PolyglossiaSetup{breton}{
+  bcp47=br,
   hyphennames={breton},
   hyphenmins={2,2},
   langtag=BRE,
@@ -3464,6 +4480,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{breton}{br}
+
 \ifluatex
   % TODO
 \else
@@ -3553,7 +4572,7 @@
 % 
 % \subsection{gloss-british.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for british english]
+\ProvidesFile{gloss-british.ldf}[polyglossia: module for british english]
 
 % We provide this as a babel alias
 
@@ -3562,6 +4581,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-british.ldf>
+%<*gloss-bs.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-bs.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-bs.ldf}[polyglossia: module for bs (bosnian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bosnian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-bs.ldf>
 %<*gloss-bulgarian.ldf>
 % \fi
 % \clearpage
@@ -3570,6 +4604,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-bulgarian.ldf}[polyglossia: module for bulgarian]
 \PolyglossiaSetup{bulgarian}{
+  bcp47=bg,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=BGR,
@@ -3580,6 +4615,9 @@
   %TODO localalph=bulgarian at alph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{bulgarian}{bg}
+
 \def\bulgarian at Alph#1{%
    \ifcase#1\or
    А\or Б\or В\or Г\or Д\or Е\or Ж\or
@@ -3654,6 +4692,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-bulgarian.ldf>
+%<*gloss-ca.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ca.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ca.ldf}[polyglossia: module for ca (catalan)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{catalan}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ca.ldf>
 %<*gloss-canadian.ldf>
 % \fi
 % \clearpage
@@ -3675,7 +4728,7 @@
 % 
 % \subsection{gloss-canadien.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for canadian french]
+\ProvidesFile{gloss-canadien.ldf}[polyglossia: module for canadian french]
 
 % We provide this as a babel alias
 
@@ -3692,6 +4745,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-catalan.ldf}[polyglossia: module for catalan]
 \PolyglossiaSetup{catalan}{
+  bcp47=ca,
   hyphennames={catalan},
   hyphenmins={2,2},
   langtag=CAT,
@@ -3700,6 +4754,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{catalan}{ca}
+
 \define at boolkey{catalan}[catalan@]{babelshorthands}[true]{}
 \ifsystem at babelshorthands
   \setkeys{catalan}{babelshorthands=true}
@@ -3707,6 +4764,9 @@
   \setkeys{catalan}{babelshorthands=false}
 \fi
 
+% Register default options
+\xpg at initialize@gloss at options{catalan}{babelshorthands=false}
+
 \ifcsundef{initiate at active@char}{%
   \input{babelsh.def}%
   \initiate at active@char{"}%
@@ -3715,18 +4775,12 @@
 
 %%% adapted from Babel's catalan.ldf
 \newdimen\leftllkern \newdimen\rightllkern \newdimen\raiselldim
+
 % we check if char · exists, and use it instead of raised dot:
 \def\xpg at raiseddot{%
-  \ifluatex %
-    \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\hbox{\char"00B7}%
-    \else\raise\raiselldim\hbox{.}%
-    \fi %
-  \else %
-    \ifnum\XeTeXcharglyph"00B7 > 0\hbox{\char"00B7}% why a hbox here?
-      \else\raise\raiselldim\hbox{.}%
-    \fi %
-  \fi %
-  }
+  \charifavailable{00B7}{\raise\raiselldim\hbox{.}}%
+}
+
 \def\lgem{%
   \ifmmode
     \csname normal at char\string"\endcsname l%
@@ -3733,15 +4787,9 @@
   \else
     \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
     \setbox0\hbox{l}\setbox1\hbox{l\/}%
-    \ifluatex %
-      \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\setbox2\hbox{\char"00B7}%
-      \else\setbox2\hbox{.}%
-      \fi %
-    \else %
-      \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}%
-        \else\setbox2\hbox{.}%
-      \fi %
-    \fi %
+    \xpg at if@char at available{00B7}%
+          {\setbox2\hbox{\char"00B7}}%
+          {\setbox2\hbox{.}}%
     \advance\raiselldim by \the\fontdimen5\the\font
     \advance\raiselldim by -\ht2%
     \leftllkern=-.25\wd0%
@@ -3755,6 +4803,7 @@
       \kern\rightllkern\hbox{l}}\allowhyphens
   \fi
 }
+
 \def\Lgem{%
   \ifmmode
     \csname normal at char\string"\endcsname L%
@@ -3761,15 +4810,9 @@
   \else
     \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
     \setbox0\hbox{L}\setbox1\hbox{L\/}%
-    \ifluatex %
-      \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\setbox2\hbox{\char"00B7}%
-      \else\setbox2\hbox{.}%
-      \fi %
-    \else %
-      \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}%
-        \else\setbox2\hbox{.}%
-      \fi %
-    \fi %
+    \xpg at if@char at available{00B7}%
+          {\setbox2\hbox{\char"00B7}}%
+          {\setbox2\hbox{.}}%
     \advance\raiselldim by .5\ht0%
     \advance\raiselldim by -.5\ht2%
     \leftllkern=-.125\wd0%
@@ -3784,6 +4827,7 @@
       \kern\rightllkern\hbox{L}}\allowhyphens
   \fi
 }
+
 \AtBeginDocument{%
   \let\lslash\l
   \let\Lslash\L
@@ -3848,6 +4892,66 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-catalan.ldf>
+%<*gloss-ckb-Arab.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ckb-Arab.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ckb-Arab.ldf}[polyglossia: module for ckb-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ckb-Arab.ldf>
+%<*gloss-ckb-Latn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ckb-Latn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ckb-Latn.ldf}[polyglossia: module for ckb-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ckb-Latn.ldf>
+%<*gloss-ckb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ckb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ckb.ldf}[polyglossia: module for ckb (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ckb.ldf>
+%<*gloss-cop.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-cop.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-cop.ldf}[polyglossia: module for cop (coptic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{coptic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-cop.ldf>
 %<*gloss-coptic.ldf>
 % \fi
 % \clearpage
@@ -3856,6 +4960,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-coptic.ldf}[polyglossia: module for coptic]
 \PolyglossiaSetup{coptic}{
+  bcp47=cop,
   script=Coptic,
   scripttag=copt,
   langtag=COP,
@@ -3864,6 +4969,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{coptic}{cop}
+
 %\def\captionscoptic{%
 %   \def\refname{<++>}%
 %   \def\abstractname{<++>}%
@@ -3903,6 +5011,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-croatian.ldf}[polyglossia: module for croatian]
 \PolyglossiaSetup{croatian}{
+  bcp47=hr,
   langtag=HRV,
   hyphennames={croatian},
   hyphenmins={2,2}, % aligned with https://ctan.org/pkg/hrhyph patterns and http://lebesgue.math.hr/~nenad/Diplomski/Maja_Ribaric_2011.pdf
@@ -3911,12 +5020,134 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{croatian}{hr}
+
+\define at boolkey{croatian}[croatian@]{babelshorthands}[true]{}
+
+\define at boolkey{croatian}[croatian@]{disableligatures}[true]{}
+
+% Register default options
+\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disableligatures=false}
+
+\ifsystem at babelshorthands
+  \setkeys{croatian}{babelshorthands=true}
+\else
+  \setkeys{croatian}{babelshorthands=false}
+\fi
+
+\ifcsundef{initiate at active@char}{%
+  \input{babelsh.def}%
+  \initiate at active@char{"}%
+  \shorthandoff{"}%
+}{}
+
+\def\croatian at shorthands{%
+  \bbl at activate{"}%
+  \def\language at group{croatian}%
+  \declare at shorthand{croatian}{"=}{\penalty\@M-\hskip\z at skip}%
+  \declare at shorthand{croatian}{""}{\hskip\z at skip}%
+  \declare at shorthand{croatian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{croatian}{"-}{\nobreak\-\bbl at allowhyphens}%
+  \declare at shorthand{croatian}{"|}{%
+      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
+      \bbl at allowhyphens}{}%
+  }%
+  \declare at shorthand{croatian}{"/}{\textormath
+    {\bbl at allowhyphens\discretionary{/}{}{/}\bbl at allowhyphens}{}}%
+  \declare at shorthand{croatian}{"`}{„}%
+  \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}}%
+}
+
+\def\nocroatian at shorthands{%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+}
+
+\newcommand*\hr at charifavailable[2]{%
+   \ifcroatian at disableligatures
+     \bgroup#2\egroup%
+   \else
+     \charifavailable{#1}{#2}%
+   \fi%
+}
+
+% Provide croatian ligatures if available in current font
+\def\xpg at hr@lig#1#2{%
+ \bgroup%
+  % 1. DŽ, Dž and dž
+  \ifx#1D%
+    \ifx#2Z\relax%
+       \hr at charifavailable{01C4}{DŽ}%
+    \else%
+       \ifx#2z\relax
+          \hr at charifavailable{01C5}{Dž}%
+       \else
+           D#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1d%
+    \ifx#2z\relax
+       \hr at charifavailable{01C6}{dž}%
+    \else
+       d#2%
+    \fi%
+  \fi%
+  % 2. LJ, Lj and lj
+  \ifx#1L%
+    \ifx#2J\relax%
+       \hr at charifavailable{01C7}{LJ}%
+    \else%
+       \ifx#2j\relax
+          \hr at charifavailable{01C8}{Lj}%
+       \else
+           L#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1l%
+    \ifx#2j\relax
+       \hr at charifavailable{01C9}{lj}%
+    \else
+       l#2%
+    \fi%
+  \fi%
+  % 2. NJ, Nj and nj
+  \ifx#1N%
+    \ifx#2J\relax%
+       \hr at charifavailable{01CA}{NJ}%
+    \else%
+       \ifx#2j\relax
+          \hr at charifavailable{01CB}{Nj}%
+       \else
+           N#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1n%
+    \ifx#2j\relax
+       \hr at charifavailable{01CC}{nj}%
+    \else
+       n#2%
+    \fi%
+  \fi%
+  \egroup%
+}
+
 \def\captionscroatian{%
   \def\prefacename{Predgovor}%
   \def\refname{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
-  \def\chaptername{Poglavlje}%
+  \def\chaptername{Poglav\hr at charifavailable{01C9}{lj}e}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Popis slika}%
@@ -3934,15 +5165,59 @@
   \def\proofname{Dokaz}%
   \def\glossaryname{Pojmovnik}%
 }
+
 \def\datecroatian{%
   \def\today{\number\day.~\ifcase\month\or
     siječnja\or veljače\or ožujka\or travnja\or svibnja\or
     lipnja\or srpnja\or kolovoza\or rujna\or listopada\or studenoga\or
-    prosinca\fi \space \number\year.}}
+    prosinca\fi \space \number\year.}%
+}
 
+\def\noextras at croatian{%
+  \nocroatian at shorthands%
+}
+
+\def\blockextras at croatian{%
+  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+}
+
+\def\inlineextras at croatian{%
+  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+}
+
 %    \end{macrocode}
 % \iffalse
 %</gloss-croatian.ldf>
+%<*gloss-cy.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-cy.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-cy.ldf}[polyglossia: module for cy (welsh)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{welsh}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-cy.ldf>
+%<*gloss-cz.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-cz.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-cz.ldf}[polyglossia: module for cz (czech)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{czech}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-cz.ldf>
 %<*gloss-czech.ldf>
 % \fi
 % \clearpage
@@ -3952,6 +5227,7 @@
 \ProvidesFile{gloss-czech.ldf}[polyglossia: module for czech]
 
 \PolyglossiaSetup{czech}{
+  bcp47=cz,
   hyphennames={czech},
   hyphenmins={2,2},
   langtag=CSY,
@@ -3959,6 +5235,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{czech}{cz}
+
 \ifluatex
   \RequirePackage{luavlna}
 \fi
@@ -3969,7 +5248,8 @@
 
 \define at boolkey{czech}[czech@]{vlna}[true]{}
 
-\setkeys{czech}{splithyphens,vlna}
+% Register default options
+\xpg at initialize@gloss at options{czech}{babelshorthands=false,splithyphens=true,vlna=true}
 
 \ifsystem at babelshorthands
   \setkeys{czech}{babelshorthands=true}
@@ -3984,8 +5264,12 @@
 }{}
 
 \def\cs@@splithyphen#1{%
-  \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
-  \nobreak\hskip\z@%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
 }
 
 \def\cs at splithyphen{%
@@ -4163,18 +5447,33 @@
 \def\blockextras at czech{%
   \ifczech at babelshorthands\czech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
-  \ifczech at splithyphens\czech at hyphens\else\noczech at hyhens\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 vlna\czech at vlna\else\noczech at vlna\fi%
-  \ifczech at splithyphens\czech at hyphens\else\noczech at hyhens\fi%
+  \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }
 
 %    \end{macrocode}
 % \iffalse
 %</gloss-czech.ldf>
+%<*gloss-da.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-da.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-da.ldf}[polyglossia: module for da (danish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{danish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-da.ldf>
 %<*gloss-danish.ldf>
 % \fi
 % \clearpage
@@ -4183,6 +5482,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-danish.ldf}[polyglossia: module for danish]
 \PolyglossiaSetup{danish}{
+  bcp47=da,
   hyphennames={danish},
   hyphenmins={2,3},
   langtag=DAN,
@@ -4190,6 +5490,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{danish}{da}
+
 \def\captionsdanish{%
   \def\prefacename{Forord}%
   \def\refname{Litteratur}%
@@ -4223,6 +5526,306 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-danish.ldf>
+%<*gloss-de-AT-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-AT-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT-1901.ldf}[polyglossia: module for de-AT-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-AT-1901.ldf>
+%<*gloss-de-AT-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-AT-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT-1996.ldf}[polyglossia: module for de-AT-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-AT-1996.ldf>
+%<*gloss-de-AT.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-AT.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT.ldf}[polyglossia: module for de-AT (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-AT.ldf>
+%<*gloss-de-CH-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-CH-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH-1901.ldf}[polyglossia: module for de-CH-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-CH-1901.ldf>
+%<*gloss-de-CH-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-CH-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH-1996.ldf}[polyglossia: module for de-CH-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-CH-1996.ldf>
+%<*gloss-de-CH.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-CH.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH.ldf}[polyglossia: module for de-CH (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-CH.ldf>
+%<*gloss-de-DE-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-DE-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE-1901.ldf}[polyglossia: module for de-DE-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-DE-1901.ldf>
+%<*gloss-de-DE-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-DE-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE-1996.ldf}[polyglossia: module for de-DE-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-DE-1996.ldf>
+%<*gloss-de-DE.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-DE.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE.ldf}[polyglossia: module for de-DE (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-DE.ldf>
+%<*gloss-de-Latf-AT-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-AT-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT-1901-Latf.ldf}[polyglossia: module for de-AT-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-AT-1901.ldf>
+%<*gloss-de-Latf-AT-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-AT-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT-1996-Latf.ldf}[polyglossia: module for de-AT-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-AT-1996.ldf>
+%<*gloss-de-Latf-AT.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-AT.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-AT-Latf.ldf}[polyglossia: module for de-AT-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-AT.ldf>
+%<*gloss-de-Latf-CH-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-CH-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH-1901-Latf.ldf}[polyglossia: module for de-CH-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-CH-1901.ldf>
+%<*gloss-de-Latf-CH-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-CH-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH-1996-Latf.ldf}[polyglossia: module for de-CH-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-CH-1996.ldf>
+%<*gloss-de-Latf-CH.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-CH.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-CH-Latf.ldf}[polyglossia: module for de-CH-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-CH.ldf>
+%<*gloss-de-Latf-DE-1901.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-DE-1901.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE-1901-Latf.ldf}[polyglossia: module for de-DE-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-DE-1901.ldf>
+%<*gloss-de-Latf-DE-1996.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-DE-1996.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE-1996-Latf.ldf}[polyglossia: module for de-DE-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-DE-1996.ldf>
+%<*gloss-de-Latf-DE.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf-DE.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-DE-Latf.ldf}[polyglossia: module for de-DE-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf-DE.ldf>
+%<*gloss-de-Latf.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de-Latf.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de-Latf.ldf}[polyglossia: module for de-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de-Latf.ldf>
+%<*gloss-de.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-de.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-de.ldf}[polyglossia: module for de (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-de.ldf>
 %<*gloss-divehi.ldf>
 % \fi
 % \clearpage
@@ -4238,6 +5841,7 @@
 \fi
 \RequireBidi
 \PolyglossiaSetup{divehi}{
+  bcp47=dv,
   script=Thaana,
   scripttag=thaa,
   langtag=DIV,% TODO Support DHV as well?
@@ -4246,6 +5850,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{divehi}{dv}
+
 %\def\captionsdivehi{%
 %   \def\refname{<++>}%
 %   \def\abstractname{<++>}%
@@ -4287,6 +5894,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-divehi.ldf>
+%<*gloss-dsb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-dsb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-dsb.ldf}[polyglossia: module for dsb (sorbian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{sorbian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-dsb.ldf>
 %<*gloss-dutch.ldf>
 % \fi
 % \clearpage
@@ -4295,6 +5917,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-dutch.ldf}[polyglossia: module for dutch]
 \PolyglossiaSetup{dutch}{
+  bcp47=nl,
   hyphennames={dutch},
   hyphenmins={2,2},
   langtag=NLD,
@@ -4302,8 +5925,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{dutch}{nl}
+
 \define at boolkey{dutch}[dutch@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{dutch}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{dutch}{babelshorthands=true}
 \else
@@ -4381,6 +6010,156 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-dutch.ldf>
+%<*gloss-dv.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-dv.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-dv.ldf}[polyglossia: module for dv (divehi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{divehi}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-dv.ldf>
+%<*gloss-el-monoton.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-el-monoton.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-el-monoton.ldf}[polyglossia: module for el-monoton (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-el-monoton.ldf>
+%<*gloss-el-polyton.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-el-polyton.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-el-polyton.ldf}[polyglossia: module for el-polyton (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-el-polyton.ldf>
+%<*gloss-el.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-el.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-el.ldf}[polyglossia: module for el (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-el.ldf>
+%<*gloss-en-AU.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en-AU.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en-AU.ldf}[polyglossia: module for en-AU (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en-AU.ldf>
+%<*gloss-en-CA.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en-CA.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en-CA.ldf}[polyglossia: module for en-CA (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en-CA.ldf>
+%<*gloss-en-GB.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en-GB.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en-GB.ldf}[polyglossia: module for en-GB (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en-GB.ldf>
+%<*gloss-en-NZ.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en-NZ.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en-NZ.ldf}[polyglossia: module for en-NZ (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en-NZ.ldf>
+%<*gloss-en-US.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en-US.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en-US.ldf}[polyglossia: module for en-US (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en-US.ldf>
+%<*gloss-en.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-en.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-en.ldf}[polyglossia: module for en (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-en.ldf>
 %<*gloss-english.ldf>
 % \fi
 % \clearpage
@@ -4390,6 +6169,7 @@
 \ProvidesFile{gloss-english.ldf}[polyglossia: module for english]
 
 \PolyglossiaSetup{english}{
+  bcp47=en-US,
   hyphennames={english,american,usenglish,USenglish},
   hyphenmins={2,3},
   langtag=ENG,
@@ -4396,6 +6176,14 @@
   fontsetup=true,
 }
 
+% 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}
+
 % Babel aliases
 \setlanguagealias[variant=us]{english}{american}
 \setlanguagealias[variant=australian]{english}{australian}
@@ -4417,13 +6205,13 @@
 % Option ordinalmonthday
 \define at boolkey{english}[english@]{ordinalmonthday}[true]{}
 
-\define at choicekey*+{english}{variant}[\val\nr]{uk,british,us,american,usmax,australian,newzealand,canadian}{%
+\define at choicekey*+{english}{variant}[\val\nr]{uk,british,us,american,usmax,australian,newzealand,canadian}[us]{%
    \ifcase\nr\relax
       % uk:
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdaytrue
-      \SetLanguageKeys{english}{babelname=british}%
+      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB}%
       \xpg at info{Option: English, variant=british}%
    \or
       % british:
@@ -4430,7 +6218,7 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdaytrue
-      \SetLanguageKeys{english}{babelname=british}%
+      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB}%
       \xpg at info{Option: english variant=british}%
    \or
       % us:
@@ -4437,7 +6225,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: English, variant=american}%
    \or
       % american:
@@ -4444,7 +6232,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: English, variant=american}%
    \or
       % usmax:
@@ -4451,7 +6239,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: english variant=american (with additional patterns)}%
       \xpg at ifdefined{usenglishmax}{}%
          {\xpg at warning{No hyphenation patterns were loaded for "US English Max"\MessageBreak
@@ -4466,8 +6254,9 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=australian}%
+      \SetLanguageKeys{english}{babelname=australian,bcp47=en-AU}%
       \xpg at info{Option: English, variant=australian}%
+      \adddialect\l at australian\l at english%
    \or
       % newzealand:
       % These use the british hyphenation patterns
@@ -4475,8 +6264,9 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=newzealand}%
+      \SetLanguageKeys{english}{babelname=newzealand,bcp47=en-NZ}%
       \xpg at info{Option: English, variant=newzealand}%
+      \adddialect\l at newzealand\l at english%
    \or
       % canadian:
       % This is currently equivalent to usenglish (as in babel)
@@ -4483,8 +6273,9 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=canadian}%
+      \SetLanguageKeys{english}{babelname=canadian,bcp47=en-CA}%
       \xpg at info{Option: English, variant=american}%
+      \adddialect\l at canadian\l at english%
    \fi
    \ifbritish at hyphen
       \xpg at ifdefined{ukenglish}{}%
@@ -4496,6 +6287,12 @@
    \fi
 }{\xpg at warning{Unknown English variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{english}{variant=us,ordinalmonthday=false}
+% Register alias options
+\xpg at set@alias at values{english}{variant}{us}{american}
+\xpg at set@alias at values{english}{variant}{uk}{british}
+
 \ifxetex
    % Check if \l at english is defined. If not, try to set it to some variety
    % (specific order as in the csv list below), or null language if everything fails
@@ -4515,7 +6312,7 @@
 \fi
 
 \def\english at language{%
-   \polyglossia at setup@language at patterns{\english at variant}
+   \polyglossia at setup@language at patterns{\english at variant}%
 }%
 
 \def\captionsenglish{%
@@ -4566,6 +6363,66 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-english.ldf>
+%<*gloss-eo.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-eo.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-eo.ldf}[polyglossia: module for eo (esperanto)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{esperanto}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-eo.ldf>
+%<*gloss-es-ES.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-es-ES.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-es-ES.ldf}[polyglossia: module for es-ES (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-es-ES.ldf>
+%<*gloss-es-MX.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-es-MX.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-es-MX.ldf}[polyglossia: module for es-MX (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-es-MX.ldf>
+%<*gloss-es.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-es.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-es.ldf}[polyglossia: module for es (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-es.ldf>
 %<*gloss-esperanto.ldf>
 % \fi
 % \clearpage
@@ -4574,6 +6431,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-esperanto.ldf}[polyglossia: module for esperanto]
 \PolyglossiaSetup{esperanto}{
+  bcp47=eo,
   hyphennames={esperanto},
   hyphenmins={2,2},
   langtag=NTO,
@@ -4581,6 +6439,9 @@
   %TODO localalph={esperanto at alph,esperanto at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{esperanto}{eo}
+
 \def\captionsesperanto{%
    \def\refname{Citaĵoj}%
    \def\abstractname{Resumo}%
@@ -4646,6 +6507,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-estonian.ldf}[polyglossia: module for estonian]
 \PolyglossiaSetup{estonian}{
+  bcp47=et,
   hyphennames={estonian},
   hyphenmins={2,2},
   langtag=ETI,
@@ -4653,6 +6515,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{estonian}{et}
+
 \def\captionsestonian{%
    \def\refname{Viited}%
    \def\abstractname{Kokkuvõte}%
@@ -4686,6 +6551,51 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-estonian.ldf>
+%<*gloss-et.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-et.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-et.ldf}[polyglossia: module for et (estonian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{estonian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-et.ldf>
+%<*gloss-eu.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-eu.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-eu.ldf}[polyglossia: module for eu (basque)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{basque}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-eu.ldf>
+%<*gloss-fa.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fa.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fa.ldf}[polyglossia: module for fa (persian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{persian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fa.ldf>
 %<*gloss-farsi.ldf>
 % \fi
 % \clearpage
@@ -4702,6 +6612,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-farsi.ldf>
+%<*gloss-fi.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fi.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fi.ldf}[polyglossia: module for fi (finnish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{finnish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fi.ldf>
 %<*gloss-finnish.ldf>
 % \fi
 % \clearpage
@@ -4710,6 +6635,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-finnish.ldf}[polyglossia: module for finnish]
 \PolyglossiaSetup{finnish}{
+  bcp47=fi,
   hyphennames={finnish},
   hyphenmins={2,2},
   langtag=FIN,
@@ -4717,8 +6643,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{finnish}{fi}
+
 \define at boolkey{finnish}[finnish@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{finnish}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{finnish}{babelshorthands=true}
 \else
@@ -4793,6 +6725,66 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-finnish.ldf>
+%<*gloss-fr-CA.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fr-CA.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fr-CA.ldf}[polyglossia: module for fr-CA (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fr-CA.ldf>
+%<*gloss-fr-CH.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fr-CH.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fr-CH.ldf}[polyglossia: module for fr-CH (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fr-CH.ldf>
+%<*gloss-fr-FR.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fr-FR.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fr-FR.ldf}[polyglossia: module for fr-FR (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fr-FR.ldf>
+%<*gloss-fr.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fr.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fr.ldf}[polyglossia: module for fr (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fr.ldf>
 %<*gloss-french.ldf>
 % \fi
 % \clearpage
@@ -4802,6 +6794,7 @@
 \ProvidesFile{gloss-french.ldf}[polyglossia: module for french]
 
 \PolyglossiaSetup{french}{%
+  bcp47=fr-FR,
   language=French,
   script=Latin,
   langtag=FRA,
@@ -4811,31 +6804,47 @@
   hyphenmins={2,2},
   fontsetup=true}
 
+% BCP-47 compliant aliases
+\setlanguagealias*{french}{fr}
+\setlanguagealias*[variant=french]{french}{fr-FR}
+\setlanguagealias*[variant=canadian]{french}{fr-CA}
+\setlanguagealias*[variant=swiss]{french}{fr-CH}
+
 % Babel aliases
 \setlanguagealias[variant=acadian]{french}{acadien}
 \setlanguagealias[variant=canadian]{french}{canadien}
 
 \def\french at variant{french}
-\define at choicekey*+{french}{variant}[\val\nr]{french,canadian,acadian}[french]{%
+\define at choicekey*+{french}{variant}[\val\nr]{french,canadian,acadian,swiss}[french]{%
    \ifcase\nr\relax
       % french:
       \def\french at variant{french}%
+      \SetLanguageKeys{french}{babelname=french,bcp47=fr-FR}%
+      \french at thincolonspacefalse
    \or
       % canadian:
       \def\french at variant{canadien}%
-      \SetLanguageKeys{french}{babelname=canadien}%
+      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA}%
       \xpg at ifdefined{canadien}{}%
       {\xpg at warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak
         I will use the standard patterns for French instead}%
       \adddialect\l at canadien\l at french\relax}%
+      \french at thincolonspacefalse
    \or
       % acadian:
       \def\french at variant{acadian}%
-      \SetLanguageKeys{french}{babelname=canadien}%
+      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA}%
       \xpg at ifdefined{acadian}{}%
       {\xpg at warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak
         I will use the standard patterns for French instead}%
       \adddialect\l at acadian\l at french\relax}%
+      \french at thincolonspacefalse
+   \or
+      % swiss:
+      \def\french at variant{swissfrench}%
+      \SetLanguageKeys{french}{babelname=french,bcp47=fr-CH}%
+      \adddialect\l at swissfrench\l at french\relax%
+      \french at thincolonspacetrue
    \fi
    \xpg at info{Option: French, variant=\val}%
 }{\xpg at warning{Unknown French variant `#1'}}
@@ -4842,15 +6851,16 @@
 
 
 \def\french at language{%
-   \polyglossia at setup@language at patterns{\french at variant}
+   \polyglossia at setup@language at patterns{\french at variant}%
 }%
 
 \ifluatex
   \directlua{require('polyglossia-french')}%
 \else
-  \newXeTeXintercharclass\french at openbrackets % ( ] {
-  \newXeTeXintercharclass\french at closebrackets % ( ] {
-  \newXeTeXintercharclass\french at punctthin % ! ? ; et autres
+  \newXeTeXintercharclass\french at openbrackets % ( [ {
+  \newXeTeXintercharclass\french at closebrackets % ) ] }
+  \newXeTeXintercharclass\french at questionexclamation % ! ? et autres
+  \newXeTeXintercharclass\french at punctthin % ; (et :)
   \newXeTeXintercharclass\french at punctthick % :
   \newXeTeXintercharclass\french at punctguillstart % « ‹
   \newXeTeXintercharclass\french at punctguillend % » ›
@@ -4863,9 +6873,9 @@
 
 \define at boolkey{french}[french@]{frenchfootnote}[true]{%
   \AfterPreamble{%
-    \ifdefstring{\xpg at main@language}{french}{%
-      \iffrench at frenchfootnote
-         \ifx\@makefntext\undefined\else        
+    \iffrench at frenchfootnote
+      \ifdefstring{\xpg at main@language}{french}{%
+         \ifx\@makefntext\undefined\else
              \long\def\french at makefntext##1{%
                 \parindent1em \noindent\quad%
                 \ifx\@thefnmark\empty\else%
@@ -4873,10 +6883,10 @@
              }
              \let\@makefntext\french at makefntext
          \fi
-      \else
-         \let\@makefntext\xpg at orig@makefntext
-      \fi
-    }{\xpg at warning{Option 'frenchfootnote' only supported if French is main language!}}%
+      }{\xpg at warning{Option 'frenchfootnote' only supported if French is main language!}}%
+    \else
+       \let\@makefntext\xpg at orig@makefntext
+    \fi
   }%
 }
 
@@ -4948,20 +6958,29 @@
 
 \define at boolkey{french}[french@]{frenchitemlabels}[true]{%
   \AfterPreamble{%
-    \ifdefstring{\xpg at main@language}{french}{%
-      \iffrench at frenchitemlabels
+    \iffrench at frenchitemlabels
+      \ifdefstring{\xpg at main@language}{french}{%
          \renewcommand{\labelitemi}{\french at itemi}%
          \renewcommand{\labelitemii}{\french at itemii}%
          \renewcommand{\labelitemiii}{\french at itemiii}%
          \renewcommand{\labelitemiv}{\french at itemiv}%
-      \else
-         \let\@makefntext\xpg at orig@makefntext
-      \fi
-    }{\xpg at warning{Option 'frenchitemlabels' only supported if French is main language!}}%
+      }{\xpg at warning{Option 'frenchitemlabels' only supported if French is main language!}}%
+    \else
+       \let\@makefntext\xpg at orig@makefntext
+    \fi
   }%
 }
 
+% Register default options
+\xpg at initialize@gloss at options{french}{variant=french,autospacing=true,thincolonspace=false,
+                                      autospaceguillemets=true,autospacetypewriter=false,
+                                      frenchfootnote=false,frenchitemlabels=false,
+                                      itemlabels=\textemdash,itemlabeli=\textemdash,itemlabelii=\textemdash,
+                                      itemlabeliii=\textemdash,itemlabeliv=\textemdash}
+% Register alias options
+\xpg at set@alias at values{french}{variant}{canadian}{acadian}
 
+
 \def\french at fontsetup{%
   \unless\iffrench at autospacetypewriter
     \let\ttfamily\french at ttfamilyFB
@@ -4993,12 +7012,13 @@
       \fi
     \else
       \XeTeXinterchartokenstate=1
-      \XeTeXcharclass `\! \french at punctthin
-      \XeTeXcharclass `\? \french at punctthin
-      \XeTeXcharclass `\‼ \french at punctthin
-      \XeTeXcharclass `\⁇ \french at punctthin
-      \XeTeXcharclass `\⁈ \french at punctthin
-      \XeTeXcharclass `\⁉ \french at punctthin
+      \XeTeXcharclass `\! \french at questionexclamation
+      \XeTeXcharclass `\? \french at questionexclamation
+      \XeTeXcharclass `\‼ \french at questionexclamation
+      \XeTeXcharclass `\⁇ \french at questionexclamation
+      \XeTeXcharclass `\⁈ \french at questionexclamation
+      \XeTeXcharclass `\⁉ \french at questionexclamation
+      \XeTeXcharclass `\‽ \french at questionexclamation % U+203D (interrobang)
       \XeTeXcharclass `\; \french at punctthin
       \iffrench at thincolonspace
         \XeTeXcharclass `\: \french at punctthin
@@ -5017,13 +7037,16 @@
       \XeTeXcharclass `\} \french at closebrackets
       \XeTeXcharclass `\⟨ \french at openbrackets
       \XeTeXcharclass `\⟩ \french at closebrackets
+      \XeTeXinterchartoks \z@ \french at questionexclamation = {\xpg at french@thinsp}%
       \XeTeXinterchartoks \z@ \french at punctthin = {\xpg at french@thinsp}%
       \XeTeXinterchartoks \z@ \french at punctthick = {\nobreakspace}%
+      \XeTeXinterchartoks \xpg at boundaryclass \french at questionexclamation = {\xpg at unskip\xpg at french@thinsp}%
       \XeTeXinterchartoks \xpg at boundaryclass \french at punctthin = {\xpg at unskip\xpg at french@thinsp}%
       \XeTeXinterchartoks \xpg at boundaryclass \french at punctthick = {\xpg at unskip\nobreakspace}%
       \iffrench at autospaceguillemets
         \let\xpg at french@guillspace\xpg at french@thinsp%
         \XeTeXinterchartoks \french at punctguillstart \z@ = {\xpg at french@guillspace}% "«a" -> "«\,a"
+        \XeTeXinterchartoks \french at punctguillstart \french at punctguillstart = {\xpg at french@guillspace}% "«‹" -> "«\,‹"
  %      \XeTeXinterchartoks \z@ \french at punctguillstart = {\nobreakspace}% "a«" unchanged?
  %      \XeTeXinterchartoks \french at punctguillend \z@ = {\nobreakspace}% "»a" unchanged?
         \XeTeXinterchartoks \z@ \french at punctguillend = {\xpg at french@guillspace}% "a»" -> "a\,»"
@@ -5030,13 +7053,19 @@
         \XeTeXinterchartoks \french at punctguillstart \xpg at boundaryclass = {\xpg at french@guillspace\ignorespaces}% "«  " -> "«\,"
         \XeTeXinterchartoks \xpg at boundaryclass \french at punctguillend = {\xpg at unskip\xpg at french@guillspace}% "  »" -> "\,»"
         \XeTeXinterchartoks \french at closebrackets \french at punctguillend = {\xpg at french@guillspace}% ")»" -> ")\,»"
+        \XeTeXinterchartoks \french at questionexclamation \french at punctguillend  = {\xpg at french@guillspace}% "?»" -> "?\,»"
+        \XeTeXinterchartoks \french at punctthin \french at punctguillend  = {\xpg at french@guillspace}% ";»" -> ";\,»"
+        \XeTeXinterchartoks \french at punctguillend \french at punctguillend  = {\xpg at french@guillspace}% "›»" -> "›\,»"
      \else
        \def\xpg at french@guillspace{}%
      \fi
+     \XeTeXinterchartoks \french at punctguillend \french at questionexclamation = {\xpg at french@thinsp}% "»?" -> "»\,?"
      \XeTeXinterchartoks \french at punctguillend \french at punctthin = {\xpg at french@thinsp}% "»;" -> "»\,;"
      \XeTeXinterchartoks \french at punctguillend \french at punctthick = {\nobreakspace}% "»:" -> "» :"
-     \XeTeXinterchartoks \french at punctthin \french at punctguillend  = {\xpg at french@thinsp}% "?»" -> "?\,»"
-     \XeTeXinterchartoks \french at openbrackets \french at punctthin = {\xpg at unskip}% "(?" -> "(?" and not "( ?"      
+     \XeTeXinterchartoks \french at questionexclamation \french at punctthin = {\xpg at french@thinsp}% "?;" -> "?\,;"
+     \XeTeXinterchartoks \french at questionexclamation \french at punctthick = {\xpg at french@thinsp}% "?:" -> "?\,:"
+     \XeTeXinterchartoks \french at openbrackets \french at questionexclamation = {\xpg at unskip}% "(?" -> "(?" and not "( ?"
+     \XeTeXinterchartoks \french at openbrackets \french at punctthin = {\xpg at unskip}% "(;" -> "(;" and not "( ;"
      \XeTeXinterchartoks \french at punctthin \french at closebrackets = {\xpg at unskip}% "?)" -> "?)" (code not need, just for symetry with previous one)
      \XeTeXinterchartoks \french at closebrackets \french at punctthin = {\xpg at french@thinsp}% ")?" -> ")\,?"
      \XeTeXinterchartoks \french at closebrackets \french at punctthick = {\nobreakspace}% "):" -> ") :"
@@ -5054,6 +7083,7 @@
       \XeTeXcharclass `\⁇ \z@
       \XeTeXcharclass `\⁈ \z@
       \XeTeXcharclass `\⁉ \z@
+      \XeTeXcharclass `\‽ \z@
       \XeTeXcharclass `\; \z@
       \XeTeXcharclass `\: \z@
       \XeTeXcharclass `\« \z@
@@ -5184,6 +7214,7 @@
 \ProvidesFile{gloss-friulian.ldf}[polyglossia: module for friulian]
 
 \PolyglossiaSetup{friulian}{%
+  bcp47=fur,
   language=Friulian,
   babelname=friulan,
   hyphennames={friulan,furlan},
@@ -5194,6 +7225,9 @@
   frenchspacing=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{friulian}{fur}
+
 % Babel and backwards compat. alias
 \setlanguagealias{friulian}{friulan}
 
@@ -5253,6 +7287,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-friulian.ldf>
+%<*gloss-fur.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-fur.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-fur.ldf}[polyglossia: module for fur (friulian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{friulian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-fur.ldf>
+%<*gloss-ga.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ga.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ga.ldf}[polyglossia: module for ga (gaelic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{gaelic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ga.ldf>
 %<*gloss-gaelic.ldf>
 % \fi
 % \clearpage
@@ -5262,6 +7326,7 @@
 \ProvidesFile{gloss-gaelic.ldf}[polyglossia: module for gaelic]
 
 \PolyglossiaSetup{gaelic}{
+  bcp47=ga,
   language=Irish,
   babelname=irish,
   hyphennames={irish},
@@ -5270,6 +7335,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=irish]{gaelic}{ga}
+\setlanguagealias*[variant=scottish]{gaelic}{gd} 
 % Babel aliases
 \setlanguagealias[variant=irish]{gaelic}{irish}
 \setlanguagealias[variant=scottish]{gaelic}{scottish}
@@ -5279,17 +7347,20 @@
    \ifcase\nr\relax
       % irish:
       \gdef\gaelic at variant{irish}%
-      \SetLanguageKeys{gaelic}{language=Irish,langtag=IRI,babelname=irish}%
+      \SetLanguageKeys{gaelic}{language=Irish,langtag=IRI,babelname=irish,bcp47=ga}%
       \xpg at fontsetup@latin{gaelic}%
    \or
       % scottish:
       \gdef\gaelic at variant{scottish}%
-      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish}%
+      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish,bcp47=gd}%
       \xpg at fontsetup@latin{gaelic}%
    \fi
    \xpg at info{Option: gaelic, variant=\val}%
 }{\xpg at warning{Unknown gaelic variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{gaelic}{variant=irish}
+
 \def\captionsgaelic at irish{%
    \def\refname{Tagairtí}%
    \def\abstractname{Achoimre}%
@@ -5380,6 +7451,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-galician.ldf}[polyglossia: module for galician]
 \PolyglossiaSetup{galician}{
+  bcp47=gl,
   hyphennames={galician},
   hyphenmins={2,2},
   langtag=GAL,
@@ -5387,6 +7459,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{galician}{gl}
+
 \def\captionsgalician{%
    \def\refname{Referencias}%
    \def\abstractname{Resumo}%
@@ -5420,6 +7495,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-galician.ldf>
+%<*gloss-gd.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-gd.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-gd.ldf}[polyglossia: module for gd (gaelic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{gaelic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-gd.ldf>
 %<*gloss-georgian.ldf>
 % \fi
 % \clearpage
@@ -5429,6 +7519,7 @@
 \ProvidesFile{gloss-georgian.ldf}[polyglossia: module for georgian]
 
 \PolyglossiaSetup{georgian}{
+  bcp47=ka,
   script=Georgian,
   scripttag=geor,
   langtag=KAT,
@@ -5437,6 +7528,9 @@
   localnumeral=georgiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{georgian}{ka}
+
 \newif\ifgeorgian at numerals
 \define at key{georgian}{numerals}[arabic]{%
    \ifstrequal{#1}{georgian}%
@@ -5448,6 +7542,9 @@
 
 \define at boolkey{georgian}[georgian@]{oldmonthnames}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{georgian}{babelshorthands=false,oldmonthnames=false,numerals=arabic}
+
 \ifsystem at babelshorthands
   \setkeys{georgian}{babelshorthands=true}
 \else
@@ -5662,6 +7759,7 @@
 \ProvidesFile{gloss-german.ldf}[polyglossia: module for german]
 
 \PolyglossiaSetup{german}{
+  bcp47=de-DE,
   hyphenmins={2,2},
   frenchspacing=true,
   fontsetup=true,
@@ -5669,6 +7767,28 @@
   babelname=ngerman
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{german}{de}
+\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH}
+\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT}
+\setlanguagealias*[variant=german,spelling=new]{german}{de-DE}
+\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH}
+\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE}
+\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT}
+\setlanguagealias*[variant=austrian,spelling=old]{german}{de-AT-1901}
+\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH-1996}
+\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT-1996}
+\setlanguagealias*[variant=german,spelling=old]{german}{de-DE-1901}
+\setlanguagealias*[variant=swiss,spelling=old,script=blackletter]{german}{de-Latf-CH-1901}
+\setlanguagealias*[variant=swiss,spelling=old]{german}{de-CH-1901}
+\setlanguagealias*[variant=austrian,spelling=old,script=blackletter]{german}{de-Latf-AT-1901}
+\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH-1996}
+\setlanguagealias*[script=blackletter]{german}{de-Latf}
+\setlanguagealias*[variant=german,spelling=new]{german}{de-DE-1996}
+\setlanguagealias*[variant=german,spelling=old,script=blackletter]{german}{de-Latf-DE-1901}
+\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE-1996}
+\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT-1996}
+
 % Babel aliases
 \setlanguagealias[variant=austrian,spelling=old]{german}{austrian}
 \setlanguagealias[variant=austrian,spelling=new]{german}{naustrian}
@@ -5679,7 +7799,7 @@
 
 \newif\if at german@oldspelling
 \@german at oldspellingfalse
-\define at choicekey*+{german}{spelling}[\val\nr]{new,old,1901}[new]{%
+\define at choicekey*+{german}{spelling}[\val\nr]{new,old,1901,1996}[new]{%
    \ifcase\nr\relax
       % new:
       \@german at oldspellingfalse
@@ -5689,6 +7809,9 @@
    \or
       % 1901:
       \@german at oldspellingtrue
+   \or
+      % 1996:
+      \@german at oldspellingfalse
    \fi
    \german at set@babelname%
    \xpg at info{Option: German, spelling=\val}%
@@ -5725,21 +7848,45 @@
 \def\german at set@babelname{%
   \if at german@oldspelling
      \if at swiss@locale
-         \SetLanguageKeys{german}{babelname=swissgerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-Latf-CH-1901}%
+         \else
+           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-CH-1901}%
+         \fi
      \else
      \if at austrian@locale
-         \SetLanguageKeys{german}{babelname=austrian}%
+         \if at german@blackletter
+            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-Latf-AT-1901}%
+         \else
+            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-AT-1901}%
+         \fi
      \else
-         \SetLanguageKeys{german}{babelname=german}%
+         \if at german@blackletter
+            \SetLanguageKeys{german}{babelname=german,bcp47=de-Latf-DE-1901}%
+         \else
+            \SetLanguageKeys{german}{babelname=german,bcp47=de-DE-1901}%
+         \fi
      \fi\fi
   \else
      \if at swiss@locale
-         \SetLanguageKeys{german}{babelname=nswissgerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-Latf-CH}%
+         \else
+           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-CH}%
+         \fi
      \else
      \if at austrian@locale
-         \SetLanguageKeys{german}{babelname=naustrian}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-Latf-AT}%
+         \else
+           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-AT}%
+         \fi
      \else
-         \SetLanguageKeys{german}{babelname=ngerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-Latf-DE}%
+         \else
+           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-DE}%
+         \fi
      \fi\fi
   \fi
 }
@@ -5756,15 +7903,25 @@
       % fraktur:
       \@german at blacklettertrue%
    \fi
+   \german at set@babelname%
    \xpg at info{Option: German, script=\val}%
 }{\xpg at warning{Unknown German script `#1'}}
 
-\define at boolkey{german}[german@]{latesthyphen}[false]{}
+% Option defunc'ed, as bot XeTeX and LuaTeX meanwhile
+% use the experimental German hyphenation patterns by default.
+\define at boolkey{german}[german@]{latesthyphen}[true]{}
 
 \define at boolkey{german}[german@]{babelshorthands}[true]{}
 
-\setkeys{german}{spelling,latesthyphen,script,variant}
+\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}
+% Register alias options
+\xpg at set@alias at values{german}{spelling}{new}{1996}
+\xpg at set@alias at values{german}{spelling}{old}{1901}
+\xpg at set@alias at values{german}{script}{blackletter}{fraktur}
+
 \ifsystem at babelshorthands
   \setkeys{german}{babelshorthands=true}
 \else
@@ -5890,26 +8047,23 @@
 }
 
 \def\german at language{%
-  \ifgerman at latesthyphen
-    \if at german@oldspelling
-        \if at swiss@locale
-            \polyglossia at setup@language at patterns{swissgerman}%
-        \else
-            \polyglossia at setup@language at patterns{german-x-latest}%
-        \fi
-    \else
-        \polyglossia at setup@language at patterns{ngerman-x-latest}%
-    \fi
-  \else% (latesthyphen=false)
-    \if at german@oldspelling
-        \if at swiss@locale
-            \polyglossia at setup@language at patterns{swissgerman}%
-        \else
-            \polyglossia at setup@language at patterns{german}%
-        \fi
-    \else
-        \polyglossia at setup@language at patterns{ngerman}%
-    \fi
+  \if at german@oldspelling
+      \if at swiss@locale
+          \polyglossia at setup@language at patterns{swissgerman}%
+      \else
+          \polyglossia at setup@language at patterns{german}%
+      \fi
+      \if at austrian@locale
+         \adddialect\l at austrian\l at german%
+      \fi
+  \else
+      \polyglossia at setup@language at patterns{ngerman}%
+      \if at austrian@locale
+         \adddialect\l at naustrian\l at ngerman%
+      \fi
+      \if at swiss@locale
+         \adddialect\l at nswissgerman\l at ngerman%
+      \fi
   \fi
 }
 
@@ -5943,6 +8097,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-germanb.ldf>
+%<*gloss-gl.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-gl.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-gl.ldf}[polyglossia: module for gl (galician)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{galician}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-gl.ldf>
+%<*gloss-grc.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-grc.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-grc.ldf}[polyglossia: module for grc (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-grc.ldf>
 %<*gloss-greek.ldf>
 % \fi
 % \clearpage
@@ -5952,6 +8136,7 @@
 \ProvidesFile{gloss-greek.ldf}[polyglossia: module for greek]
 
 \PolyglossiaSetup{greek}{
+  bcp47=el-monoton,
   script=Greek,
   scripttag=grek,
   langtag=ELL,
@@ -5963,6 +8148,12 @@
   %TODO localalph={greek at alph,greek at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=ancient]{greek}{grc}
+\setlanguagealias*[varant=polytonic]{greek}{el-polyton}
+\setlanguagealias*[variant=monotonic]{greek}{el-monoton}
+\setlanguagealias*{greek}{el}
+
 % Babel aliases
 \setlanguagealias[variant=polytonic]{greek}{polutonikogreek}
 
@@ -5999,7 +8190,7 @@
     \def\greek at variant{polygreek}%
     \def\captionsgreek{\polygreekcaptions}%
     \def\dategreek{\datepolygreek}%
-    \SetLanguageKeys{greek}{babelname=polutonikogreek}%
+    \SetLanguageKeys{greek}{babelname=polutonikogreek,bcp47=el-polyton}%
     \xpg at info{Option: Polytonic Greek}%
   \else
     \ifx\@tmpa\tmp at ancient
@@ -6010,6 +8201,7 @@
       \def\greek at variant{ancientgreek}%
       \def\captionsgreek{\ancientgreekcaptions}%
       \def\dategreek{\dateancientgreek}%
+      \SetLanguageKeys{greek}{babelname=greek,bcp47=grc}%
       \xpg at info{Option: Ancient Greek}%
     \else %monotonic
       \xpg at ifdefined{monogreek}{}%
@@ -6019,12 +8211,13 @@
       \def\greek at variant{monogreek}% monotonic
       \def\captionsgreek{\monogreekcaptions}%
       \def\dategreek{\datemonogreek}%
+      \SetLanguageKeys{greek}{babelname=greek,bcp47=el-monoton}%
       \xpg at info{Option: Monotonic Greek}%
     \fi
   \fi}
 
 \def\greek at language{%
-  \polyglossia at setup@language at patterns{\greek at variant}
+  \polyglossia at setup@language at patterns{\greek at variant}%
 }
 
 
@@ -6035,8 +8228,11 @@
 
 \define at boolkey{greek}{attic}[true]{\xpg at warning{Greek option `attic' is no longer required.}}
 
-% This sets the defaults
-\setkeys{greek}{numerals,variant}
+% Register default options
+\xpg at initialize@gloss at options{greek}{variant=monotonic,numerals=greek}
+% Register alias options
+\xpg at set@alias at values{greek}{variant}{monotonic}{mono}
+\xpg at set@alias at values{greek}{variant}{polytonic}{poly}
 
 \def\monogreekcaptions{%
    \def\refname{Αναφορές}%
@@ -6347,6 +8543,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-greek.ldf>
+%<*gloss-he.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-he.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-he.ldf}[polyglossia: module for he (hebrew)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hebrew}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-he.ldf>
 %<*gloss-hebrew.ldf>
 % \fi
 % \clearpage
@@ -6364,6 +8575,7 @@
 \RequirePackage{hebrewcal}
 
 \PolyglossiaSetup{hebrew}{
+  bcp47=he,
   script=Hebrew,
   direction=RL,
   scripttag=hebr,
@@ -6375,6 +8587,9 @@
   %digits = hebrewnumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hebrew}{he}
+
 \newif\if at calendar@hebrew
 \def\tmp at hebrew{hebrew}
 \define at key{hebrew}{calendar}[gregorian]{%
@@ -6405,6 +8620,9 @@
 
 \setkeys{hebrew}{numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{hebrew}{numerals=arabic,calendar=gregorian,marcheshvan=false}
+
 \def\captionshebrew{%
   \def\prefacename{מבוא}%
   \def\refname{מקורות}%
@@ -6459,19 +8677,45 @@
    \fi
 }
 
+% Bidi inserts an RTL mark (0x200f) before any number, forcing numbers to
+% RTL. Hebrew uses LTR numbers, though. So we insert an LTR mark to revert
+% the directionality
+\ifxetex
+  \newcommand\xpg at hebrew@DigitsDotDashInterCharToks{\if at nonlatin\char"200E \fi}
+\fi
+
+\def\hebrew at ltr@numbers{%
+    \ifxetex
+      \XeTeXinterchartoks \bidi at sepmark@charclass  \bidi at digits@charclass = {\xpg at hebrew@DigitsDotDashInterCharToks}
+    \fi%
+}
+
+\def\nohebrew at ltr@numbers{%
+    \ifxetex
+      % This is bidi's original intervention
+      \XeTeXinterchartoks \bidi at sepmark@charclass  \bidi at digits@charclass = {\DigitsDotDashInterCharToks}
+    \fi%
+}
+
 \def\hebrew at numbers{%
    \let\@alph\hebrewnumeral%
    \let\@Alph\Hebrewnumeral%
+   % Prevent bidi from setting the numbers RTL
+   \hebrew at ltr@numbers%
 }
 
 \def\nohebrew at numbers{%
   \let\@alph\latin at alph%
   \let\@Alph\latin at Alph%
+  % Restore previous bidi numbers definition
+  \nohebrew at ltr@numbers
 }
 
 \def\hebrew at globalnumbers{%
    \let\@arabic\hebrewnumber%
    \renewcommand\thefootnote{\localnumeral*{footnote}}%
+   % Prevent bidi from setting the numbers RTL
+   \hebrew at ltr@numbers%
 }
 
 % Store original definition
@@ -6496,6 +8740,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-hebrew.ldf>
+%<*gloss-hi.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-hi.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-hi.ldf}[polyglossia: module for hi (hindi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hindi}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-hi.ldf>
 %<*gloss-hindi.ldf>
 % \fi
 % \clearpage
@@ -6510,6 +8769,7 @@
 \ProvidesFile{gloss-hindi.ldf}[polyglossia: module for hindi]
 \RequirePackage{devanagaridigits}
 \PolyglossiaSetup{hindi}{
+  bcp47=hi,
   script=Devanagari,
   scripttag=deva,
   langtag=HIN,
@@ -6519,6 +8779,9 @@
   %TODO nouppercase=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hindi}{hi}
+
 \ifx\l at hindi\@undefined%
   \ifx\l at sanskrit\@undefined%
     \xpg at nopatterns{Hindi}%
@@ -6542,8 +8805,12 @@
   \def\@tmpa{#1}%
   \ifx\@tmpa\tmp at western
     \hindi at devanagari@numeralsfalse
-  \fi}
+  \fi%
+}
 
+% Register default options
+\xpg at initialize@gloss at options{hindi}{numerals=Devanagari}
+
 \newcommand{\hindinumerals}[2]{\hindinumber{#2}}
 
 \def\hindinumber#1{%
@@ -6611,6 +8878,51 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-hindi.ldf>
+%<*gloss-hr.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-hr.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-hr.ldf}[polyglossia: module for hr (croatian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{croatian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-hr.ldf>
+%<*gloss-hsb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-hsb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-hsb.ldf}[polyglossia: module for hsb (sorbian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{sorbian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-hsb.ldf>
+%<*gloss-hu.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-hu.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-hu.ldf}[polyglossia: module for hu (hungarian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hungarian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-hu.ldf>
 %<*gloss-hungarian.ldf>
 % \fi
 % \clearpage
@@ -6620,6 +8932,7 @@
 \ProvidesFile{gloss-hungarian.ldf}[polyglossia: module for hungarian]
 
 \PolyglossiaSetup{hungarian}{
+  bcp47=hu,
   babelname=magyar,
   hyphennames={hungarian,magyar},
   langtag=HUN,
@@ -6627,6 +8940,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hungarian}{hu}
+
 \frenchspacing
 
 % Babel and backwards compat. alias
@@ -6670,8 +8986,14 @@
    \xpg at info{Option: Hungarian, swapstrings=\val}%
 }{\xpg at warning{Unknown Hungarian swapstrings value `#1'}}
 
-\setkeys{hungarian}{swapstrings}
+% Register default options
+\xpg at initialize@gloss at options{hungarian}{swapstrings=all}
 
+\def\hungarian at language{%
+   \polyglossia at setup@language at patterns{hungarian}%
+   \xpg at ifdefined{hungarian}{\adddialect\l at magyar\l at hungarian}{}%
+}%
+
 \def\captionshungarian{%
    \def\refname{Hivatkozások}%
    \def\abstractname{Kivonat}%
@@ -6741,8 +9063,8 @@
   % change chapter and part headings
   \if at hungarian@swapheadings
      % With titlesec
-     \ifdefined\titleformat%
-       \ifdefined\@part%
+     \ifcsdef{titleformat}{%
+       \ifcsdef{@part}{%
           \let\xpg at save@part at format\@part%
           \patchcmd{\@part}%
                     {\partname\nobreakspace\thepart}%
@@ -6749,44 +9071,44 @@
                     {\thepart.\nobreakspace\partname}%
                     {}%
                     {\xpg at warning{Failed to patch part for Hungarian}}%
-       \fi%
-       \ifdefined\chapter%
+       }{}%
+       \ifcsdef{chapter}{%
           \titleformat\chapter[display]%
              {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}
              {\thechapter.\space\@chapapp}{.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}{\thepart.~\partname}%
-          \fi%
-          \ifdefined\chapterformat%
+          }{}%
+          \ifcsdef{chapterformat}{%
             \let\xpg at save@chap at format\chapterformat%
             \renewcommand{\chapterformat}{\mbox{\thechapter\autodot%
                                           \IfUsePrefixLine{\nobreakspace\chapapp}{\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}%
                        {\printchapternum.\chapternamenum\printchaptername}%
                        {}%
                        {\xpg at warning{Failed to patch chapter for Hungarian}}%
-           \fi%
-           \ifdefined\@part%
+           }{}%
+           \ifcsdef{@part}{%
               \let\xpg at save@part at format\@part%
               \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                                {\printpartnum.\partnamenum\printpartname}%
                                {}%
                                {\xpg at warning{Failed to patch part for Hungarian}}%
-           \fi%
-         \else%  (not \ifdefined\@memptsize)
+           }{}%
+         }{%  (not \ifdefined\@memptsize)
            % With standard classes
-            \ifdefined\@makechapterhead%
+            \ifcsdef{@makechapterhead}{%
               \let\xpg at save@chap at format\@makechapterhead%
               \patchcmd{\@makechapterhead}%
                        {\@chapapp\space \thechapter}%
@@ -6793,8 +9115,8 @@
                        {\thechapter.\space \@chapapp}%
                        {}%
                        {\xpg at warning{Failed to patch chapter for Hungarian}}%
-            \fi%
-            \ifdefined\@part%
+            }{}%
+            \ifcsdef{@part}{%
               \let\xpg at save@part at format\@part%
               \patchcmd{\@part}%
                        {\partname\nobreakspace\thepart}%
@@ -6801,21 +9123,21 @@
                        {\thepart.\nobreakspace\partname}%
                        {}%
                        {\xpg at warning{Failed to patch part for Hungarian}}%
-            \fi%  (end \ifdefined\@part)
-          \fi% (end \ifdefined\@memptsize)
-        \fi% (end \ifdefined\sectionformat)
-     \fi% (end \ifdefined\titleformat)
+            }{}%  (end \ifdefined\@part)
+          }% (end \ifdefined\@memptsize)
+        }% (end \ifdefined\sectionformat)
+     }% (end \ifdefined\titleformat)
   \fi% (end \if at hungarian@swapheadings)
   %
   % Change running headers
   \if at hungarian@swapheaders
-    \ifdefined\chapterformat%
+    \ifcsdef{chapterformat}{%
       % With KOMA
       \let\xpg at save@chaptermark at format\chaptermarkformat%
       \renewcommand*\chaptermarkformat{%
          \thechapter\autodot\ \IfChapterUsesPrefixLine{\chapapp\enskip}{}}
-    \else% (not \ifdefined\chapterformat)
-      \ifdefined\@memptsize%
+    }{% (not \ifdefined\chapterformat)
+      \ifcsdef{@memptsize}{%
         % With memoir
         \let\xpg at save@chaptermark at format\chaptermark%
         \renewcommand*\chaptermark[1]{%
@@ -6826,18 +9148,21 @@
               \fi
             \fi
             ##1}}{}}%
-      \else% (not \ifdefined\@memptsize)
+      }{% (not \ifdefined\@memptsize)
         % With standard classes
-        \ifdefined\chaptermark%
-           \let\xpg at save@chaptermark at format\chaptermark%
-           \patchcmd{\chaptermark}%
+        \ifcsdef{chaptermark}{%
+          \ifpatchable{\chaptermark}%
+               {\@chapapp\ \thechapter.}%
+               {\let\xpg at save@chaptermark at format\chaptermark%
+                \patchcmd{\chaptermark}%
                     {\@chapapp\ \thechapter.}%
                     {\thechapter.\ \@chapapp}%
                     {}%
-                    {\xpg at warning{Failed to patch chaptermark for Hungarian}}%
-        \fi% (end \ifdefined\chaptermark)
-      \fi% (end \ifdefined\@memptsize)
-    \fi% (end \ifdefined\chapterformat)
+                    {\xpg at warning{Failed to patch chaptermark for Hungarian}}}%
+               {}%
+        }{}% (end \ifdefined\chaptermark)
+      }% (end \ifdefined\@memptsize)
+    }% (end \ifdefined\chapterformat)
   \fi% (end \if at hungarian@swapheaders)
 }
 
@@ -6848,50 +9173,50 @@
    \let\fnum at figure\xpg at save@fnum at figure%
    %
    % Reset chapter and part heading
-   \ifdefined\titleformat%
+   \ifcsdef{titleformat}{%
       % With titlesec
-     \ifdefined\xpg at save@part at format
+     \ifcsdef{xpg at save@part at format}{%
         \let\@part\xpg at save@part at format
-     \fi%
-     \ifdefined\chapter
+     }{}%
+     \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
+        \ifcsdef{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@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\blockextras at hungarian{%
@@ -6906,6 +9231,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-hungarian.ldf>
+%<*gloss-hy.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-hy.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-hy.ldf}[polyglossia: module for hy (armenian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{armenian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-hy.ldf>
+%<*gloss-ia.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ia.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ia.ldf}[polyglossia: module for ia (interlingua)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{interlingua}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ia.ldf>
 %<*gloss-icelandic.ldf>
 % \fi
 % \clearpage
@@ -6914,6 +9269,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-icelandic.ldf}[polyglossia: module for icelandic]
 \PolyglossiaSetup{icelandic}{
+  bcp47=is,
   hyphennames={icelandic},
   hyphenmins={2,2},
   langtag=ISL,
@@ -6920,6 +9276,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{icelandic}{is}
+
 \def\captionsicelandic{%
    \def\refname{Heimildir}%
    \def\abstractname{Útdráttur}%
@@ -6956,6 +9315,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-icelandic.ldf>
+%<*gloss-id.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-id.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-id.ldf}[polyglossia: module for id (malay)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{malay}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-id.ldf>
 %<*gloss-interlingua.ldf>
 % \fi
 % \clearpage
@@ -6964,6 +9338,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-interlingua.ldf}[polyglossia: module for interlingua]
 \PolyglossiaSetup{interlingua}{
+  bcp47=ia,
   hyphennames={interlingua},
   hyphenmins={2,2},
   langtag=INA,
@@ -6972,6 +9347,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{interlingua}{ia}
+
 \def\captionsinterlingua{%
    \def\refname{Referentias}%
    \def\abstractname{Summario}%
@@ -7022,6 +9400,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-irish.ldf>
+%<*gloss-is.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-is.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-is.ldf}[polyglossia: module for is (icelandic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{icelandic}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-is.ldf>
+%<*gloss-it.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-it.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-it.ldf}[polyglossia: module for it (italian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{italian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-it.ldf>
 %<*gloss-italian.ldf>
 % \fi
 % \clearpage
@@ -7031,6 +9439,7 @@
 % !TEX encoding = UTF-8 Unicode
 \ProvidesFile{gloss-italian.ldf}[polyglossia: module for italian]
 \PolyglossiaSetup{italian}{
+  bcp47=it,
   hyphennames={italian},
   hyphenmins={2,2},
   langtag=ITA,
@@ -7039,10 +9448,16 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{italian}{it}
 
+
 %%% CHANGES START %%% by Enrico Gregorio
 \define at boolkey{italian}[italian@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{italian}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{italian}{babelshorthands=true}
 \else
@@ -7163,6 +9578,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-italian.ldf>
+%<*gloss-ja.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ja.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ja.ldf}[polyglossia: module for ja (japanese)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{japanese}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ja.ldf>
 %<*gloss-japanese.ldf>
 % \fi
 % \clearpage
@@ -7170,21 +9600,27 @@
 % \subsection{gloss-japanese.ldf}
 %    \begin{macrocode}
 \ProvidesFile{gloss-japanese.ldf}[polyglossia: module for japanese]
+
 \PolyglossiaSetup{japanese}{
+	bcp47=ja,
 	script=CJK,
 	language=Japanese,
 	langtag=JAN,
 	hyphennames={nohyphenation},
 	frenchspacing=false,
-	fontsetup=true
+	fontsetup=true,
+	localnumeral=japanesenumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{japanese}{ja}
+
 \def\japanese at capsformat{%
 	\def\@seccntformat##1{%
 		\csname pre##1\endcsname%
 		\csname the##1\endcsname%
 		\csname post##1\endcsname%
-	}
+	}%
 	\def\postsection{節\space}%
 	\def\postsubsection{節\space}%
 	\def\postsubsubsection{節\space}%
@@ -7224,33 +9660,33 @@
 \newif\if at IzumoTuki \@IzumoTukifalse%
 \newcount\c at TempJNum%
 
-\def\@JapaneseDigit#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 五十七\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 九十九
+\def\@JapaneseDigit#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 五十七\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
-		\@ctrerr
-	\fi\relax
+		\@ctrerr%
+	\fi\relax%
 }
 
-\def\@JapaneseNum#1{
+\def\@JapaneseNum#1{%
 	\c at TempJNum=#1\divide\c at TempJNum by 1000\relax%
 	\ifnum\c at TempJNum=\z@\c at TempJNum=#1%
 		\divide\c at TempJNum by 100\relax%
@@ -7260,7 +9696,7 @@
 				六百\or 七百\or 八百\or 九百%
 			\fi
 			\c at TempJNum=#1\divide\c at TempJNum by 100\multiply\c at TempJNum by -100\advance\c at TempJNum#1\@JapaneseDigit\c at TempJNum\relax%
-		\fi
+		\fi%
 	\else
 		\ifcase\c at TempJNum\or 千\or 二千\or 三千\or 四千\or 五千\or
 			六千\or 七千\or 八千\or 九千%
@@ -7277,7 +9713,7 @@
 	\fi
 }
 
-\def\@japanesenumber#1{
+\def\@japanesenumber#1{%
 	\@tempcnta=#1%
 	\ifnum\@tempcnta=\z@{〇}%
 	\else
@@ -7310,12 +9746,14 @@
 	\fi
 }
 
-\def\japanesenumber#1{
+\def\japanesenumber#1{%
 	\expandafter\@japanesenumber\csname c@#1\endcsname%
 }
 
-\def\datejapanese{
-	{
+\newcommand{\japanesenumerals}[2]{\@japanesenumber{#2}}
+
+\def\datejapanese{%
+	{%
 		\ifnum\year<1868%
 			\xdef\the at WarekiCur{}%
 		\else
@@ -7334,7 +9772,7 @@
 			\fi
 		\fi
 		\xdef\the at WameiTosi{\the\year}%
-	}
+	}%
 	\def\西暦{\@WameiRekifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\和暦{\@WameiRekitrue \@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\和名暦{\@WameiTositrue \@WameiTukitrue \@WameiHitrue}%
@@ -7341,7 +9779,7 @@
 	\def\数字暦{\@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\出雲月{\@IzumoTukitrue}%
 	\def\大和月{\@IzumoTukifalse}%
-	\def\today{
+	\def\today{%
 		\if at WameiReki%
 			\the at WarekiCur%
 			\if at WameiTosi%
@@ -7368,8 +9806,8 @@
 		\else
 			\,\number\day\,%
 		\fi
-		{日}
-	}
+		{日}%
+	}%
 }
 
 \def\noextras at japanese{%
@@ -7388,6 +9826,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-japanese.ldf>
+%<*gloss-ka.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ka.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ka.ldf}[polyglossia: module for ka (georgian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{georgian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ka.ldf>
 %<*gloss-kannada.ldf>
 % \fi
 % \clearpage
@@ -7420,6 +9873,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{kannada}{
+  bcp47=kn,
   script=Kannada,
   scripttag=knda,
   langtag=KAN,
@@ -7429,6 +9883,9 @@
   localnumeral=kannadanumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{kannada}{kn}
+
 %% Defining Kannada digits equivalents to english
 \def\kannadadigits#1{\expandafter\@kannada at digits #1@}
 \def\@kannada at digits#1{%
@@ -7514,166 +9971,257 @@
 % 
 % \subsection{gloss-khmer.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-khmer.ldf}[polyglossia: module for Khmer]
-\PolyglossiaSetup{khmer}{
-	script=Khmer,%
-	scripttag=khmr,%
-	langtag=KHM,%
-	hyphennames={nohyphenation},%
-	fontsetup=true,%
-	localnumeral=khmernumerals%
-}
-\newif\if at khmer@numerals
-\def\tmp at khmer{khmer}
-\define at key{khmer}{numerals}[arabic]{%
-	\def\@tmpa{#1}%
-	\ifx\@tmpa\tmp at khmer\@khmer at numeralstrue%
-	\else\@khmer at numeralsfalse\fi%
-}
-\setkeys{khmer}{numerals}
-\def\captionskhmer{%
-	\def\prefacename{អារម្ភកថា}%
-	\def\refname{ឯកសារយោង}%
-	\def\abstractname{សង្ខេប}%
-	\def\bibname{គន្ថនិទ្ទេស}%
-	\def\chaptername{ជំពូក}%
-	\def\appendixname{សេចក្ដីបន្ថែម}%
-	\def\contentsname{មាតិការ}%
-	\def\listfigurename{បញ្ជីរូបភាព}%
-	\def\listtablename{បញ្ជីតារាង}%
-	\def\indexname{សន្ទស្សន៍}%
-	\def\figurename{រូប}%
-	\def\tablename{តារាង}%
-	\def\partname{ផ្នែក}%
-	\def\pagename{ទំព័រ}%
-	\def\seename{មើល}%
-	\def\alsoname{មើលបន្ថែម}%
-	\def\enclname{ឯកសារភ្ជាប់}%
-	\def\ccname{ចម្លងជួន}%
-	\def\headtoname{ផ្ញើរទៅ}%
-	\def\proofname{សម្រាយ}%
-	\def\glossaryname{សទានុក្រម}%
-}
-\def\datekhmer{%
-	\def\khmer at month{%
-		\ifcase\month\or%
-		មករា\or%
-		កុម្ភៈ\or%
-		មិនា\or%
-		មេសា\or%
-		ឧសភា\or%
-		មិថុនា\or%
-		កក្កដា\or%
-		សីហា\or%
-		កញ្ញា\or%
-		តុលា\or%
-		វិច្ឆិកា\or%
-		ធ្នូ\fi}%
-	\def\today{\khmernumber\day\space\khmer at month\space\khmernumber\year}%
-}
-\def\khmerdigits#1{\expandafter\@khmer at digits #1@}
-\def\@khmer at digits#1{%
-	\ifx @#1% then terminate
-	\else\ifx0#1០%
-	\else\ifx1#1១%
-	\else\ifx2#1២%
-	\else\ifx3#1៣%
-	\else\ifx4#1៤%
-	\else\ifx5#1៥%
-	\else\ifx6#1៦%
-	\else\ifx7#1៧%
-	\else\ifx8#1៨%
-	\else\ifx9#1៩%
-	\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
-    \expandafter\@khmer at digits%
-    \fi
-}
-
-\newcommand{\khmernumerals}[2]{\khmernumber{#2}}
-
-\def\khmernumber#1{%
-	\if at khmer@numerals%
-		\khmerdigits{\number#1}%
-	\else%
-		\number#1%
-	\fi}
-\def\khmer at globalnumbers{%
-	\let\orig at arabic\@arabic%
-	\let\@arabic\khmernumber%
-	\renewcommand{\thefootnote}{\localnumeral*{footnote}}%
-}
-\def\nokhmer at globalnumbers{%
-	\let\@arabic\orig at arabic%
-}
-\def\thepart{\arabic{part}}
-\def\@khmeralph#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 អ%
-\else\xpg at ill@value{#1}{@khmeralph}\fi}
-\def\khmerAlph#1{\expandafter\@khmerAlph\csname c@#1\endcsname}
-\def\@khmerAlph#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 អ%
-\else\xpg at ill@value{#1}{@khmeralph}\fi}
-\def\khmer at numbers{%
-	\if at khmer@numerals
-		\let\@alph\@khmeralph%
-		\let\@Alph\@khmerAlph%
-	\fi%
-}
-\def\nokhmer at numbers{%
-	\let\@alph\latin at alph%
-	\let\@Alph\latin at Alph%
-}
-\def\blockextras at khmer{%
-	\XeTeXlinebreaklocale "kh" % 
-	\XeTeXlinebreakskip = 0pt plus 1pt minus 1pt
-%	\let\orig at baselinestretch\baselinestretch%
-%	\renewcommand{\baselinestretch}{1.2}% not work
-}
-\def\noblockextras at khmer{% 
-	\XeTeXlinebreaklocale "en"%
-%	\let\baselinestretch\orig at baselinestretch%
-}
-\@ifclassloaded{beamer}{%
-	\usefonttheme{professionalfonts}%
-	\def\factname{ស្វ័យសត្យ}%
-	\def\lemmaname{បទគន្លិះ}%
-	\def\theoremname{ទ្រឹស្ដីបទ}%
-	\def\corollaryname{អនុសាធ្យ}%
-	\def\problemname{ចំណោទ}%
-	\def\solutionname{ដំណោះស្រាយ}%
-	\def\definitionname{និយមន័យ}%
-	\def\examplename{ឧទាហរណ៏}%
-	\uselanguage{khmer}%
-	\languagepath{khmer}%
-	\deftranslation[to=khmer]{Fact}{\factname}%
-	\deftranslation[to=khmer]{Lemma}{\lemmaname}%
-	\deftranslation[to=khmer]{Theorem}{\theoremname}%
-	\deftranslation[to=khmer]{Corollary}{\corollaryname}%
-	\deftranslation[to=khmer]{Problem}{\problemname}%
-	\deftranslation[to=khmer]{Solution}{\solutionname}%
-	\deftranslation[to=khmer]{Definition}{\definitionname}%
-	\deftranslation[to=khmer]{Definitions}{\definitionname}%
-	\deftranslation[to=khmer]{Example}{\examplename}%
-	\deftranslation[to=khmer]{Examples}{\examplename}%
-	\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
-		{\noexpand\headcommand{\noexpand\def\noexpand%
-		\inserttotalframenumber{\localnumeral*{framenumber}}}}}}%
-}{}
+\ProvidesFile{gloss-khmer.ldf}[polyglossia: module for Khmer]
+\PolyglossiaSetup{khmer}{
+  bcp47=km,
+	script=Khmer,%
+	scripttag=khmr,%
+	langtag=KHM,%
+	hyphennames={nohyphenation},%
+	fontsetup=true,%
+	localnumeral=khmernumerals%
+}
+\newif\if at khmer@numerals
+\def\tmp at khmer{khmer}
+\define at key{khmer}{numerals}[arabic]{%
+	\def\@tmpa{#1}%
+	\ifx\@tmpa\tmp at khmer\@khmer at numeralstrue%
+	\else\@khmer at numeralsfalse\fi%
+}
+\setkeys{khmer}{numerals}
+\def\captionskhmer{%
+	\def\prefacename{អារម្ភកថា}%
+	\def\refname{ឯកសារយោង}%
+	\def\abstractname{សង្ខេប}%
+	\def\bibname{គន្ថនិទ្ទេស}%
+	\def\chaptername{ជំពូក}%
+	\def\appendixname{សេចក្ដីបន្ថែម}%
+	\def\contentsname{មាតិការ}%
+	\def\listfigurename{បញ្ជីរូបភាព}%
+	\def\listtablename{បញ្ជីតារាង}%
+	\def\indexname{សន្ទស្សន៍}%
+	\def\figurename{រូប}%
+	\def\tablename{តារាង}%
+	\def\partname{ផ្នែក}%
+	\def\pagename{ទំព័រ}%
+	\def\seename{មើល}%
+	\def\alsoname{មើលបន្ថែម}%
+	\def\enclname{ឯកសារភ្ជាប់}%
+	\def\ccname{ចម្លងជួន}%
+	\def\headtoname{ផ្ញើរទៅ}%
+	\def\proofname{សម្រាយ}%
+	\def\glossaryname{សទានុក្រម}%
+}
+\def\datekhmer{%
+	\def\khmer at month{%
+		\ifcase\month\or%
+		មករា\or%
+		កុម្ភៈ\or%
+		មិនា\or%
+		មេសា\or%
+		ឧសភា\or%
+		មិថុនា\or%
+		កក្កដា\or%
+		សីហា\or%
+		កញ្ញា\or%
+		តុលា\or%
+		វិច្ឆិកា\or%
+		ធ្នូ\fi}%
+	\def\today{\khmernumber\day\space\khmer at month\space\khmernumber\year}%
+}
+\def\khmerdigits#1{\expandafter\@khmer at digits #1@}
+\def\@khmer at digits#1{%
+	\ifx @#1% then terminate
+	\else\ifx0#1០%
+	\else\ifx1#1១%
+	\else\ifx2#1២%
+	\else\ifx3#1៣%
+	\else\ifx4#1៤%
+	\else\ifx5#1៥%
+	\else\ifx6#1៦%
+	\else\ifx7#1៧%
+	\else\ifx8#1៨%
+	\else\ifx9#1៩%
+	\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
+    \expandafter\@khmer at digits%
+    \fi
+}
+
+\newcommand{\khmernumerals}[2]{\khmernumber{#2}}
+
+\def\khmernumber#1{%
+	\if at khmer@numerals%
+		\khmerdigits{\number#1}%
+	\else%
+		\number#1%
+	\fi}
+\def\khmer at globalnumbers{%
+	\let\orig at arabic\@arabic%
+	\let\@arabic\khmernumber%
+	\renewcommand{\thefootnote}{\localnumeral*{footnote}}%
+}
+\def\nokhmer at globalnumbers{%
+	\let\@arabic\orig at arabic%
+}
+\def\thepart{\arabic{part}}
+\def\@khmeralph#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 អ%
+\else\xpg at ill@value{#1}{@khmeralph}\fi}
+\def\khmerAlph#1{\expandafter\@khmerAlph\csname c@#1\endcsname}
+\def\@khmerAlph#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 អ%
+\else\xpg at ill@value{#1}{@khmeralph}\fi}
+\def\khmer at numbers{%
+	\if at khmer@numerals
+		\let\@alph\@khmeralph%
+		\let\@Alph\@khmerAlph%
+	\fi%
+}
+\def\nokhmer at numbers{%
+	\let\@alph\latin at alph%
+	\let\@Alph\latin at Alph%
+}
+\def\blockextras at khmer{%
+	\XeTeXlinebreaklocale "kh" % 
+	\XeTeXlinebreakskip = 0pt plus 1pt minus 1pt
+%	\let\orig at baselinestretch\baselinestretch%
+%	\renewcommand{\baselinestretch}{1.2}% not work
+}
+\def\noblockextras at khmer{% 
+	\XeTeXlinebreaklocale "en"%
+%	\let\baselinestretch\orig at baselinestretch%
+}
+\@ifclassloaded{beamer}{%
+	\usefonttheme{professionalfonts}%
+	\def\factname{ស្វ័យសត្យ}%
+	\def\lemmaname{បទគន្លិះ}%
+	\def\theoremname{ទ្រឹស្ដីបទ}%
+	\def\corollaryname{អនុសាធ្យ}%
+	\def\problemname{ចំណោទ}%
+	\def\solutionname{ដំណោះស្រាយ}%
+	\def\definitionname{និយមន័យ}%
+	\def\examplename{ឧទាហរណ៏}%
+	\uselanguage{khmer}%
+	\languagepath{khmer}%
+	\deftranslation[to=khmer]{Fact}{\factname}%
+	\deftranslation[to=khmer]{Lemma}{\lemmaname}%
+	\deftranslation[to=khmer]{Theorem}{\theoremname}%
+	\deftranslation[to=khmer]{Corollary}{\corollaryname}%
+	\deftranslation[to=khmer]{Problem}{\problemname}%
+	\deftranslation[to=khmer]{Solution}{\solutionname}%
+	\deftranslation[to=khmer]{Definition}{\definitionname}%
+	\deftranslation[to=khmer]{Definitions}{\definitionname}%
+	\deftranslation[to=khmer]{Example}{\examplename}%
+	\deftranslation[to=khmer]{Examples}{\examplename}%
+	\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
+		{\noexpand\headcommand{\noexpand\def\noexpand%
+		\inserttotalframenumber{\localnumeral*{framenumber}}}}}}%
+}{}
 %    \end{macrocode}
 % \iffalse
 %</gloss-khmer.ldf>
+%<*gloss-km.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-km.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-km.ldf}[polyglossia: module for km (khmer)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{khmer}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-km.ldf>
+%<*gloss-kmr-Arab.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-kmr-Arab.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-kmr-Arab.ldf}[polyglossia: module for kmr-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-kmr-Arab.ldf>
+%<*gloss-kmr-Latn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-kmr-Latn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-kmr-Latn.ldf}[polyglossia: module for kmr-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-kmr-Latn.ldf>
+%<*gloss-kmr.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-kmr.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-kmr.ldf}[polyglossia: module for kmr (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-kmr.ldf>
+%<*gloss-kn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-kn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-kn.ldf}[polyglossia: module for kn (kannada)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kannada}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-kn.ldf>
+%<*gloss-ko.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ko.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ko.ldf}[polyglossia: module for ko (korean)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{korean}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ko.ldf>
 %<*gloss-korean.ldf>
 % \fi
 % \clearpage
@@ -7683,6 +10231,7 @@
 \ProvidesFile{gloss-korean.ldf}[polyglossia: module for Korean]
 
 \PolyglossiaSetup{korean}{
+  bcp47=ko,
     script=Hangul,
     scripttag=hang,
     language=Korean,
@@ -7692,6 +10241,9 @@
     fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{korean}{ko}
+
 % variant : plain (0), classic (1), or modern (2)
 \define at choicekey{korean}{variant}[\val\nr]{plain,classic,modern}[plain]{%
     \let\xpg at korean@variant\nr
@@ -7700,8 +10252,33 @@
 \define at choicekey{korean}{captions}[\val\nr]{hangul,hanja}[hangul]{%
     \let\xpg at korean@captions\nr
 }
-\setkeys{korean}{variant,captions}
+% swapstrings: all (0), headings (1), headers (2), or none (3)
+\newif\if at korean@swapheadings
+\newif\if at korean@swapheaders
+\define at choicekey*+{korean}{swapstrings}[\val\nr]{all,headings,headers,none}[all]{%
+   \ifcase\nr\relax
+      % all:
+      \@korean at swapheadingstrue%
+      \@korean at swapheaderstrue%
+   \or
+      % headings:
+      \@korean at swapheadingstrue%
+      \@korean at swapheadersfalse%
+   \or
+      % headers:
+      \@korean at swapheadingsfalse%
+      \@korean at swapheaderstrue%
+   \or
+      % none:
+      \@korean at swapheadingsfalse%
+      \@korean at swapheadersfalse%
+   \fi
+   \xpg at info{Option: Korean, swapstrings=\val}%
+}{\xpg at warning{Unknown Korean swapstrings value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{korean}{variant=plain,swapstrings=all,captions=hangul}
+
 \def\captionskorean{%
     \ifcase\xpg at korean@captions\relax
         \captions at korean@hangul
@@ -7713,7 +10290,7 @@
 }
 \def\captions at korean@hangul{%
     \def\koreanTHEname{제}%
-    \def\partname##1##2{제##1##2 편}%
+    \def\partname{편}%
     \def\chaptername{장}%
     \def\refname{참고문헌}%
     \def\abstractname{요약}%
@@ -7731,10 +10308,11 @@
     \def\proofname{증명}%
     \def\headtoname{수신:}%
     \def\ccname{사본}%
+    \def\glossaryname{용어집}%
 }
 \def\captions at korean@hanja{%
     \def\koreanTHEname{第}%
-    \def\partname##1##2{第##1##2 篇}%
+    \def\partname{篇}%
     \def\chaptername{章}%
     \def\refname{參考文獻}%
     \def\abstractname{要約}%
@@ -7752,8 +10330,219 @@
     \def\proofname{證明}%
     \def\headtoname{受信:}%
     \def\ccname{寫本}%
+    \def\glossaryname{用語集}%
 }
 
+\def\korean at appendix@chapapp{\appendixname}% to exclude appendix
+
+\def\korean at headingsformat{%
+  % 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}%
+                 {\partname\nobreakspace\thepart}%
+                 {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                 {}%
+                 {\xpg at warning{Failed to patch part for Korean}}%
+      \fi
+      \ifdefined\chapter
+        \titleformat\chapter[display]%
+          {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
+          {%
+            \ifx\@chapapp\korean at appendix@chapapp
+              \appendixname\space \thechapter
+            \else
+              \koreanTHEname\space \thechapter\space \@chapapp
+            \fi
+          }{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
+      \fi
+    \else % (not \ifdefined\titleformat)
+      % With KOMA
+      \ifdefined\sectionformat
+        \ifdefined\partformat
+          \let\xpg at save@part at format\partformat
+          \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
+        \fi
+        \ifdefined\chapterformat
+          \let\xpg at save@chap at format\chapterformat
+          \renewcommand*{\chapterformat}{\mbox{%
+            \IfChapterUsesPrefixLine
+            {%
+              \ifx\@chapapp\korean at appendix@chapapp
+                \chapappifchapterprefix\nobreakspace \thechapter\autodot
+              \else
+                \koreanTHEname\nobreakspace \thechapter\nobreakspace \chapappifchapterprefix{}%
+              \fi
+            }%
+            {\thechapter\autodot\enskip}%
+          }}%
+        \fi
+      \else % (not \ifdefined\sectionformat)
+        % With memoir
+        \ifdefined\@memptsize
+          \ifdefined\@makechapterhead
+            \let\xpg at save@chap at format\@makechapterhead
+            \patchcmd{\@makechapterhead}%
+                     {\printchaptername \chapternamenum \printchapternum}%
+                     {%
+                       \ifx\@chapapp\korean at appendix@chapapp
+                         \printchaptername\relax\chapternamenum \printchapternum
+                       \else
+                         \printkoreanchapterthe \printchapternum\chapternamenum \printchaptername
+                       \fi
+                     }%
+                     {}%
+                     {\xpg at warning{Failed to patch chapter for Korean}}%
+            \ifdefined\printkoreanchapterthe\else
+              \def\printkoreanchapterthe{%
+                \ifpatchable\printchaptername\@chapapp
+                  {\chapnamefont\koreanTHEname\chapternamenum}{}}%
+            \fi
+          \fi
+          \ifdefined\@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
+          \fi
+        \else % (not \ifdefined\@memptsize)
+          % With standard classes
+          \ifdefined\@makechapterhead
+            \let\xpg at save@chap at format\@makechapterhead
+            \patchcmd{\@makechapterhead}%
+                     {\@chapapp\space \thechapter}%
+                     {%
+                       \ifx\@chapapp\korean at appendix@chapapp
+                         \appendixname\space \thechapter
+                       \else
+                         \koreanTHEname\space \thechapter\space \@chapapp
+                       \fi
+                     }%
+                     {}%
+                     {\xpg at warning{Failed to patch chapter for Korean}}%
+          \fi
+          \ifdefined\@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}}%
+          \fi % (end \ifdefined\@part)
+        \fi % (end \ifdefined\@memptsize)
+      \fi % (end \ifdefined\sectionformat)
+    \fi % (end \ifdefined\titleformat)
+  \fi % (end \if at korean@swapheadings)
+  %
+  % Change running headers
+  \if at korean@swapheaders
+    \ifdefined\chapterformat
+      % With KOMA
+      \let\xpg at save@chaptermark at format\chaptermarkformat
+      \renewcommand*\chaptermarkformat{%
+        \IfChapterUsesPrefixLine
+        {%
+          \ifx\@chapapp\korean at appendix@chapapp
+            \chapappifchapterprefix\ \thechapter\autodot
+          \else
+            \koreanTHEname\ \thechapter\ \chapappifchapterprefix{}%
+          \fi
+        }%
+        {\thechapter\autodot}%
+        \enskip
+      }%
+    \else % (not \ifdefined\chapterformat)
+      \ifdefined\@memptsize
+        % With memoir
+        \let\xpg at save@chaptermark at format\chaptermark
+        \patchcmd{\chaptermark}%
+                 {\@chapapp\ \@nameuse{thechapter}}%
+                 {%
+                   \ifx\@chapapp\korean at appendix@chapapp
+                     \appendixname\ \@nameuse{thechapter}%
+                   \else
+                     \koreanTHEname\ \@nameuse{thechapter}\ \@chapapp
+                   \fi
+                 }%
+                 {}%
+                 {}%
+      \else % (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)
+  \fi % (end \if at korean@swapheaders)
+}
+
+\def\nokorean at headingsformat{%
+  % Reset chapter and part heading
+  \ifdefined\titleformat
+    % With titlesec
+    \ifdefined\xpg at save@part at format
+      \let\@part\xpg at save@part at format
+    \fi
+    \ifdefined\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
+      % With KOMA
+      \ifdefined\xpg at save@part at format
+        \let\partformat\xpg at save@part at format
+      \fi
+      \ifdefined\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
+        \let\@makechapterhead\xpg at save@chap at format
+      \fi
+    \fi % (end \ifdefined\sectionformat)
+  \fi % (end \ifdefined\titleformat)
+  %
+  % Reset headers
+  \ifdefined\chaptermarkformat
+    % With KOMA
+    \ifdefined\xpg at save@chaptermark at format
+      \let\chaptermarkformat\xpg at save@chaptermark at format
+    \fi
+  \else
+    \ifdefined\chaptermark
+      % With memoir and standard classes
+      \ifdefined\xpg at save@chaptermark at format
+        \let\chaptermark\xpg at save@chaptermark at format
+      \fi
+    \fi % (end \ifdefined\chaptermark)
+  \fi % (end \ifdefined\chapterformat)
+}
+
 \def\datekorean{%
     \ifcase\xpg at korean@captions\relax
         \def\today{\the\year 년 \the\month 월 \the\day 일}%
@@ -7827,17 +10616,11 @@
 
 \def\blockextras at korean{%
     \inlineextras at korean
-    \ifdefined\@chapapp
-        \long\def\@tmpa{\chaptername}\def\@tmpb{\chaptername}%
-        \ifnum0\ifx\@chapapp\@tmpa1\else\ifx\@chapapp\@tmpb1\fi\fi>\z@
-            \let\xpg at orig@@chapapp\@chapapp
-            \def\@chapapp##1##2{\koreanTHEname ##1##2##1\chaptername}%
-        \fi
-    \fi
+    \korean at headingsformat
 }
 
 \def\noextras at korean@common{%
-    \ifdefined\xpg at orig@@chapapp \let\@chapapp\xpg at orig@@chapapp \fi
+    \nokorean at headingsformat
 }
 
 \ifluatex % luatex
@@ -7871,6 +10654,51 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-korean.ldf>
+%<*gloss-ku-Arab.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ku-Arab.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ku-Arab.ldf}[polyglossia: module for ku-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ku-Arab.ldf>
+%<*gloss-ku-Latn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ku-Latn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ku-Latn.ldf}[polyglossia: module for ku-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ku-Latn.ldf>
+%<*gloss-ku.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ku.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ku.ldf}[polyglossia: module for ku (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ku.ldf>
 %<*gloss-kurdish.ldf>
 % \fi
 % \clearpage
@@ -7887,6 +10715,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{kurdish}{
+  bcp47=ckb,
   script=Arabic,
   direction=RL,
   scripttag=arab,
@@ -7896,6 +10725,17 @@
   localnumeral=kurdishnumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{kurdish}{ku}
+\setlanguagealias*[variant=kurmanji,script=Latin]{kurdish}{kmr-Latn}
+\setlanguagealias*[variant=sorani]{kurdish}{ckb}
+\setlanguagealias*[variant=kurmanji,script=Arabic]{kurdish}{kmr-Arab}
+\setlanguagealias*[script=Latin]{kurdish}{ku-Latn}
+\setlanguagealias*[variant=sorani,script=Arabic]{kurdish}{ckb-Arab}
+\setlanguagealias*[variant=sorani,script=Latin]{kurdish}{ckb-Latn}
+\setlanguagealias*[script=Arabic]{kurdish}{ku-Arab}
+\setlanguagealias*[variant=kurmanji]{kurdish}{kmr}
+
 % Babel aliases
 \setlanguagealias[variant=kurmanji]{kurdish}{kurmanji}
 
@@ -7942,9 +10782,9 @@
      \@western at numeralstrue%
      \if at kurdish@kurmanji
          \def\kurdish at pattern{kurmanji}%
-         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji}%
+         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn}%
      \else
-         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish}%
+         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish,bcp47=ckb-Arab}%
      \fi
      \def\kurdish at script{latin}
      \xpg at fontsetup@latin{kurdish}%
@@ -7952,20 +10792,20 @@
      \if at kurdish@arabic% Arabic explicitly set
         \if at kurdish@kurmanji
             \if at force@western at numerals\else\@western at numeralsfalse\fi%
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurmanji}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurmanji,bcp47=kmr-Arab}%
             \def\kurdish at script{arabic}%
         \else
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab}%
         \fi
         \xpg at fontsetup@nonlatin{kurdish}%
      \else% sorani=Arabic, kurmanji=Latin
         \if at kurdish@kurmanji
             \@western at numeralstrue%
-            \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji}%
+            \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn}%
             \xpg at fontsetup@latin{kurdish}%
             \def\kurdish at script{latin}
         \else
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab}%
             \xpg at fontsetup@nonlatin{kurdish}%
         \fi
      \fi
@@ -7997,7 +10837,8 @@
 
 %TODO add option for CALENDAR
 
-\setkeys{kurdish}{variant,locale}
+% Register default options
+\xpg at initialize@gloss at options{kurdish}{variant=sorani,locale=default,script=Arabic,abjadjimnotail=false,numerals=eastern}
 
 \def\kurdish at language{%
    \polyglossia at setup@language at patterns{\kurdish at pattern}%
@@ -8204,19 +11045,9 @@
   \if at western@numerals
     \number#1%
   \else
-    \ifxetex
-      \ifnum\XeTeXcharglyph"06F0 > 0\relax
-        \farsidigits{\number#1}%
-      \else%
-         \arabicdigits{\number#1}%
-      \fi
-    \else\ifluatex
-      \expandafter\ifnum\directlua{polyglossia.check_char(0x6F0)} > 0\relax
-        \farsidigits{\number#1}%
-      \else%
-         \arabicdigits{\number#1}%
-      \fi
-    \fi\fi
+    \xpg at if@char at available{06F0}%
+          {\farsidigits{\number#1}}%
+          {\arabicdigits{\number#1}}%
   \fi
 }
 
@@ -8266,6 +11097,81 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-kurdish.ldf>
+%<*gloss-kurmanji.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-kurmanji.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-kurmanji.ldf}[polyglossia: module for kurmanji kurdish]
+
+% We provide this gloss for babel compatibility.
+
+\xpg at load@master at language{kurdish}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-kurmanji.ldf>
+%<*gloss-la-x-classic.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-la-x-classic.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-la-xclassic.ldf}[polyglossia: module for la-xclassic (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-la-x-classic.ldf>
+%<*gloss-la-x-ecclesia.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-la-x-ecclesia.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-la-xecclesiastic.ldf}[polyglossia: module for la-xecclesiastic (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-la-x-ecclesia.ldf>
+%<*gloss-la-x-medieval.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-la-x-medieval.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-la-xmedieval.ldf}[polyglossia: module for la-xmedieval (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-la-x-medieval.ldf>
+%<*gloss-la.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-la.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-la.ldf}[polyglossia: module for la (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-la.ldf>
 %<*gloss-lao.ldf>
 % \fi
 % \clearpage
@@ -8280,6 +11186,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{lao}{
+  bcp47=lo,
   script=Lao,
   scripttag=lao,
   langtag=LAO,
@@ -8291,6 +11198,9 @@
   %TODO localdigits=laonumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{lao}{lo}
+
 \newif\if at lao@numerals
 \def\tmp at lao{lao}
 \define at key{lao}{numerals}[arabic]{%
@@ -8299,7 +11209,8 @@
 	  \@lao at numeralsfalse\fi
 }
 
-\setkeys{lao}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{lao}{numerals=arabic}
 
 % Translations provided by Brian Wilson <bountonw at gmail.com>
 \def\captionslao{%
@@ -8420,13 +11331,13 @@
 % 
 % \subsection{gloss-latin.ldf}
 %    \begin{macrocode}
-\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.0 2019-10-28]
+\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.2 2020-01-03]
 
 \ExplSyntaxOn
 
 \PolyglossiaSetup {latin}
   {
-    hyphennames = {latin},
+    bcp47 = la,
     hyphenmins = {2,2},
     frenchspacing = true,
     fontsetup = true,
@@ -8433,10 +11344,16 @@
     langtag = LAT
   }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{latin}{la}
+\setlanguagealias*[variant=classic]{latin}{la-x-classic}
+\setlanguagealias*[variant=ecclesiastic]{latin}{la-x-ecclesia}
+\setlanguagealias*[variant=medieval]{latin}{la-x-medieval}
+
 % Babel aliases
-\setlanguagealias[variant=classic]{latin}{latinclassic}
-\setlanguagealias[variant=ecclesiastic]{latin}{latinecclesiastic}
-\setlanguagealias[variant=medieval]{latin}{latinmedieval}
+\setlanguagealias[variant=classic]{latin}{classiclatin}
+\setlanguagealias[variant=ecclesiastic]{latin}{ecclesiasticlatin}
+\setlanguagealias[variant=medieval]{latin}{medievallatin}
 
 
 %%%%% Variables and commands concerning spelling
@@ -8469,8 +11386,7 @@
 
 \msg_new:nnn {polyglossia} {latin / missing modern patterns}
   {
-    No~hyphenation~patterns~were~found~for~Latin~\msg_line_context:.~
-    I~will~not~hyphenate~Latin~words.
+    The~hyphenation~patterns~for~modern~Latin~were~not~found~\msg_line_context:.
   }
 
 \msg_new:nnn {polyglossia} {latin / missing patterns}
@@ -8486,11 +11402,23 @@
         \def \latin at language
           {
             \polyglossia at setup@language at patterns {latin}
+            \str_case:Vn \l_polyglossia_latin_variant_str
+              {
+                {classic}      { \adddialect \l at classiclatin \l at latin }
+                {medieval}     { \adddialect \l at medievallatin \l at latin }
+                {ecclesiastic} { \adddialect \l at ecclesiasticlatin \l at latin }
+              }
           }
       }
       {
         \msg_warning:nn {polyglossia} {latin / missing modern patterns}
-        \adddialect \l at latin \l at nohyphenation
+        \str_case:Vn \l_polyglossia_latin_variant_str
+          {
+            {classic}      { \adddialect \l at classiclatin \l at nohyphenation }
+            {medieval}     { \adddialect \l at medievallatin \l at nohyphenation }
+            {modern}       { \adddialect \l at latin \l at nohyphenation }
+            {ecclesiastic} { \adddialect \l at ecclesiasticlatin \l at nohyphenation }
+          }
       }
   }
 
@@ -8502,19 +11430,22 @@
         \def \latin at language
           {
             \polyglossia at setup@language at patterns {#1}
+            \str_case:Vn \l_polyglossia_latin_variant_str
+              {
+                {classic}      {
+                                 \str_if_eq:nnTF{#1}{liturgicallatin}
+                                     { \adddialect \l at classiclatin { \use:c {l@#1} } }
+                                     {}
+                               }
+                {medieval}     { \adddialect \l at medievallatin { \use:c {l@#1} } }
+                {modern}       { \adddialect \l at latin { \use:c {l@#1} } }
+                {ecclesiastic} { \adddialect \l at ecclesiasticlatin { \use:c {l@#1} } }
+              }
           }
       }
       {
-        \xpg at ifdefined {latin}
-          {
-            \msg_warning:nnn {polyglossia} {latin / missing patterns} {#1}
-            \adddialect \l@ #1 \l at latin
-            \polyglossia_latin_use_modern_patterns:
-          }
-          {
-            \msg_warning:nn {polyglossia} {latin / missing modern patterns}
-            \adddialect \l@ #1 \l at nohyphenation
-          }
+        \msg_warning:nnn {polyglossia} {latin / missing patterns} {#1}
+        \polyglossia_latin_use_modern_patterns:
       }
   }
 
@@ -8528,7 +11459,8 @@
     \directlua { require('polyglossia-latin') }
   }
   {
-    \newXeTeXintercharclass \g_polyglossia_latin_punctuation_class
+    \newXeTeXintercharclass \g_polyglossia_latin_question_exclamation_class
+    \newXeTeXintercharclass \g_polyglossia_latin_colon_semicolon_class
     \newXeTeXintercharclass \g_polyglossia_latin_opening_guillemet_class
     \newXeTeXintercharclass \g_polyglossia_latin_closing_guillemet_class
     \newXeTeXintercharclass \g_polyglossia_latin_opening_bracket_class
@@ -8559,14 +11491,15 @@
       }
       {
         \XeTeXinterchartokenstate = 1
-        \XeTeXcharclass `\! \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\? \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\‼ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁇ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁈ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁉ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\; \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\: \g_polyglossia_latin_punctuation_class
+        \XeTeXcharclass `\! \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\? \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\‼ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁇ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁈ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁉ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\‽ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\; \g_polyglossia_latin_colon_semicolon_class
+        \XeTeXcharclass `\: \g_polyglossia_latin_colon_semicolon_class
         \XeTeXcharclass `\« \g_polyglossia_latin_opening_guillemet_class
         \XeTeXcharclass `\» \g_polyglossia_latin_closing_guillemet_class
         \XeTeXcharclass `\‹ \g_polyglossia_latin_opening_guillemet_class
@@ -8580,16 +11513,31 @@
         \XeTeXcharclass `\⟨ \g_polyglossia_latin_opening_bracket_class
         \XeTeXcharclass `\⟩ \g_polyglossia_latin_closing_bracket_class
 
-        % punctuation followed by a closing guillemet
-        \XeTeXinterchartoks \g_polyglossia_latin_punctuation_class \g_polyglossia_latin_closing_guillemet_class =
+        % question or exclamation mark followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % closing bracket followed by punctuation
-        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_punctuation_class =
+        % question or exclamation mark followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_colon_semicolon_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
+        % colon or semicolon followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_colon_semicolon_class \g_polyglossia_latin_closing_guillemet_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing bracket followed by a question or exclamation mark
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_question_exclamation_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing bracket followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % closing bracket followed by a closing guillemet
         \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_closing_guillemet_class =
           {
@@ -8600,31 +11548,56 @@
           {
             \polyglossia_latin_replace_following_space:
           }
+        % opening guillemet followed by an opening guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \g_polyglossia_latin_opening_guillemet_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % opening guillemet followed by an ordinary character
         \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \z@ =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % closing guillemet followed by punctuation
-        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_punctuation_class =
+        % closing guillemet followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % space followed by punctuation
-        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_punctuation_class =
+        % closing guillemet followed by a question or exclamation mark
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_question_exclamation_class =
           {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing guillemet followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % space followed by a question or exclamation mark
+        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_question_exclamation_class =
+          {
             \polyglossia_latin_replace_preceding_space:
           }
+        % space followed by a colon or semicolon
+        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_replace_preceding_space:
+          }
         % space followed by closing guillemet
         \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_replace_preceding_space:
           }
-        % ordinary character followed by punctuation
-        \XeTeXinterchartoks \z@ \g_polyglossia_latin_punctuation_class =
+        % ordinary character followed by a question or exclamation mark
+        \XeTeXinterchartoks \z@ \g_polyglossia_latin_question_exclamation_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
+        % ordinary character followed by a colon or semicolon
+        \XeTeXinterchartoks \z@ \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % ordinary character followed by closing guillemet
         \XeTeXinterchartoks \z@ \g_polyglossia_latin_closing_guillemet_class =
           {
@@ -8646,6 +11619,7 @@
         \XeTeXcharclass `\⁇ \z@
         \XeTeXcharclass `\⁈ \z@
         \XeTeXcharclass `\⁉ \z@
+        \XeTeXcharclass `\‽ \z@
         \XeTeXcharclass `\; \z@
         \XeTeXcharclass `\: \z@
         \XeTeXcharclass `\« \z@
@@ -8701,7 +11675,9 @@
           }
       }
       {
-        \msg_warning:nn {polyglossia} {latin / ineffective footnote option}
+        \iflatin at ecclesiasticfootnotes
+          \msg_warning:nn {polyglossia} {latin / ineffective footnote option}
+        \fi
       }
   }
 
@@ -8723,6 +11699,8 @@
 
 %%%%% Language variants: classic, medieval, modern, and ecclesiastic
 
+\str_new:N \l_polyglossia_latin_variant_str
+
 \msg_new:nnn {polyglossia} {latin / language variant}
   {
     Activating~Latin~language~variant~"#1"~\msg_line_context:.
@@ -8740,7 +11718,8 @@
     \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.classic }
+    \str_set:Nn \l_polyglossia_latin_variant_str {classic}
+    \SetLanguageKeys {latin} { babelname = classiclatin, bcp47 = la-x-classic }
     \polyglossia_latin_set_patterns:n {classiclatin}
   }
 
@@ -8751,7 +11730,8 @@
     \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.medieval }
+    \str_set:Nn \l_polyglossia_latin_variant_str {medieval}
+    \SetLanguageKeys {latin} { babelname = medievallatin, bcp47 = la-x-medieval }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -8762,7 +11742,8 @@
     \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin }
+    \str_set:Nn \l_polyglossia_latin_variant_str {modern}
+    \SetLanguageKeys {latin} { babelname = latin, bcp47 = la }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -8773,7 +11754,8 @@
     \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_true:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.ecclesiastic }
+    \str_set:Nn \l_polyglossia_latin_variant_str {ecclesiastic}
+    \SetLanguageKeys {latin} { babelname = ecclesiasticlatin, bcp47 = la-x-ecclesia }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -8841,7 +11823,7 @@
     The~Latin~hyphenation~variant~"#1"~is~undefined~\msg_line_context:.
   }
 
-\define at key{latin}{hyphenation}
+\define at key {latin} {hyphenation}
   {
     \str_case:nnTF {#1}
       {
@@ -8940,6 +11922,11 @@
   {
   }
 
+% Register default options
+\xpg at initialize@gloss at options{latin}{variant=modern,hyphenation=modern,babelshorthands=false,
+                                     prosodicshorthands=false,ecclesiasticfootnotes=false,
+                                     usej=false,capitalizemonth=true}
+
 \ifsystem at babelshorthands
   \setkeys{latin}{babelshorthands=true}
 \else
@@ -9322,7 +12309,7 @@
 
 %%   Copyright (C) Claudio Beccari 2013-2016
 %%   Copyright (C) Élie Roux 2016-2019
-%%   Copyright (C) Keno Wehr 2019
+%%   Copyright (C) Keno Wehr 2019-2020
 %%
 %%   Permission is hereby granted, free of charge, to any person obtaining
 %%   a copy of this software and associated documentation files
@@ -9400,6 +12387,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-latvian.ldf}[polyglossia: module for latvian]
 \PolyglossiaSetup{latvian}{
+  bcp47=lv,
   hyphennames={latvian},
   hyphenmins={2,2},
   langtag=LVI,
@@ -9406,6 +12394,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{latvian}{lv}
+
 \def\captionslatvian{%
    \def\prefacename{Priekšvārds}%
    \def\refname{Literatūras saraksts}%
@@ -9451,6 +12442,7 @@
 
 \ProvidesFile{gloss-lithuanian.ldf}[polyglossia: module for lithuanian]
 \PolyglossiaSetup{lithuanian}{
+  bcp47=lt,
   hyphennames={lithuanian},
   hyphenmins={2,2},
   langtag=LTH,
@@ -9458,6 +12450,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{lithuanian}{lt}
+
 \def\captionslithuanian{%
    \def\prefacename{Pratarmė}%
    \def\refname{Literatūra}%
@@ -9514,6 +12509,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-lithuanian.ldf>
+%<*gloss-lo.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-lo.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-lo.ldf}[polyglossia: module for lo (lao)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{lao}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-lo.ldf>
 %<*gloss-lowersorbian.ldf>
 % \fi
 % \clearpage
@@ -9545,6 +12555,36 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-lsorbian.ldf>
+%<*gloss-lt.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-lt.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-lt.ldf}[polyglossia: module for lt (lithuanian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{lithuanian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-lt.ldf>
+%<*gloss-lv.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-lv.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-lv.ldf}[polyglossia: module for lv (latvian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latvian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-lv.ldf>
 %<*gloss-macedonian.ldf>
 % \fi
 % \clearpage
@@ -9553,6 +12593,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-macedonian.ldf}[polyglossia: module for macedonian]
 \PolyglossiaSetup{macedonian}{
+  bcp47=mk,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=MKD,
@@ -9562,6 +12603,9 @@
   fontsetup
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{macedonian}{mk}
+
 \def\macedonian at Alph#1{%
    \ifcase#1\or
    А\or Б\or В\or Г\or Д\or Ѓ\or Е\or
@@ -9662,12 +12706,18 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{malay}{%
+  bcp47=id,
   language=Malay,
   langtag=MLY,
   hyphennames={malay,melayu,bahasam,bahasai,indonesian,indon,bahasa},
   hyphenmins={2,2},
-  fontsetup=true}
+  fontsetup=true
+}
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=malaysian]{malay}{zsm}
+\setlanguagealias*[variant=indonesian]{malay}{id}
+
 % Babel aliases
 \setlanguagealias[variant=indonesian]{malay}{bahasai}
 \setlanguagealias[variant=malaysian]{malay}{bahasa}
@@ -9689,7 +12739,7 @@
       \malay at melayutrue
    \fi
    \ifmalay at melayu
-      \SetLanguageKeys{malay}{language=Malay,langtag=MLY,babelname=bahasam}%
+      \SetLanguageKeys{malay}{language=Malay,langtag=MLY,babelname=bahasam,bcp47=zsm}%
       \xpg at fontsetup@latin{malay}%
       % Check if \l at malay is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -9707,7 +12757,7 @@
         }%
       }%
    \else
-      \SetLanguageKeys{malay}{language=Indonesian,langtag=IND,babelname=bahasa}%
+      \SetLanguageKeys{malay}{language=Indonesian,langtag=IND,babelname=bahasa,bcp47=id}%
       \xpg at fontsetup@latin{malay}%
       % Check if \l at indonesian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -9728,7 +12778,10 @@
    \xpg at info{Option: malay, variant=\val}%
 }{\xpg at warning{Unknown malay variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{malay}{variant=malaysian}
 
+
 \def\malay at language{%
    \polyglossia at setup@language at patterns{\malay at variant}%
 }%
@@ -9853,6 +12906,7 @@
 % Translations provided by Kevin & Siji, 01-11-2009
 
 \PolyglossiaSetup{malayalam}{
+  bcp47=ml,
   script=Malayalam,
   scripttag=mlym,
   langtag=MAL, %FIXME there is also MLR for "Malayalam Reformed"
@@ -9861,6 +12915,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{malayalam}{ml}
+
 \def\captionsmalayalam{%
      \def\abstractname{സാരാംശം}%
      \def\appendixname{ശിഷ്ടം}%
@@ -9911,6 +12968,7 @@
 % \subsection{gloss-marathi.ldf}
 %    \begin{macrocode}
 % Translations provided by Abhijit Navale <abhi_navale at live.in>
+% Ordinals (1-100) added by Niranjan Tambe <niranjanvikastambe at gmail.com> on 14th December, 2019
 % TODO implement Hindu calendar (not used in day-to-day practice)
 
 \ProvidesFile{gloss-marathi.ldf}[polyglossia: module for marathi]
@@ -9923,6 +12981,7 @@
 \RequirePackage{devanagaridigits}
 
 \PolyglossiaSetup{marathi}{
+  bcp47=mr,
   script=Devanagari,
   scripttag=deva,
   langtag=MAR,
@@ -9933,16 +12992,26 @@
   %TODO nouppercase=true,
 }
 
-\def\tmp at western{Western}
+% BCP-47 compliant aliases
+\setlanguagealias*{marathi}{mr}
+
 \newif\ifmarathi at devanagari@numerals
 \marathi at devanagari@numeralstrue
 
-\define at key{marathi}{numerals}[Devanagari]{%
-  \def\@tmpa{#1}%
-  \ifx\@tmpa\tmp at western
-    \marathi at devanagari@numeralsfalse
-  \fi}
+\define at choicekey*+{marathi}{numerals}[\val\nr]{Western,Devanagari}[Devanagari]{%
+   \ifcase\nr\relax
+      % Western:
+      \marathi at devanagari@numeralsfalse%
+   \or
+      % Devanagari:
+      \marathi at devanagari@numeralstrue%
+   \fi
+   \xpg at info{Option: Marathi, numerals=\val}%
+}{\xpg at warning{Unknown Marathi numerals value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{marathi}{numerals=Devanagari}
+
 \newcommand{\marathinumerals}[2]{\marathinumber{#2}}
 
 \def\marathinumber#1{%
@@ -9950,55 +13019,155 @@
     \devanagaridigits{\number#1}%
   \else
     \number#1%
-  \fi}
+  \fi%
+}
 
 \def\captionsmarathi{%
    \def\refname{संदर्भ}%
    \def\abstractname{सारांश}%
-   \def\bibname{संदर्भ ग्रंथांची यादी}%
+   \def\bibname{संदर्भसूची}%
    \def\prefacename{प्रस्तावना}%
    \def\chaptername{प्रकरण}%
    \def\appendixname{परिशिष्ट}%
    \def\contentsname{अनुक्रमणिका}%
-   \def\listfigurename{आकृत्यांची यादी}%
-   \def\listtablename{कोष्टकांची यादी}%
+   \def\listfigurename{आकृत्यांची सूची}%
+   \def\listtablename{कोष्टक सूची}%
    \def\indexname{सूची}%
    \def\figurename{आकृती}%
    \def\tablename{कोष्टक}%
-   %\def\thepart{}% TODO
-   \def\partname{भाग}%
-   \def\pagename{पान}%
-   \def\seename{पहा}%
-   \def\alsoname{हे सुध्दा पहा}%
+   \def\partname{खंड}%
+   \def\pagename{पृष्ठ}%
+   \def\seename{पाहा}%
+   \def\alsoname{हेदेखील पाहा}%
    \def\enclname{समाविष्ट}%
-   \def\ccname{सि.सि.}%
+   \def\ccname{सी.सी.}%
    \def\headtoname{प्रति}%
    \def\proofname{सिद्धता}%
-   \def\glossaryname{स्पष्टीकरणांची यादी}%
+   \def\glossaryname{संक्षेपसूची}%
    \def\authorsand{आणि}%
 }
+
 \def\datemarathi{%
    \def\marathimonth{%
      \ifcase\month\or
-       जानेवारी\or
-       फेब्रुवारी\or
-       मार्च\or
-       एप्रिल\or
-       मे\or
-       जून\or
-       जुलै\or
-       ऑगस्ट\or
-       सप्टेंबर\or
-       ऑक्टोबर\or
-       नोव्हेंबर\or
-       डिसेंबर\fi
+                जानेवारी\or
+                फेब्रुवारी\or
+                मार्च\or
+                एप्रिल\or
+                मे\or
+                जून\or
+                जुलै\or
+               ऑगस्ट\or
+               सप्टेंबर\or
+               ऑक्टोबर\or
+               नोव्हेंबर\or
+               डिसेंबर%
+     \fi%
    }%
-   \def\today{\marathinumber\day\space\marathimonth\space\marathinumber\year}%
+   \def\today{%
+     \marathinumber\day\space\marathimonth\space\marathinumber\year%
+   }%
 }
 
+\def\devanagari at akshar#1{\ifcase#1\or अ\or आ\or इ\or ई\or उ\or ऊ\or ए\or ऐ\or ओ\or औ\or अं\or अः\else\@ctrerr\fi}
+
+\def\devanagari at 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 ळ\else\@ctrerr%
+    \fi%
+}
+
+\def\devanagari at letter#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 अठ्ठावन्न \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\@ctrerr%
+  \fi%
+}
+
+\let\xpg at save@roman\@roman
+\let\xpg at save@Roman\@Roman
+
+\def\marathi at numbers{%
+  \let\@alph\devanagari at akshar
+  \let\@Alph\devanagari at letter
+  \let\@roman\devanagari at alph
+  \let\@Roman\devanagari at letter
+}
+
+\def\nomarathi at numbers{%
+  \let\@alph\latin at alph%
+  \let\@Alph\latin at Alph%
+  \let\@roman\xpg at save@roman
+  \let\@Roman\xpg at save@Roman
+}
+
+\def\blockextras at marathi{%
+  \let\xpg at orig@baselinestretch\baselinestrech%
+  \renewcommand{\baselinestretch}{1.2}%
+  \renewcommand{\labelitemii}{$\rightarrow$}%
+}
+
+\let\xpg at orig@labelitemii\labelitemii
+
+\def\noextras at marathi{%
+  \let\baselinestrech\xpg at orig@baselinestretch%
+  \let\labelitemii\xpg at orig@labelitemii%
+}
+
 %    \end{macrocode}
 % \iffalse
 %</gloss-marathi.ldf>
+%<*gloss-mk.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-mk.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-mk.ldf}[polyglossia: module for mk (macedonian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{macedonian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-mk.ldf>
+%<*gloss-ml.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-ml.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-ml.ldf}[polyglossia: module for ml (malayalam)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{malayalam}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-ml.ldf>
+%<*gloss-mn.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-mn.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-mn.ldf}[polyglossia: module for mn (mongolian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{mongolian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-mn.ldf>
 %<*gloss-mongolian.ldf>
 % \fi
 % \clearpage
@@ -10010,6 +13179,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{mongolian}{
+  bcp47=mn,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=MNG,
@@ -10021,6 +13191,9 @@
   Localnumeral=Mongoliannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{mongolian}{mn}
+
 % This file is derived from mongolian-babel. which
 % provides support for Mongolian (Khalkha variety)
 % with Cyrillic script
@@ -10028,15 +13201,32 @@
 %       variants of Mongolian
 
 \newif\ifcyrillic at numerals
-\define at key{mongolian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{mongolian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Mongolian, numerals=\val}%
+}{\xpg at warning{Unknown Mongolian numerals value `#1'}}
 
-\define at boolkey{mongolian}[mongolian@]{babelshorthands}[false]{}
+\define at boolkey{mongolian}[mongolian@]{babelshorthands}[true]{}
 
-\setkeys{mongolian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{mongolian}{babelshorthands=false,numerals=arabic}
 
 \ifsystem at babelshorthands
   \setkeys{mongolian}{babelshorthands=true}
@@ -10131,7 +13321,11 @@
 
 \def\mongoliannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \mongolian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -10139,7 +13333,11 @@
 
 \def\Mongoliannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \mongolian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -10148,25 +13346,30 @@
 \let\mongoliannumeral=\mongoliannumber
 \let\Mongoliannumeral=\Mongoliannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\mongolian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\mongolian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\mongolian 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 Я%
+   \else\xpg at ill@value{#1}{mongolian at asbuk@Alph}\fi%
+}
 
-%\def\mongolian at 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 Я\else\xpg at ill@value{#1}{mongolian at Alph}\fi}
+\def\mongolian 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 я%
+   \else\xpg at ill@value{#1}{mongolian at asbuk@alph}\fi%
+}
 
-%\def\mongolian at 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 я\else\xpg at ill@value{#1}{mongolian at alph}\fi}
-
 \def\mongolian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph
@@ -10200,6 +13403,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-mongolian.ldf>
+%<*gloss-mr.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-mr.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-mr.ldf}[polyglossia: module for mr (marathi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{marathi}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-mr.ldf>
 %<*gloss-naustrian.ldf>
 % \fi
 % \clearpage
@@ -10215,6 +13433,21 @@
 %    \end{macrocode}
 % \iffalse
 %</gloss-naustrian.ldf>
+%<*gloss-nb.ldf>
+% \fi
+% \clearpage
+% 
+% \subsection{gloss-nb.ldf}
+%    \begin{macrocode}
+\ProvidesFile{gloss-nb.ldf}[polyglossia: module for nb (norwegian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{norwegian}
+
+%    \end{macrocode}
+% \iffalse
+%</gloss-nb.ldf>
 %<*gloss-newzealand.ldf>
 % \fi
 % \clearpage
@@ -10253,6 +13486,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-nko.ldf}[Polyglossia: module for N’Ko v0.1 2013/05/19]
 \PolyglossiaSetup{nko}{%
+  bcp47=nko,
   script=N'ko,
   scripttag=nko~,
   langtag=NKO,
@@ -10261,6 +13495,7 @@
   direction=RL,
   localnumeral=nkonumerals
 }
+
 \RequirePackage{nkonumbers}%
 
 \newcommand{\nkonumerals}[2]{\nkonumber{#2}}
@@ -10361,6 +13596,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-norwegian.ldf}[polyglossia: module for norwegian]
 \PolyglossiaSetup{norwegian}{
+  bcp47=nn,
   hyphennames={nynorsk},
   langtag=NYN,
   hyphenmins={2,2},
@@ -10368,6 +13604,9 @@
   fontsetup=false,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=bokmal]{norwegian}{nb}
+\setlanguagealias*[variant=nynorsk]{norwegian}{nn} 
 % Babel and backwards compat. aliases
 \setlanguagealias[variant=bokmal]{norwegian}{norsk}
 \setlanguagealias[variant=nynorsk]{norwegian}{nynorsk}
@@ -10377,12 +13616,12 @@
    \ifcase\nr\relax
       % nynorsk:
       \def\norwegian at variant{nynorsk}%
-      \SetLanguageKeys{norwegian}{langtag=NYN,babelname=nynorsk}%
+      \SetLanguageKeys{norwegian}{langtag=NYN,babelname=nynorsk,bcp47=nn}%
       \xpg at fontsetup@latin{norwegian}%
    \or
       % bokmal:
       \def\norwegian at variant{norsk}%
-      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk}%
+      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk,bcp47=nb}%
       \xpg at fontsetup@latin{norwegian}%
    \fi
    \xpg at info{Option: norwegian, variant=\val}%
@@ -10389,8 +13628,12 @@
 }{\xpg at warning{Unknown norwegian variant `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{norwegian}{variant=nynorsk}
+
+
 \def\norwegian at language{%
-   \polyglossia at setup@language at patterns{\norwegian at variant}
+   \polyglossia at setup@language at patterns{\norwegian at variant}%
 }%
 
 \def\captionsnorwegian at nynorsk{%
@@ -10525,6 +13768,7 @@
 \ProvidesFile{gloss-occitan.ldf}[2016/02/04 v0.3 polyglossia:
      module for Occitan]
 \PolyglossiaSetup{occitan}{
+  bcp47=oc,
   hyphennames={occitan},
   langtag=OCI,
   hyphenmins={2,2},
@@ -10532,6 +13776,10 @@
   indentfirst=true,
   fontsetup=true,
 }
+
+% BCP-47 compliant aliases
+\setlanguagealias*{occitan}{oc}
+
 \define at boolkey{occitan}[occitan@]{babelshorthands}[true]{}
 
 \ifsystem at babelshorthands
@@ -10687,6 +13935,7 @@
 \RequirePackage{farsical}
 \RequirePackage{hijrical}
 \PolyglossiaSetup{persian}{
+  bcp47=fa,
   babelname=farsi,
   script=Arabic,
   direction=RL,
@@ -10697,6 +13946,9 @@
   localnumeral=farsinumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{persian}{fa}
+
 % Babel and backwards compat. alias
 \setlanguagealias{persian}{farsi}
 
@@ -10723,7 +13975,8 @@
 
 %TODO add option for CALENDAR
 
-\setkeys{persian}{locale,numerals}
+% Register default options
+\xpg at initialize@gloss at options{persian}{locale=default,numerals=eastern,abjadjimnotail=false}
 
 \def\farsigregmonth#1{\ifcase#1%
   \or ژانویه\or فوریه\or مارس\or آوریل\or مه\or ژوئن\or ژوئیه\or اوت\or سپتامبر\or اکتبر\or نوامبر\or دسامبر\fi}
@@ -10764,28 +14017,13 @@
 
 \newcommand{\farsinumerals}[2]{\farsinumber{#2}}
 
-\newif\ifpersiandigits
-
 \def\farsinumber#1{%
   \if at western@numerals
     \number#1%
   \else
-    \ifxetex
-      \ifnum\XeTeXcharglyph"06F0 > 0\relax
-        \persiandigitstrue
-      \fi
-    \else\ifluatex
-      \expandafter\ifnum\directlua{polyglossia.check_char(0x6F0)} > 0\relax
-        \persiandigitstrue
-      \fi
-    \fi\fi
-    \ifpersiandigits
-      \farsidigits{\number#1}%
-      %%{\protect\addfontfeature{Mapping=farsidigits}\number#1}%
-    \else%
-      \arabicdigits{\number#1}%
-      %%{\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-    \fi
+    \xpg at if@char at available{06F0}%
+          {\farsidigits{\number#1}}%
+          {\arabicdigits{\number#1}}%
   \fi
 }
 
@@ -10841,6 +14079,7 @@
 \ProvidesFile{gloss-piedmontese.ldf}[2013/02/12 v1.0 polyglossia: module for piedmontese]
 \makeatletter
 \PolyglossiaSetup{piedmontese}{
+  bcp47=pms,
   hyphennames={piedmontese},
   hyphenmins={2,2},
   langtag=PMS,
@@ -10848,6 +14087,8 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{piedmontese}{pms}
 
 \define at boolkey{piedmontese}[piedmontese@]{babelshorthands}[true]{}
 
@@ -10963,6 +14204,7 @@
 %    \begin{macrocode}
 \ProvidesFile{gloss-polish.ldf}[polyglossia: module for polish]
 \PolyglossiaSetup{polish}{
+  bcp47=pl,
   hyphennames={polish},
   hyphenmins={2,2},
   langtag=PLK,
@@ -10970,6 +14212,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{polish}{pl}
+
 \def\captionspolish{%
   \def\prefacename{Przedmowa}%
   \def\refname{Literatura}%
@@ -11047,6 +14292,7 @@
 \ProvidesFile{gloss-portuguese.ldf}[polyglossia: module for portuguese]
 
 \PolyglossiaSetup{portuguese}{
+  bcp47=pt-PT,
   babelname=portuges,
   hyphennames={portuges,portuguese},
   hyphenmins={2,3},
@@ -11054,6 +14300,11 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=portuguese]{portuguese}{pt-PT}
+\setlanguagealias*[variant=brazilian]{portuguese}{pt-BR}
+\setlanguagealias*{portuguese}{pt}
+
 % Babel aliases
 \setlanguagealias[variant=portuguese]{portuguese}{portuges}
 \setlanguagealias[variant=brazilian]{portuguese}{brazil}
@@ -11063,11 +14314,11 @@
    \ifcase\nr\relax
       % portuguese:
       \def\portuguese at variant{portuges}%
-      \SetLanguageKeys{portuguese}{babelname=portuges}%
+      \SetLanguageKeys{portuguese}{babelname=portuges,bcp47=pt-PT}%
    \or
       % brazilian:
       \def\portuguese at variant{brazil}%
-      \SetLanguageKeys{portuguese}{babelname=brazil}%
+      \SetLanguageKeys{portuguese}{babelname=brazil,bcp47=pt-BR}%
       \xpg at ifdefined{brazil}{}%
 	    {\xpg at warning{No hyphenation patterns were loaded for "Portuguese (Brazil)"\MessageBreak
 	      I will use the standard patterns for Portuguese instead}%
@@ -11077,8 +14328,12 @@
 }{\xpg at warning{Unknown portuguese variant `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{portuguese}{variant=portuguese}
+
+
 \def\portuguese at language{%
-   \polyglossia at setup@language at patterns{\portuguese at variant}
+   \polyglossia at setup@language at patterns{\portuguese at variant}%
 }%
 
 \def\captionsportuguese at portuges{%
@@ -11164,6 +14419,7 @@
 \ProvidesFile{gloss-romanian.ldf}[polyglossia: module for romanian]
 
 \PolyglossiaSetup{romanian}{
+  bcp47=ro,
   hyphennames={romanian},
   hyphenmins={2,2},
   langtag=ROM,
@@ -11170,6 +14426,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{romanian}{ro}
+
 \def\captionsromanian{%
    \def\refname{Bibliografie}%
    \def\abstractname{Rezumat}%
@@ -11215,6 +14474,7 @@
 \ProvidesFile{gloss-romansh.ldf}[polyglossia: module for romansh]
 \makeatletter
 \PolyglossiaSetup{romansh}{%
+  bcp47=rm,
   hyphennames={romansh},
   hyphenmins={2,2},
   langtag=RMS,
@@ -11222,6 +14482,8 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{romansh}{rm}
 
 \def\captionsromansh{%
   \def\prefacename{Prefaziun}%
@@ -11268,6 +14530,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{russian}{
+  bcp47=ru,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=RUS,
@@ -11280,11 +14543,16 @@
   Localnumeral=Russiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{russian}{ru}
+\setlanguagealias*[spelling=modern]{russian}{ru-luna1918}
+\setlanguagealias*[spelling=old]{russian}{ru-petr1708}
+
 \newif\if at russian@modern
 \define at key{russian}{spelling}[modern]{%
   \ifstrequal{#1}{old}%
-    {\@russian at modernfalse}%
-    {\@russian at moderntrue}%
+    {\@russian at modernfalse\SetLanguageKeys{russian}{bcp47=ru-petr1708}}%
+    {\@russian at moderntrue\SetLanguageKeys{russian}{bcp47=ru}}%
 }
 
 \def\captionsrussian{%
@@ -11296,13 +14564,29 @@
 }%
 
 \newif\ifcyrillic at numerals
-\define at key{russian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{russian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Russian, numerals=\val}%
+}{\xpg at warning{Unknown Russian numerals value `#1'}}
 
-\define at boolkey{russian}[russian@]{indentfirst}{
+\define at boolkey{russian}[russian@]{indentfirst}[true]{
    \ifrussian at indentfirst
       \SetLanguageKeys{russian}{indentfirst=true}
    \else
@@ -11310,10 +14594,13 @@
   \fi
 }
 
-\define at boolkey{russian}[russian@]{babelshorthands}[false]{}
+\define at boolkey{russian}[russian@]{babelshorthands}[true]{}
 
-\setkeys{russian}{spelling,numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{russian}{babelshorthands=false,spelling=modern,numerals=arabic,indentfirst=false}
+
+
 \ifsystem at babelshorthands
   \setkeys{russian}{babelshorthands=true}
 \else
@@ -11496,7 +14783,11 @@
 
 \def\russiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \russian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -11504,7 +14795,11 @@
 
 \def\Russiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \russian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -11513,25 +14808,31 @@
 \let\russiannumeral=\russiannumber
 \let\Russiannumeral=\Russiannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\russian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\russian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
+
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\russian 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 Я%
+   \else\xpg at ill@value{#1}{russian at asbuk@Alph}\fi%
+}
 
-%\def\russian at 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 Я\else\xpg at ill@value{#1}{russian at Alph}\fi}
+\def\russian 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 я%
+   \else\xpg at ill@value{#1}{russian at asbuk@alph}\fi%
+}
 
-%\def\russian at 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 я\else\xpg at ill@value{#1}{russian at alph}\fi}
-
 \def\russian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph
@@ -11538,8 +14839,8 @@
    \ifcyrillic at numerals%
      \def\russian at alph##1{\expandafter\russiannumeral\expandafter{\the##1}}%
      \def\russian at Alph##1{\expandafter\Russiannumeral\expandafter{\the##1}}%
-      \let\@alph\russian at alph%
-      \let\@Alph\russian at Alph%
+     \let\@alph\russian at alph%
+     \let\@Alph\russian at Alph%
    \fi
 }
 
@@ -11611,6 +14912,7 @@
 \ProvidesFile{gloss-sami.ldf}[polyglossia: module for sami]
 
 \PolyglossiaSetup{sami}{
+  bcp47=se,
   babelname=samin,
   hyphennames={samin},
   hyphenmins={2,2},
@@ -11619,6 +14921,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{sami}{se}
+
 % Babel and backwards compat. alias
 \setlanguagealias{sami}{samin}
 %\setlanguagealias[variant=northern]{sami}{samin}
@@ -11642,7 +14947,7 @@
 
 
 %\def\sami at language{%
-%   \polyglossia at setup@language at patterns{\sami at variant}
+%   \polyglossia at setup@language at patterns{\sami at variant}%
 %}%
 
 \def\captionssami at northern{%
@@ -11731,6 +15036,7 @@
 \RequirePackage{devanagaridigits}
 
 \PolyglossiaSetup{sanskrit}{
+  bcp47=sa-Deva,
   langtag=SAN,
   hyphennames={sanskrit,prakrit},
   hyphenmins={1,3},
@@ -11739,6 +15045,16 @@
   localnumeral=sanskritnumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{sanskrit}{sa}
+\setlanguagealias*[script=Devanagari]{sanskrit}{sa-Deva}
+\setlanguagealias*[script=Malayalam]{sanskrit}{sa-Mlym}
+\setlanguagealias*[script=Telugu]{sanskrit}{sa-Telu}
+\setlanguagealias*[script=Bengali]{sanskrit}{sa-Beng}
+\setlanguagealias*[script=Kannada]{sanskrit}{sa-Knda}
+\setlanguagealias*[script=Gujarati]{sanskrit}{sa-Gujr}
+\setlanguagealias*[script=Latin]{sanskrit}{sa-Latn}
+
 \define at key{sanskrit}{Script}[Devanagari]{%
   \ifcsdef{fontsetup at sanskrit@#1}%
     {\csname fontsetup at sanskrit@#1\endcsname}%
@@ -11749,30 +15065,28 @@
 \define at key{sanskrit}{script}[Devanagari]{\setkeys{sanskrit}{Script=#1}}
 
 \def\fontsetup at sanskrit@Devanagari{%
-  \SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari}
+  \SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari,bcp47=sa-Deva}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Gujarati{%
-  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati}
+  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati,bcp47=sa-Gujr}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Malayalam{%
-  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam}
+  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam,bcp47=sa-Mlym}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Bengali{%
-  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali}
+  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali,bcp47=sa-Beng}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Kannada{%
-  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada}
+  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada,bcp47=sa-Knda}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Telugu{%
-  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu}
+  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu,bcp47=sa-Relu}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Latin{%
-  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin}
+  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin,bcp47=sa-Latn}
   \xpg at fontsetup@latin{sanskrit}}
 
-\setkeys{sanskrit}{Script} %sets the default for Devanagari
 
-
 \newif\ifsanskrit at devanagari@numerals
 \sanskrit at devanagari@numeralstrue
 \define at choicekey*+{sanskrit}{numerals}[\val\nr]{Devanagari,Western}[Devanagari]{%
@@ -11787,6 +15101,10 @@
 }{\xpg at warning{Unknown Sanskrit numeral `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{sanskrit}{script=Devanagari,numerals=Devanagari}
+
+
 \newcommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
 
 \def\sanskritnumber#1{%
@@ -11800,7 +15118,8 @@
 \ifluatex
   \directlua{require('polyglossia-sanskrit')}%
 \else
-  \newXeTeXintercharclass\sanskrit at punctthin % ! ? ‼ ⁇ ⁈ ⁉ : ; danda double_danda
+  \newXeTeXintercharclass\sanskrit at questionexclamation % ! ? ‼ ⁇ ⁈ ⁉ ‽
+  \newXeTeXintercharclass\sanskrit at punctthin % : ; danda double_danda
 \fi
 
 \def\sanskrit at punctthinspace{{\unskip\thinspace}}
@@ -11810,17 +15129,20 @@
     \directlua{polyglossia.activate_sanskrit_punct()}%
   \else
     \XeTeXinterchartokenstate=1%
-    \XeTeXcharclass `\! \sanskrit at punctthin
-    \XeTeXcharclass `\? \sanskrit at punctthin
-    \XeTeXcharclass `\‼ \sanskrit at punctthin
-    \XeTeXcharclass `\⁇ \sanskrit at punctthin
-    \XeTeXcharclass `\⁈ \sanskrit at punctthin
-    \XeTeXcharclass `\⁉ \sanskrit at punctthin
+    \XeTeXcharclass `\! \sanskrit at questionexclamation
+    \XeTeXcharclass `\? \sanskrit at questionexclamation
+    \XeTeXcharclass `\‼ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁇ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁈ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁉ \sanskrit at questionexclamation
+    \XeTeXcharclass `\‽ \sanskrit at questionexclamation % interrobang, U+203D
     \XeTeXcharclass `\: \sanskrit at punctthin
     \XeTeXcharclass `\; \sanskrit at punctthin
     \XeTeXcharclass `\। \sanskrit at punctthin % danda, U+0964
     \XeTeXcharclass `\॥ \sanskrit at punctthin % double danda, U+0965
+    \XeTeXinterchartoks \z@ \sanskrit at questionexclamation = \sanskrit at punctthinspace
     \XeTeXinterchartoks \z@ \sanskrit at punctthin = \sanskrit at punctthinspace
+    \XeTeXinterchartoks \sanskrit at questionexclamation \sanskrit at punctthin = \sanskrit at punctthinspace
   \fi
 }
 
@@ -11834,6 +15156,7 @@
     \XeTeXcharclass `\⁇ \z@
     \XeTeXcharclass `\⁈ \z@
     \XeTeXcharclass `\⁉ \z@
+    \XeTeXcharclass `\‽ \z@
     \XeTeXcharclass `\: \z@
     \XeTeXcharclass `\; \z@
     \XeTeXcharclass `\। \z@
@@ -11884,6 +15207,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{serbian}{
+  bcp47=sr-Latn,
   langtag=SRB,
   hyphennames={serbian},
   hyphenmins={2,2},
@@ -11894,6 +15218,11 @@
   %TODO localalph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{serbian}{sr}
+\setlanguagealias*[script=Cyrillic]{serbian}{sr-Cyrl}
+\setlanguagealias*[script=Latin]{serbian}{sr-Latn}
+
 % Babel aliases
 \setlanguagealias[script=Cyrillic]{serbian}{serbianc}
 
@@ -11902,12 +15231,12 @@
    \ifcase\nr\relax
       % cyrillic:
       \@serbian at cyrtrue
-      \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc}
+      \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl}
       \xpg at fontsetup@nonlatin{serbian}%
    \or
       % latin:
       \@serbian at cyrfalse
-      \SetLanguageKeys{serbian}{scripttag=latn,script=Latin}
+      \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,bcp47=sr-Latn}
       \xpg at fontsetup@latin{serbian}%
       %TODO \def\serbian at language{\language=\l at serbianlat}%
       % or should we use Croatian patterns as a fallback for the time being???
@@ -11917,17 +15246,34 @@
 
 \define at key{serbian}{script}[Cyrillic]{\setkeys{serbian}{Script=#1}}
 
-\newif\ifserbian at numerals
-\define at key{serbian}{numerals}[arabic]{%
-   \ifstrequal{#1}{latin}{\serbian at numeralsfalse}{%
-       \ifstrequal{#1}{cyrillic}%
-          {\serbian at numeralstrue}
-          {\serbian at numeralsfalse}%
-   }%
-}
+\newif\ifcyrillic at numerals
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{serbian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Serbian, numerals=\val}%
+}{\xpg at warning{Unknown Serbian numerals value `#1'}}
 
 \setkeys{serbian}{Script,numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic}
+
 \def\captionsserbian{%
    \if at serbian@cyr\captionsserbian at cyr\else\captionsserbian at lat\fi
 }
@@ -12012,19 +15358,27 @@
 \newcommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
 
 \def\serbiannumber#1{%
-  \ifserbian at numerals
-    \cyr at alph{#1}%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
-  \fi
+  \fi%
 }
 
 \def\Serbiannumber#1{%
-  \ifserbian at numerals
-    \cyr at Alph{#1}%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
-  \fi
+  \fi%
 }
 
 \let\serbiannumeral=\serbiannumber
@@ -12054,25 +15408,30 @@
    \ifserbian at numerals\noserbian at numbers\fi
 }
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\serbian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\serbian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% 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 Я%
+   \else\xpg at ill@value{#1}{serbian at asbuk@Alph}\fi%
+}
 
-%\def\cyr at 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 Ш\else\xpg at ill@value{#1}{cyr at 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 я%
+   \else\xpg at ill@value{#1}{serbian at asbuk@alph}\fi%
+}
 
-%\def\cyr at 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 ш\else\xpg at ill@value{#1}{cyr at alph}\fi}
-
  
 %    \end{macrocode}
 % \iffalse
@@ -12101,6 +15460,7 @@
 \ProvidesFile{gloss-slovak.ldf}[polyglossia: module for slovak]
 
 \PolyglossiaSetup{slovak}{
+  bcp47=sk,
   hyphennames={slovak},
   hyphenmins={2,2},
   langtag=SKY,
@@ -12107,6 +15467,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{slovak}{sk}
+
 \ifluatex
   \RequirePackage{luavlna}
 \fi
@@ -12117,7 +15480,8 @@
 
 \define at boolkey{slovak}[slovak@]{vlna}[true]{}
 
-\setkeys{slovak}{splithyphens,vlna}
+% Register default options
+\xpg at initialize@gloss at options{slovak}{babelshorthands=false,splithyphens=true,vlna=true}
 
 \ifsystem at babelshorthands
   \setkeys{slovak}{babelshorthands=true}
@@ -12132,8 +15496,12 @@
 }{}
 
 \def\slovak@@splhyphen#1{%
-  \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
-  \nobreak\hskip\z@%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
 }
 
 \def\slovak at splhyphen{%
@@ -12320,13 +15688,13 @@
 \def\blockextras at slovak{%
   \ifslovak at babelshorthands\slovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
-  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyhens\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 vlna\slovak at vlna\else\noslovak at vlna\fi%
-  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyhens\fi%
+  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }
 
 %    \end{macrocode}
@@ -12356,6 +15724,7 @@
 \ProvidesFile{gloss-slovenian.ldf}[polyglossia: module for slovenian]
 
 \PolyglossiaSetup{slovenian}{
+  bcp47=sl,
   hyphennames={slovenian,slovene},
   babelname=slovene,
   hyphenmins={2,2},
@@ -12363,20 +15732,18 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{slovenian}{sl}
+
 % Babel aliases
 \setlanguagealias{slovenian}{slovene}
 
-\providebool{slovenian at localalph}
-\define at boolkey{slovenian}[slovenian@]{localalph}[false]{%
-  \def\@tmpa{#1}%
-  \def\@tmptrue{true}%
-  \ifx\@tmpa\@tmptrue
-    \slovenian at localalphtrue
-  \fi
-  \setlocalalph
-}
+\define at boolkey{slovenian}[slovenian@]{localalph}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{slovenian}{localalph=false}
 
+
 \def\captionsslovenian{%
    \def\refname{Literatura}%
    \def\abstractname{Povzetek}%
@@ -12400,7 +15767,7 @@
    \def\headtoname{Prejme}%
    \def\proofname{Dokaz}%
    \def\glossaryname{Slovar}%
-   }
+}
 
 \def\dateslovenian{%   
   \def\today{\number\day.~\ifcase\month\or
@@ -12407,7 +15774,7 @@
     januar\or februar\or marec\or april\or maj\or junij\or
     julij\or avgust\or september\or oktober\or november\or december\fi
     \space \number\year}%
-  }
+}
 
 \def\slovenian at alph#1{%
   \ifcase#1\or a\or b\or c\or č\or d\or e\or f\or g\or h\or i\or j\or k\or l\or
@@ -12415,17 +15782,22 @@
 }
 \def\slovenian at Alph#1{%
   \ifcase#1\or A\or B\or C\or Č\or D\or E\or F\or G\or H\or I\or J\or K\or L\or
-  M\or N\or O\or P\or R\or S\or Š\or T\or U\or V\or Z\or Ž\else#1\fi}
+  M\or N\or O\or P\or R\or S\or Š\or T\or U\or V\or Z\or Ž\else#1\fi
+}
+
 \def\abeceda#1{\expandafter\slovenian at alph\csname c@#1\endcsname}
 \def\Abeceda#1{\expandafter\slovenian at Alph\csname c@#1\endcsname}
 
-\def\setlocalalph{%
-  \def\extras at slovenian{\let\alph\abeceda\let\Alph\Abeceda}
-  \def\blockextras at slovenian{\extras at slovenian}
-  \def\inlineextras at slovenian{\extras at slovenian}
-  \def\noextras at slovenian{\let\alph\latinalph\let\Alph\latinAlph}
+\def\extras at slovenian{%
+  \ifslovenian at localalph\let\alph\abeceda\let\Alph\Abeceda\fi%
 }
 
+\def\blockextras at slovenian{\extras at slovenian}
+
+\def\inlineextras at slovenian{\extras at slovenian}
+
+\def\noextras at slovenian{\let\alph\latinalph\let\Alph\latinAlph}
+
 %    \end{macrocode}
 % \iffalse
 %</gloss-slovenian.ldf>
@@ -12438,6 +15810,7 @@
 \ProvidesFile{gloss-sorbian.ldf}[polyglossia: module for sorbian]
 
 \PolyglossiaSetup{sorbian}{
+  bcp47=hsb,
   language=Upper Sorbian,
   babelname=uppersorbian,
   hyphennames={usorbian,uppersorbian},
@@ -12446,6 +15819,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=upper]{sorbian}{hsb}
+\setlanguagealias*[variant=lower]{sorbian}{dsb} 
 % Backwards compat. aliases
 \setlanguagealias[variant=lower]{sorbian}{lsorbian}
 \setlanguagealias[variant=upper]{sorbian}{usorbian}
@@ -12459,7 +15835,7 @@
    \ifcase\nr\relax
       % upper:
       \def\sorbian at variant{usorbian}%
-      \SetLanguageKeys{sorbian}{language=Upper Sorbian,langtag=USB,babelname=uppersorbian}%
+      \SetLanguageKeys{sorbian}{language=Upper Sorbian,langtag=USB,babelname=uppersorbian,bcp47=hsb}%
       \xpg at fontsetup@latin{sorbian}%
       % Check if \l at usorbian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -12479,7 +15855,7 @@
    \or
       % lower:
       \def\sorbian at variant{lsorbian}%
-      \SetLanguageKeys{sorbian}{language=Lower Sorbian,langtag=LSB,babelname=lowersorbian}%
+      \SetLanguageKeys{sorbian}{language=Lower Sorbian,langtag=LSB,babelname=lowersorbian,bcp47=dsb}%
       \xpg at fontsetup@latin{sorbian}%
       % Check if \l at lsorbian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -12503,7 +15879,8 @@
 
 \define at boolkey{sorbian}[sorbian@]{olddate}[true]{}
 
-\setkeys{sorbian}{variant}
+% Register default options
+\xpg at initialize@gloss at options{sorbian}{variant=upper,olddate=false}
 
 
 \def\sorbian at language{%
@@ -12620,8 +15997,10 @@
 \ProvidesFile{gloss-spanish.ldf}[polyglossia: module for spanish]
 
 \PolyglossiaSetup{spanish}{
+  bcp47=es-ES,
   hyphennames={spanish},
   hyphenmins={2,2},
+  totalhyphenmin=5,
   langtag=ESP,
   frenchspacing=true,
   indentfirst=true,
@@ -12629,6 +16008,11 @@
   babelname=spanish
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{spanish}{es}
+\setlanguagealias*[variant=mexican]{spanish}{es-MX}
+\setlanguagealias*[variant=spanish]{spanish}{es-ES}
+
 % Babel aliases
 \setlanguagealias[variant=mexican]{spanish}{spanishmx}
 
@@ -12638,11 +16022,11 @@
    \ifcase\nr\relax
       % spanish:
       \@spanish at mexicofalse%
-      \SetLanguageKeys{spanish}{babelname=spanish}%
+      \SetLanguageKeys{spanish}{babelname=spanish,bcp47=es-ES}%
    \or
       % mexican:
       \@spanish at mexicotrue%
-      \SetLanguageKeys{spanish}{babelname=spanishmx}%
+      \SetLanguageKeys{spanish}{babelname=spanishmx,bcp47=es-MX}%
    \fi
    \xpg at info{Option: spanish, variant=\val}%
 }{\xpg at warning{Unknown spanish variant `#1'}}
@@ -12677,6 +16061,10 @@
    \xpg at info{Option: Spanish, spanishoperators=\val}%
 }{\xpg at warning{Unknown spanishoperators value `#1'}}
 
+
+% Register default options
+\xpg at initialize@gloss at options{spanish}{variant=spanish,spanishoperators=none}
+
 \let\xpg at save@lim\lim
 \let\xpg at save@limsup\limsup
 \let\xpg at save@liminf\liminf
@@ -12857,6 +16245,7 @@
 \ProvidesFile{gloss-swedish.ldf}[polyglossia: module for swedish]
 
 \PolyglossiaSetup{swedish}{
+  bcp47=sv,
   hyphennames={swedish},
   hyphenmins={2,2},
   langtag=SVE,
@@ -12864,6 +16253,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{swedish}{sv}
+
 \def\captionsswedish{%
   \def\refname{Referenser}%
   \def\abstractname{Sammanfattning}%
@@ -12937,6 +16329,7 @@
 \RequirePackage{arabicnumbers}
 
 \PolyglossiaSetup{syriac}{
+  bcp47=syr,
   script=Syriac,
   scripttag=syrc,
   langtag=SYR,
@@ -12947,6 +16340,9 @@
   %TODO localalph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{syriac}{syr}
+
 \def\syriacnumber#1{\@syriacnumber{#1}}%
 
 \newif\if at eastern@numerals
@@ -12964,7 +16360,8 @@
  	  \fi
   \fi}
 
-\setkeys{syriac}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{syriac}{numerals=western}
 	
 %\define at key{polyglossia}{syriaclocale}[default]{%
 %	\def\@syriac at locale{#1}}
@@ -13048,33 +16445,22 @@
       %%% we test for the presence of one of ١٢٣٤٥٦٧٨٩٠ in the Syriac font, 
       %%% else we try \arabicfont if defined (and give a warning), 
       %%% else we fall back to the Western numerals.
-      \ifxetex
-         \ifnum\XeTeXcharglyph"0661 > 0%
-           %%\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-           \protect\arabicdigits{\number#1}%
-         \else%
+      \xpg at if@char at available{0661}%
+          {\protect\arabicdigits{\number#1}}%
+          {\arabicdigits{\number#1}
            \ifcsdef{arabicfont}%
 	     {\protect\arabicdigits{\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: I am using \string\arabicfont instead}}%
+	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
+                           I am using \string\arabicfont instead}}%
 	     {\number#1%%% <---changed from \RL{\protect\reset at font\protect\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: since \string\arabicfont is not defined, we'll use Western numerals instead}}%
-         \fi
-     \else% LuaTeX
-         \expandafter\ifnum\directlua{polyglossia.check_char(0x661)} > 0\relax
-           %%\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-           \protect\arabicdigits{\number#1}%
-         \else%
-           \ifcsdef{arabicfont}%
-	     {\protect\arabicdigits{\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: I am using \string\arabicfont instead}}%
-	     {\number#1%%% <---changed from \RL{\protect\reset at font\protect\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: since \string\arabicfont is not defined, we'll use Western numerals instead}}%
-         \fi
-     \fi
+	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
+                           since \string\arabicfont is not defined, we'll use Western numerals instead}}%
+          }%
    \else
      %%\RL{\protect\reset at font\number#1}%
      \number#1%
-   \fi}
+   \fi%
+}
 
 \def\syriac at numbers{%
    \let\@alph\abjadsyriac%
@@ -13131,6 +16517,7 @@
 % Translations provided by Kevin & Siji, 01-11-2009
 
 \PolyglossiaSetup{tamil}{
+  bcp47=ta,
   script=Tamil,
   scripttag=taml,
   langtag=TAM,
@@ -13139,6 +16526,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{tamil}{ta}
+
 \def\captionstamil{%
      \def\abstractname{சாராம்சம்}%
      \def\appendixname{பிற்சேர்க்கை}%பின்னிணைப்பு
@@ -13198,6 +16588,7 @@
 % Translations provided by Anmol Sharma <unmole.in at gmail.com>
 
 \PolyglossiaSetup{telugu}{
+  bcp47=te,
   script=Telugu,
   scripttag=telu,
   langtag=TEL,
@@ -13206,6 +16597,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{telugu}{te}
+
 \def\captionstelugu{%
    \def\refname{ఆధారాలు}%
    \def\abstractname{సారాంశం}%
@@ -13275,6 +16669,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{thai}{
+  bcp47=th,
   script=Thai,
   scripttag=thai,
   langtag=THA,
@@ -13285,6 +16680,9 @@
   %TODO localdigits=thainumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{thai}{th}
+
 \newif\if at thai@numerals
 \def\tmp at thai{thai}
 \define at key{thai}{numerals}[arabic]{%
@@ -13293,7 +16691,8 @@
 	  \@thai at numeralsfalse\fi
 }
 
-\setkeys{thai}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{thai}{numerals=arabic}
 
 \def\captionsthai{%
    \def\refname{หนังสืออ้างอิง}%
@@ -13416,6 +16815,7 @@
 %%
 
 \PolyglossiaSetup{tibetan}{
+  bcp47=bo,
   script=Tibetan,
   scripttag=tibt,
   langtag=TIB,
@@ -13425,6 +16825,9 @@
   %TODO localalph={xxx at alph,xxx at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{tibetan}{bo}
+
 \newif\if at tibetan@numerals
 \def\tmp at tibetan{tibetan}
 \define at key{tibetan}{numerals}[tibetan]{%
@@ -13458,7 +16861,8 @@
   \fi %
 }
 
-\setkeys{tibetan}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{tibetan}{numerals=tibetan}
 
 % some are known, but very few
 % a few come from "Standardizing Tibetan Terms of Information Technology"
@@ -13590,6 +16994,7 @@
 \ProvidesFile{gloss-turkish.ldf}[polyglossia: module for turkish]
 \RequirePackage{hijrical}
 \PolyglossiaSetup{turkish}{
+  bcp47=tr,
   hyphennames={turkish},
   hyphenmins={2,2},
   langtag=TRK,
@@ -13617,6 +17022,9 @@
    \fi
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{turkish}{tr}
+
 \def\noturkish at punctuation{%
    \ifxetex
    \XeTeXcharclass `\! \z@
@@ -13700,6 +17108,7 @@
 \ProvidesFile{gloss-turkmen.ldf}[polyglossia: module for turkmen]
 %% Translations provided by Nazar Annagurban <nazartm at gmail dot com>
 \PolyglossiaSetup{turkmen}{
+  bcp47=tk,
   hyphennames={turkmen},
   hyphenmins={2,2},
   langtag=TKM,
@@ -13707,6 +17116,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{turkmen}{tk}
+
 \def\captionsturkmen{%
   \def\prefacename{Sözbaşy}%
   \def\refname{Çeşmeler}%
@@ -13751,7 +17163,10 @@
 % Strings taken from Babel
 % and revised by Roman Kyrylych
 
-\PolyglossiaSetup{ukrainian}{
+\RequirePackage{xpg-cyrillicnumbers}
+
+\PolyglossiaSetup{ukrainian}{%
+  bcp47=uk,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=UKR,
@@ -13758,25 +17173,47 @@
   hyphennames={ukrainian},
   hyphenmins={2,2},
   frenchspacing=true,
-  fontsetup=true
-  %TODO localalph
+  fontsetup=true,
+  localnumeral=ukrainiannumerals,
+  Localnumeral=Ukrainiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{ukrainian}{uk}
+
 \newif\ifcyrillic at numerals
-\define at key{ukrainian}{numerals}[latin]{%
-\ifstrequal{#1}{cyrillic}%
-{\cyrillic at numeralstrue}
-{\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{ukrainian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Ukrainian, numerals=\val}%
+}{\xpg at warning{Unknown Ukrainian numerals value `#1'}}
 
-\define at boolkey{ukrainian}[ukrainian@]{babelshorthands}[false]{}
 
-\setkeys{ukrainian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{ukrainian}{numerals=arabic}
 
+\define at boolkey{ukrainian}[ukrainian@]{babelshorthands}[true]{}
+
 \ifsystem at babelshorthands
-\setkeys{ukrainian}{babelshorthands=true}
+  \setkeys{ukrainian}{babelshorthands=true}
 \else
-\setkeys{ukrainian}{babelshorthands=false}
+  \setkeys{ukrainian}{babelshorthands=false}
 \fi
 
 \ifcsundef{initiate at active@char}{%
@@ -13786,45 +17223,47 @@
 }{}
 
 \def\ukrainian at shorthands{%
-\bbl at activate{"}%
-\def\language at group{ukrainian}%
+  \bbl at activate{"}%
+  \def\language at group{ukrainian}%
 %  \declare at shorthand{ukrainian}{"`}{„}%
 %  \declare at shorthand{ukrainian}{"'}{“}%
 %  \declare at shorthand{ukrainian}{"<}{«}%
 %  \declare at shorthand{ukrainian}{">}{»}%
-\declare at shorthand{ukrainian}{""}{\hskip\z at skip}%
-\declare at shorthand{ukrainian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
-\declare at shorthand{ukrainian}{"=}{\nobreak-\hskip\z at skip}%
-\declare at shorthand{ukrainian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
-\declare at shorthand{ukrainian}{"-}{%
-\def\ukrainian at sh@tmp{%
-\if\ukrainian at sh@next-\expandafter\ukrainian at sh@emdash
-\else\expandafter\ukrainian at sh@hyphen\fi
-}%
-\futurelet\ukrainian at sh@next\ukrainian at sh@tmp}%
-\def\ukrainian at sh@hyphen{%
-\nobreak\-\bbl at allowhyphens}%
-\def\ukrainian at sh@emdash##1##2{\cdash-##1##2}%
-\def\cdash##1##2##3{\def\tempx@{##3}%
-\def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
-\ifx\tempx@\tempa@\@Acdash\else
-\ifx\tempx@\tempb@\@Bcdash\else
-\ifx\tempx@\tempc@\@Ccdash\else
-\errmessage{Wrong usage of cdash}\fi\fi\fi}%
-\def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
-\cyrdash\hskip.2em\ignorespaces}%
-\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
-\nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z at skip\ignorespaces}%
-\def\@Ccdash{\leavevmode
-\nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
-\ifx\cyrdash\undefined
-\def\cyrdash{\hbox to.8em{--\hss--}}
-\fi
-\declare at shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
+  \declare at shorthand{ukrainian}{""}{\hskip\z at skip}%
+  \declare at shorthand{ukrainian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{ukrainian}{"=}{\nobreak-\hskip\z at skip}%
+  \declare at shorthand{ukrainian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
+  \declare at shorthand{ukrainian}{"-}{%
+  \def\ukrainian at sh@tmp{%
+    \if\ukrainian at sh@next-\expandafter\ukrainian at sh@emdash
+    \else\expandafter\ukrainian at sh@hyphen\fi
+  }%
+  \futurelet\ukrainian at sh@next\ukrainian at sh@tmp}%
+  \def\ukrainian at sh@hyphen{%
+  \nobreak\-\bbl at allowhyphens}%
+  \def\ukrainian at sh@emdash##1##2{\cdash-##1##2}%
+  \def\cdash##1##2##3{%
+    \def\tempx@{##3}%
+    \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
+    \ifx\tempx@\tempa@\@Acdash\else
+    \ifx\tempx@\tempb@\@Bcdash\else
+    \ifx\tempx@\tempc@\@Ccdash\else
+    \errmessage{Wrong usage of cdash}\fi\fi\fi%
+  }%
+  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
+  \cyrdash\hskip.2em\ignorespaces}%
+  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
+  \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z at skip\ignorespaces}%
+  \def\@Ccdash{\leavevmode
+  \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
+  \ifx\cyrdash\undefined
+    \def\cyrdash{\hbox to.8em{--\hss--}}
+  \fi
+  \declare at shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
 }
 
 \def\noukrainian at shorthands{%
-\@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
 }
 
 \def\captionsukrainian{%
@@ -13851,7 +17290,8 @@
    \def\headtoname{До}%
    \def\proofname{Доведення}%
    \def\glossaryname{Словник термінів}%
-   }
+}
+
 \def\dateukrainian{%
    \def\today{\number\day~\ifcase\month\or
     січня\or
@@ -13866,39 +17306,82 @@
     жовтня\or
     листопада\or
     грудня\fi%
-    \space\number\year~р.}}
+    \space\number\year~р.}%
+}
 
 % The following is based on some ideas from ruscor.sty
 \def\ukrainian at capsformat{%
-\def\@seccntformat##1{\csname pre##1\endcsname%
-\csname the##1\endcsname%
-\csname post##1\endcsname}%
-\def\@aftersepkern{\hspace{0.5em}}%
-\def\postchapter{.\@aftersepkern}%
-\def\postsection{.\@aftersepkern}%
-\def\postsubsection{.\@aftersepkern}%
-\def\postsubsubsection{.\@aftersepkern}%
-\def\postparagraph{.\@aftersepkern}%
-\def\postsubparagraph{.\@aftersepkern}%
-\def\prechapter{}%
-\def\presection{}%
-\def\presubsection{}%
-\def\presubsubsection{}%
-\def\preparagraph{}%
-\def\presubparagraph{}}
+  \def\@seccntformat##1{\csname pre##1\endcsname%
+  \csname the##1\endcsname%
+  \csname post##1\endcsname}%
+  \def\@aftersepkern{\hspace{0.5em}}%
+  \def\postchapter{.\@aftersepkern}%
+  \def\postsection{.\@aftersepkern}%
+  \def\postsubsection{.\@aftersepkern}%
+  \def\postsubsubsection{.\@aftersepkern}%
+  \def\postparagraph{.\@aftersepkern}%
+  \def\postsubparagraph{.\@aftersepkern}%
+  \def\prechapter{}%
+  \def\presection{}%
+  \def\presubsection{}%
+  \def\presubsubsection{}%
+  \def\preparagraph{}%
+  \def\presubparagraph{}%
+}
 
-\def\Asbuk#1{\expandafter\ukrainian at Alph\csname c@#1\endcsname}
-\def\ukrainian at Alph#1{\ifcase#1\or
-   А\or Б\or В\or Г\or Д\or Е\or Є\or Ж\or
-   З\or И\or І\or Ї\or Й\or К\or Л\or М\or Н\or О\or
+\newcommand{\ukrainiannumerals}[2]{\ukrainiannumber{#2}}
+\newcommand{\Ukrainiannumerals}[2]{\Ukrainiannumber{#2}}
+
+\def\ukrainiannumber#1{%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
+  \else
+    \number#1%
+  \fi%
+}
+
+\def\Ukrainiannumber#1{%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
+  \else
+    \number#1%
+  \fi%
+}
+
+\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\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.
+\def\ukranian 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 Я\else\xpg at ill@value{#1}{ukrainian at Alph}\fi}
-\def\asbuk#1{\expandafter\ukrainian at alph\csname c@#1\endcsname}
-\def\ukrainian at 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 Я%
+   \else\xpg at ill@value{#1}{ukranian at asbuk@Alph}\fi%
+}
+
+\def\ukranian 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 я\else\xpg at ill@value{#1}{ukrainian at alph}\fi}
+   ц\or ч\or ш\or щ\or э\or ю\or я%
+   \else\xpg at ill@value{#1}{ukranian at asbuk@alph}\fi%
+}
 
 \def\ukrainian at numbers{%
    \let\@Alph\ukrainian at Alph%
@@ -13911,19 +17394,19 @@
 }
 
 \def\noextras at ukrainian{%
-\def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
-\ifcyrillic at numerals\noukrainian at numbers\fi
-\noukrainian at shorthands%
+  \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
+  \ifcyrillic at numerals\noukrainian at numbers\fi
+  \noukrainian at shorthands%
 }
 
 \def\blockextras at ukrainian{%
-\ukrainian at capsformat%
-\ifcyrillic at numerals\ukrainian at numbers\fi
-\ifukrainian at babelshorthands\ukrainian at shorthands\fi
+  \ukrainian at capsformat%
+  \ifcyrillic at numerals\ukrainian at numbers\fi
+  \ifukrainian at babelshorthands\ukrainian at shorthands\fi
 }
 
 \def\inlineextras at ukrainian{%
-\ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
 }
 
 %%% stuff from Babel
@@ -13985,6 +17468,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{urdu}{
+  bcp47=ur,
   script=Arabic,
   direction=RL,
   scripttag=arab,
@@ -13995,6 +17479,9 @@
   %TODO localalph={abjad,abjad}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{urdu}{ur}
+
 \newif\if at western@numerals
 \def\tmp at western{western}
 \define at key{urdu}{numerals}[eastern]{%
@@ -14147,6 +17634,7 @@
 %% Strings contributed by Daniel Owens < dhowens . pmbx . net >
 
 \PolyglossiaSetup{vietnamese}{
+  bcp47=vi,
   hyphennames={nohyphenation},
   hyphenmins={2,2},
   langtag=VIT,
@@ -14154,6 +17642,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{vietnamese}{vi}
+
 \def\captionsvietnamese{%
   \def\refname{Tài liệu}%
   \def\abstractname{Tóm tắt nội dung}%
@@ -14197,6 +17688,7 @@
 \ProvidesFile{gloss-welsh.ldf}[polyglossia: module for welsh]
 
 \PolyglossiaSetup{welsh}{
+  bcp47=cy,
   hyphennames={welsh},
   hyphenmins={2,3},
   langtag=WEL,
@@ -14203,15 +17695,25 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{welsh}{cy}
+
 \providebool{welsh at formaldate}
 
-% TODO (maybe) Interface to change that mid-document
-\define at key{welsh}{date}{%
-  \ifstrequal{#1}{long}{%
-    \welsh at formaldatetrue
-  }% Anything else gives \welsh at formaldatefalse
-}
+\define at choicekey*+{welsh}{date}[\val\nr]{long,short}[short]{%
+   \ifcase\nr\relax
+      % long:
+      \welsh at formaldatetrue
+   \or
+      % accented:
+      \welsh at formaldatefalse
+   \fi
+   \xpg at info{Option: Welsh, date=\val}%
+}{\xpg at warning{Unknown date value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{welsh}{date=short}
+
 \def\captionswelsh{%
   \def\refname{Cyfeiriadau}%
   \def\abstractname{Crynodeb}%
@@ -14441,6 +17943,7 @@
     set_left_space(lang, '⁇', 0.5)
     set_left_space(lang, '⁈', 0.5)
     set_left_space(lang, '⁉', 0.5)
+    set_left_space(lang, '‽', 0.5) -- U+203D (interrobang)
 
     if autospaceguillemets then
         set_left_space(lang, '»', 0.5)
@@ -14887,14 +18390,19 @@
     local curr, tone = node.slide(head)
     while curr do
         if curr.id == glyph_id and node.has_attribute(curr, attr_korean) then
-            local c, wd = curr.char or 0, curr.width or 0
-            if (c == 0x302E or c == 0x302F) and wd > 0 then
-                tone = curr
-            elseif tone and not nobr_before[c] then
-                head = node.remove(head, tone)
-                tone.next, tone.prev = nil, nil
-                head, curr = node.insert_before(head, curr, tone)
+            local f = font.getfont(curr.font) or font.fonts[curr.font]
+            if f and f.hb then -- harfbuzz do the right thing
                 tone = nil
+            else
+                local c, wd = curr.char or 0, curr.width or 0
+                if (c == 0x302E or c == 0x302F) and wd > 0 then
+                    tone = curr
+                elseif tone and not nobr_before[c] then
+                    head = node.remove(head, tone)
+                    tone.next, tone.prev = nil, nil
+                    head, curr = node.insert_before(head, curr, tone)
+                    tone = nil
+                end
             end
         end
         curr = curr.prev
@@ -15085,21 +18593,31 @@
 -- between 1/4 and 1/3 of a quad. We choose a half of a \thinspace here.
 local hairspace = 0.08333 -- 1/12
 
+local function space_left(char)
+    polyglossia.add_left_spaced_character('latin', char, hairspace, 'quad')
+end
+
+local function space_right(char)
+    polyglossia.add_right_spaced_character('latin', char, hairspace, 'quad')
+end
+
+polyglossia.clear_spaced_characters('latin')
+space_left('!')
+space_left('?')
+space_left('‼')
+space_left('⁇')
+space_left('⁈')
+space_left('⁉')
+space_left('‽') -- U+203D (interrobang)
+space_left(':')
+space_left(';')
+space_left('»')
+space_left('›')
+space_right('«')
+space_right('‹')
+
 local function activate_latin_punct()
     polyglossia.activate_punct('latin')
-    polyglossia.clear_spaced_characters('latin')
-    polyglossia.add_left_spaced_character('latin',':',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','!',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','?',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin',';',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','‼',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁇',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁈',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁉',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','»',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','›',hairspace,'quad')
-    polyglossia.add_right_spaced_character('latin','«',hairspace,'quad')
-    polyglossia.add_right_spaced_character('latin','‹',hairspace,'quad')
 end
 
 local function deactivate_latin_punct()
@@ -15180,13 +18698,55 @@
     return node_copy(penalty_node)
 end
 
--- we have here all possible space characters, referenced by their unicode slot
--- number, taken from char-def.lua
-local space_chars = {[32] = true, [160] = true, [5760] = true, [6158] = true,
-    [8192] = true, [8193] = true, [8194] = true, [8195] = true, [8196] = true,
-    [8197] = true, [8198] = true, [8199] = true, [8200] = true, [8201] = true,
-    [8202] = true, [8239] = true, [8287] = true, [12288] = true}
+-- all possible space characters according to section 6.2 of the Unicode Standard
+-- https://www.unicode.org/versions/Unicode12.0.0/ch06.pdf
+local space_chars = {
+    [0x20] = true, -- space
+    [0xA0] = true, -- no-break space
+    [0x1680] = true, -- ogham space mark
+    [0x2000] = true, -- en quad
+    [0x2001] = true, -- em quad
+    [0x2002] = true, -- en space
+    [0x2003] = true, -- em space
+    [0x2004] = true, -- three-per-em-space
+    [0x2005] = true, -- four-per-em space
+    [0x2006] = true, -- six-per-em space
+    [0x2007] = true, -- figure space
+    [0x2008] = true, -- punctuation space
+    [0x2009] = true, -- thin space
+    [0x200A] = true, -- hair space
+    [0x202F] = true, -- narrow no-break space
+    [0x205F] = true, -- medium mathematical space
+    [0x3000] = true -- ideographic space
+}
 
+-- all left bracket characters, referenced by their Unicode slot
+local left_bracket_chars = {
+    [0x28] = true, -- left parenthesis
+    [0x5B] = true, -- left square bracket
+    [0x7B] = true, -- left curly bracket
+    [0x27E8] = true -- mathematical left angle bracket
+}
+
+-- all right bracket characters, referenced by their Unicode slot
+local right_bracket_chars = {
+    [0x29] = true, -- right parenthesis
+    [0x5D] = true, -- right square bracket
+    [0x7D] = true, -- right curly bracket
+    [0x27E9] = true -- mathematical right angle bracket
+}
+
+-- question and exclamation marks, referenced by their Unicode slot
+local question_exclamation_chars = {
+    [0x21] = true, -- exclamation mark !
+    [0x3F] = true, -- question mark ?
+    [0x203C] = true, -- double exclamation mark ‼
+    [0x203D] = true, -- interrobang ‽
+    [0x2047] = true, -- double question mark ⁇
+    [0x2048] = true, -- question exclamation mark ⁈
+    [0x2049] = true, -- exclamation question mark ⁉
+}
+
 -- from nodes-tst.lua, adapted
 local function somespace(n)
     if n then
@@ -15203,9 +18763,6 @@
     end
 end
 
--- we have here all left bracket characters, referenced by their unicode slot
-local left_bracket_chars = {[40] = true, [123] = true, [91] = true, [10216] = true}
-
 local function someleftbracket(n)
     if n then
         local id = n.id
@@ -15215,9 +18772,6 @@
     end
 end
 
--- we have here all right bracket characters, referenced by their unicode slot
-local right_bracket_chars = {[41] = true, [125] = true, [93] = true, [10217] = true}
-
 local function somerightbracket(n)
     if n then
         local id = n.id
@@ -15227,6 +18781,16 @@
     end
 end
 
+local function question_exclamation_sequence(n1, n2)
+    if n1 and n2 then
+        local id1 = n1.id
+        local id2 = n2.id
+        if id1 == glyph_code and id2 == glyph_code then
+            return question_exclamation_chars[n1.char] and question_exclamation_chars[n2.char]
+        end
+    end
+end
+
 -- idem
 local function somepenalty(n, value)
     if n then
@@ -15312,13 +18876,13 @@
                 if leftspace or rightspace then
                     local fontparameters = fonts.hashes.parameters[current.font]
                     local unit, stretch, shrink, spacing_node
-                    if leftspace then
+                    if leftspace and fontparameters then
                         local prev = getprev(current)
                         local space_exception = false
                         if prev then
                             local prevprev = getprev(prev)
-                            -- do not add space after left (opening) bracket
-                            space_exception = someleftbracket(prev)
+                            -- do not add space after left (opening) bracket and between question/exclamation marks
+                            space_exception = someleftbracket(prev) or question_exclamation_sequence(prev, current)
                             if somespace(prev) then
                             -- TODO: there is a question here: do we override a preceding space or not?...
                                 if somepenalty(prevprev, 10000) then
@@ -15345,7 +18909,7 @@
                             head = insert_node_before(head, current, spacing_node)
                         end
                     end
-                    if rightspace then
+                    if rightspace and fontparameters then
                         local next = getnext(current)
                         local space_exception = false
                         if next then
@@ -15440,19 +19004,25 @@
 -- value.
 local thinspace = 0.16667 -- 1/6
 
+local function space_left(char)
+    polyglossia.add_left_spaced_character('sanskrit', char, thinspace, 'quad')
+end
+
+polyglossia.clear_spaced_characters('sanskrit')
+space_left('!')
+space_left('?')
+space_left('‼')
+space_left('⁇')
+space_left('⁈')
+space_left('⁉')
+space_left('‽') -- U+203D (interrobang)
+space_left(':')
+space_left(';')
+space_left('।') -- danda, U+0964
+space_left('॥') -- double danda, U+0965
+
 local function activate_sanskrit_punct()
     polyglossia.activate_punct('sanskrit')
-    polyglossia.clear_spaced_characters('sanskrit')
-    polyglossia.add_left_spaced_character('sanskrit','!',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','?',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','‼',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁇',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁈',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁉',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit',':',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit',';',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','।',thinspace,'quad') -- danda, U+0964
-    polyglossia.add_left_spaced_character('sanskrit','॥',thinspace,'quad') -- double danda, U+0965
 end
 
 local function deactivate_sanskrit_punct()
@@ -15767,7 +19337,7 @@
 
    ¦----------------------------------------------¦
    ¦                                              ¦
-   ¦       THE POLYGLOSSIA PACKAGE v1.46          ¦
+   ¦       THE POLYGLOSSIA PACKAGE v1.47          ¦
    ¦                                              ¦
    ¦     Modern multilingual typesetting          ¦
    ¦        with XeLaTeX and LuaLaTeX             ¦
@@ -15800,8 +19370,8 @@
 
 LICENSE
 
-Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2019 Arthur Reutenauer,
-Copyright (c) 2019 Bastien Roucariès, 2019 Jürgen Spitzmüller
+Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2020 Arthur Reutenauer,
+Copyright (c) 2019-2020 Bastien Roucariès, 2019-2020 Jürgen Spitzmüller
 
 Except where otherwise noted, Polyglossia is placed under the terms of the MIT licence
 (https://opensource.org/licenses/MIT).
@@ -15815,6 +19385,69 @@
 to track the issues and follow progress.
 %</../README>
 %<*Changelog>
+1.47 (29-01-2020)
+
+New features:
+  * IETF BCP-47 compliant language tags can now be used for loading and switching
+    languages alternatively to language names (#226).
+  * New commands \languageid{<type>} and \mainlanguageid{<type>}.
+  * New test \iflanguageidloaded.
+  * New list \xpg at bcp@loaded.
+  * New environment {lang}{<lang>} (equivalent to {<lang>},  but also available with
+    \setlanguagealias* which does not define dedicated alias environments).
+  * New gloss option totalhyphenmin (corresponds to LuaTeX's \hyphenationmin) (#111).
+  * New test \iflanguageoption{<lang>}{<key>}{<val>} (#364).
+  * Restore simple alphabetic numbering for \asbuk and \Asbuk in Belarusian, Mongolian,
+    Russian, Serbian, and Ukrainian (#377).
+  * New command \AsbukTrad and \asbukTrad for Belarusian, Mongolian, Russian, Serbian,
+    and Ukrainian which uses traditional alphanumerical numbering.
+  * New numerals option "cyrillic-trad" and "cyrillic-alph" to differentiate simple
+    alphabetic and traditional alpnanumerical Cyrillic numbering.
+  * \selectbackgroundlanguage and \resetdefaultlanguage now also support language
+    aliases.
+  * New macro \charifavailable{<char code>}{<substitution>}.
+  * Add French language variant "swiss".
+  * Implement babelshorthands for Croatian.
+  * Implement \localnumeral for Japanese.
+
+Bug fixes:
+  * Fix font family issue in headers (#355).
+  * Fix whitespace issues in \text<lang> (#356).
+  * Fix option-less \babelname in multi-variant languages (#357).
+  * Fix some spacing inconsistencies with French, Latin, and Sanskrit (#358).
+  * Fix issues with babelshorthands and graphics package (#368).
+  * Fix some captions and improve numbering in Marathi (#370).
+  * Fix Hungarian swapstrings feature (#373).
+  * Fix lua punctuation code problem (#374).
+  * Fix Bengali changecounternumbering option (#381).
+  * Fix whitespace issue in Japanese (#387).
+  * Fix \text<lang> command with multiple paragraphs.
+  * Actually implement documented german spelling variant '1996' (= 'new').
+  * Fix Slovenian localalph option.
+  * Fix Czech and Slovak splithyphens with typewriter fonts.
+  * farsical.sty: fix spacing issue with some month names.
+  * Fix directionalty of numbers in Hebrew with XeTeX.
+  * Improve interoperatability with biblatex (some language variants did not work yet).
+
+Interface and defaults changes:
+  * Some boolean options had 'false' value by default, which meant if you passed
+    them without value, the logic was reversed. This has been changed, leading to
+    change of behavior should you have used one of these options without value (#363).
+    Concerned are the following options:
+    - babelshorthands in language belarusian, mongolian, ukrainian, and russian
+      ('babelshorthands' now equals 'babelshorthand=true', no longer 'babelshorthands=false')
+    - localalph in language slovenian ('localalph' now equals 'localalph=true')
+    - latesthyphen in language german ('latesthyphen' now equals 'latesthyphen=true')
+    - fullyear in package hebrewcal ('fullyear' now equals 'fullyear=true')
+  * The command \setlanguagealias* (introduced in v1.46) does no longer define
+    dedicated alias environments.
+  * The babelnames for latin variants have been corrected to classiclatin, ecclesiasticlatin
+    and medievallatin. This is how the hyphenation patterns and babel \extras are named, even
+    though the variants can currently be selected in babel only via appended "dot modifier".
+  * In accordance with the respective l3kernel change, \str_lower_case:n  has been renamed to
+    \str_lowercase:n where used in polyglossia.sty. Thus polyglossia 1.47 requires l3kernel
+    2020-01-12 at least.
+
 1.46 (15-11-2019)
 
 New features:

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/farsical.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/farsical.sty	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/farsical.sty	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,5 @@
 \ProvidesPackage{farsical}
-        [2008/07/02 v0.1 %
+        [2019/12/12 v0.2 %
          Farsi (jalali) calendar]
 \ifluatex\RequirePackage{luabidi}\else\RequirePackage{bidi}\fi
 \RequirePackage{calc,arabicnumbers}
@@ -197,7 +197,7 @@
 \or مهر\or آبان\or آذر\or دی\or بهمن\or اسفند%
 \fi}
 \def\JalalimonthEnglish#1{\ifcase#1%
-\or Farvardīn\or Ordībehesht\or Khordād\or Tīr
-\or Mordād\or Shahrīvar\or Mihr\or Ābān\or Āzar
+\or Farvardīn\or Ordībehesht\or Khordād\or Tīr%
+\or Mordād\or Shahrīvar\or Mihr\or Ābān\or Āzar%
 \or Dai\or Bahman\or Esfand\fi}
 \endinput

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-aeb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-aeb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-aeb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-aeb.ldf}[polyglossia: module for aeb (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-aeb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-af.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-af.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-af.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-af.ldf}[polyglossia: module for af (afrikaans)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{afrikaans}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-af.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-afb.ldf}[polyglossia: module for afb (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-afrikaans.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-afrikaans.ldf}[polyglossia: module for afrikaans]
 
 \PolyglossiaSetup{afrikaans}{
+  bcp47=af,
   hyphennames={afrikaans,dutch},
   hyphenmins={2,2},
   langtag=AFK,
@@ -8,8 +9,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{afrikaans}{af}
+
 \define at boolkey{afrikaans}[afrikaans@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{afrikaans}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{afrikaans}{babelshorthands=true}
 \else

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-albanian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-albanian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-albanian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-albanian.ldf}[polyglossia: module for albanian]
 
 \PolyglossiaSetup{albanian}{
+  bcp47=sq,
   hyphennames={albanian},
   langtag=SQI,
   hyphenmins={2,2},
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{albanian}{sq}
+
 \def\captionsalbanian{%
    \def\refname{Referencat}%
    \def\abstractname{Përmbledhja}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-am.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-am.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-am.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-am.ldf}[polyglossia: module for am (amharic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{amharic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-am.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-amharic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-amharic.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-amharic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-amharic.ldf}[polyglossia: module for amharic]
 \PolyglossiaSetup{amharic}{
+  bcp47=am,
   script=Ethiopic,
   scripttag=ethi,
   langtag=AMH,
@@ -9,6 +10,9 @@
   %TODO localalph=ethnum
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{amharic}{am}
+
 \def\captionsamharic{%
    \def\refname{የነሥ ጹሁፍ ምንጭ}%
    \def\abstractname{አኅጽተሮ ጽሁፍ}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-apd.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-apd.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-apd.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-apd.ldf}[polyglossia: module for apd (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-apd.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-IQ.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-IQ.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-IQ.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-IQ.ldf}[polyglossia: module for ar-IQ (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-IQ.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-JO.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-JO.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-JO.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-JO.ldf}[polyglossia: module for ar-JO (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-JO.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-LB.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-LB.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-LB.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-LB.ldf}[polyglossia: module for ar-LB (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-LB.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-MR.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-MR.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-MR.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-MR.ldf}[polyglossia: module for ar-MR (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-MR.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-PS.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-PS.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-PS.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-PS.ldf}[polyglossia: module for ar-PS (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-PS.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-SY.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-SY.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-SY.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-SY.ldf}[polyglossia: module for ar-SY (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-SY.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-YE.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-YE.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-YE.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar-YE.ldf}[polyglossia: module for ar-YE (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar-YE.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ar.ldf}[polyglossia: module for ar (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ar.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arabic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -10,6 +10,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{arabic}{
+  bcp47=ar,
   script=Arabic,
   direction=RL,
   langtag=ARA,
@@ -21,6 +22,23 @@
   %TODO localalph={abjad,abjad}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{arabic}{ar}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-IQ}
+\setlanguagealias*[locale=default]{arabic}{ar-YE}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-LB}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-JO}
+\setlanguagealias*[locale=default]{arabic}{afb}
+\setlanguagealias*[locale=mauritania]{arabic}{ar-MR}
+\setlanguagealias*[locale=default]{arabic}{arz}
+\setlanguagealias*[locale=morocco]{arabic}{ary}
+\setlanguagealias*[locale=algeria]{arabic}{arq}
+\setlanguagealias*[locale=tunisia]{arabic}{aeb}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-SY}
+\setlanguagealias*[locale=libya]{arabic}{ayl}
+\setlanguagealias*[locale=default]{arabic}{apd}
+\setlanguagealias*[locale=mashriq]{arabic}{ar-PS}
+
 \newif\ifeastern at numerals
 \def\tmp at mashriq{mashriq}
 \def\tmp at maghrib{maghrib}
@@ -47,9 +65,11 @@
   \def\@tmpa{#1}%
   \ifx\@tmpa\tmp at morocco%
     \eastern at numeralsfalse%
+    \SetLanguageKeys{arabic}{bcp47=ary}%
   \else
     \ifx\@tmpa\tmp at algeria%
       \eastern at numeralsfalse%
+      \SetLanguageKeys{arabic}{bcp47=arq}%
     \fi%
   \fi%
   \gdef\@@arabic at month{\@arabic at month{#1}}}
@@ -69,8 +89,10 @@
 \define at key{arabic}{hijricorrection}[0]{%
   \gdef\@hijri at correction{#1}}%
 
-% This should set the defaults
-\setkeys{arabic}{locale,calendar,numerals,hijricorrection,abjadjimnotail=false}
+% Register default options
+\xpg at initialize@gloss at options{arabic}{locale=default,calendar=gregorian,numerals=mashriq,hijricorrection=0,abjadjimnotail=false}
+% Register alias options
+\xpg at set@alias at values{arabic}{calendar}{islamic}{hijri}
 
 \def\arabicgregmonth at default#1{\ifcase#1%
   % Egypt, Sudan, Yemen and Golf states

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-armenian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-armenian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-armenian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-armenian.ldf}[polyglossia: module for armenian]
 
 \PolyglossiaSetup{armenian}{
+  bcp47=hy,
   script=Armenian,
   scripttag=armn,
   langtag=HYE,
@@ -10,6 +11,9 @@
   localnumeral=armeniannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{armenian}{hy}
+
 \newif\if at eastern@armenian
 \@eastern at armenianfalse
 \define at choicekey*+{armenian}{variant}[\val\nr]{western,eastern}[western]{%
@@ -29,6 +33,9 @@
   \ifstrequal{#1}{arabic}{\@armenian at numeralsfalse}{\@armenian at numeralstrue}%
 }
 
+% Register default options
+\xpg at initialize@gloss at options{armenian}{numerals=armenian,variant=western}
+
 % Taken from ArmTeX. Audit!
 \def\captionsarmenian{%
    \def\refname{Հղումներ}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arq.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arq.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arq.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-arq.ldf}[polyglossia: module for arq (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arq.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ary.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ary.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ary.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ary.ldf}[polyglossia: module for ary (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ary.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arz.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arz.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arz.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-arz.ldf}[polyglossia: module for arz (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-arz.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ast.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ast.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ast.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ast.ldf}[polyglossia: module for ast (asturian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{asturian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ast.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-asturian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-asturian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-asturian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -3,6 +3,7 @@
 %
 \ProvidesFile{gloss-asturian.ldf}[polyglossia: module for asturian]
 \PolyglossiaSetup{asturian}{
+  bcp47=ast,
   hyphennames={asturian,catalan},
   hyphenmins={2,2},
   langtag=AST,
@@ -11,6 +12,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{asturian}{ast}
+
 \def\captionsasturian{%
    \def\prefacename{Entamu}%
    \def\refname{Referencies}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-austrian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-austrian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-austrian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,4 +1,4 @@
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for austrian german (old spelling)]
+\ProvidesFile{gloss-austrian.ldf}[polyglossia: module for austrian german (old spelling)]
 
 % We provide this as a babel alias
 

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ayl.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ayl.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ayl.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ayl.ldf}[polyglossia: module for ayl (arabic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{arabic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ayl.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bahasa.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bahasa.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bahasa.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,7 +1,7 @@
-\ProvidesFile{gloss-kurmanji.ldf}[polyglossia: module for kurmanji kurdish]
+\ProvidesFile{gloss-bahasa.ldf}[polyglossia: module for bahasa indonesia]
 
 % We provide this as a babel alias
 
-\xpg at load@master at language{kurdish}
+\xpg at load@master at language{malay}
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-basque.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-basque.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-basque.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-basque.ldf}[polyglossia: module for basque]
 \PolyglossiaSetup{basque}{
+  bcp47=eu,
   hyphennames={basque},
   hyphenmins={2,2},
   langtag=EUQ,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{basque}{eu}
+
 \def\captionsbasque{%
    \def\refname{Erreferentziak}%
    \def\abstractname{Laburpena}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be-tarask.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be-tarask.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be-tarask.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-be-tarask.ldf}[polyglossia: module for be-tarask (belarusian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{belarusian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be-tarask.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-be.ldf}[polyglossia: module for be (belarusian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{belarusian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-be.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-belarusian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -3,6 +3,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{belarusian}{
+  bcp47=be,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=BEL,
@@ -14,30 +15,56 @@
   Localnumeral=Belarusiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[spelling=classic]{belarusian}{be-tarask}
+\setlanguagealias*{belarusian}{be}
+
 \def\belarusian at spelling{modern}
 \define at choicekey*+{belarusian}{spelling}[\val\nr]{modern,classic,tarask}[modern]{%
    \ifcase\nr\relax
       % modern:
-      \def\belarusian at spelling{modern}
+      \def\belarusian at spelling{modern}%
+      \SetLanguageKeys{belarusian}{bcp47=be}%
    \or
       % classic:
-      \def\belarusian at spelling{tarask}
+      \def\belarusian at spelling{tarask}%
+      \SetLanguageKeys{belarusian}{bcp47=be-tarask}%
    \or
       % tarask:
-      \def\belarusian at spelling{tarask}
+      \def\belarusian at spelling{tarask}%
+      \SetLanguageKeys{belarusian}{bcp47=be-tarask}%
    \fi
 }{\xpg at warning{Unknown Belarusian spelling `#1'}}
 
 \newif\ifcyrillic at numerals
-\define at key{belarusian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{belarusian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Belarusian, numerals=\val}%
+}{\xpg at warning{Unknown Belarusian numerals value `#1'}}
 
-\define at boolkey{belarusian}[belarusian@]{babelshorthands}[false]{}
+\define at boolkey{belarusian}[belarusian@]{babelshorthands}[true]{}
 
-\setkeys{belarusian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{belarusian}{babelshorthands=false,numerals=arabic,spelling=modern}
+% Register alias options
+\xpg at set@alias at values{belarusian}{spelling}{classic}{tarask}
 
 \ifsystem at babelshorthands
   \setkeys{belarusian}{babelshorthands=true}
@@ -202,7 +229,11 @@
 
 \def\belarusiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \belarusian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -210,7 +241,11 @@
 
 \def\Belarusiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \belarusian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -219,25 +254,31 @@
 \let\belarusiannumeral=\belarusiannumber
 \let\Belarusiannumeral=\Belarusiannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\belarusian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\belarusian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
+
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\belarusian 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 Я%
+   \else\xpg at ill@value{#1}{belarusian at asbuk@Alph}\fi%
+}
 
-%\def\belarusian at 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 Я\else\xpg at ill@value{#1}{belarusian at Alph}\fi}
+\def\belarusian 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 я%
+   \else\xpg at ill@value{#1}{belarusian at asbuk@alph}\fi%
+}
 
-%\def\belarusian at 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 я\else\xpg at ill@value{#1}{belarusian at alph}\fi}
-
 \def\belarusian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bengali.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bengali.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bengali.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,16 +2,19 @@
 % TODO implement Bengali calendar
 
 \ProvidesFile{gloss-bengali.ldf}[polyglossia: module for bengali]
+
 \ifluatex
   \xpg at warning{Bengali is not supported with LuaTeX.\MessageBreak
-I will proceed with the compilation, but\MessageBreak
-the output is not guaranteed to be correct\MessageBreak
-and may look very wrong.}
+               I will proceed with the compilation, but\MessageBreak
+               the output is not guaranteed to be correct\MessageBreak
+               and may look very wrong.}
 \fi
+
 \RequirePackage{devanagaridigits}
 \RequirePackage{bengalidigits}
 
 \PolyglossiaSetup{bengali}{
+  bcp47=bn,
   script=Bengali,
   scripttag=beng,
   langtag=BEN,
@@ -22,56 +25,36 @@
   %TODO nouppercase=true,
 }
 
-\def\tmp at western{Western}
+% BCP-47 compliant aliases
+\setlanguagealias*{bengali}{bn}
+
 \newif\ifbengali at devanagari@numerals
-\bengali at devanagari@numeralstrue
-\def\tmp at bengali{Bengali}
 \newif\ifbengali at bengali@numerals
-\bengali at bengali@numeralsfalse % Implied, but you never know
+\define at choicekey*+{bengali}{numerals}[\val\nr]{Devanagari,Bengali,Western}[Devanagari]{%
+   \ifcase\nr\relax
+      % Devanagari:
+      \bengali at bengali@numeralsfalse%
+      \bengali at devanagari@numeralstrue%
+   \or
+      % Bengali:
+      \bengali at bengali@numeralstrue%
+      \bengali at devanagari@numeralsfalse%
+   \or
+      % Western:
+      \bengali at bengali@numeralsfalse%
+      \bengali at devanagari@numeralsfalse%
+   \fi
+   \xpg at info{Option: Bengali, numerals=\val}%
+}{\xpg at warning{Unknown Bengali numeral `#1'}}
 
-
-\define at key{bengali}{numerals}[Devanagari]{%
-  \def\@tmpa{#1}%
-  \ifx\@tmpa\tmp at western
-    \bengali at devanagari@numeralsfalse
-  \else\ifx\@tmpa\tmp at bengali
-    \bengali at devanagari@numeralsfalse
-    \bengali at bengali@numeralstrue\fi
-  \fi}
-
 \def\extras at bengali{}
 \def\noextras at bengali{}
 
-\define at boolkey{bengali}[bengali@]{changecounternumbering}{
-  \def\@tmpa{#1}
-  \def\@tmptrue{true}
-  \ifx\@tmpa\@tmptrue
-    \def\extras at bengali{%
-      % FIXME Tied to the article class!  And horrible coding style
-      \let\savethepage\thepage
-      \let\savethesection\thesection
-      \let\savethesubsection\thesubsection
-      \let\savethesubsubsection\thesubsubsection
-      \let\savetheparagraph\theparagraph
-      \let\savethesubparagraph\thesubparagraph
-      \def\thepage{\bengalinumeral{page}}
-      \def\thesection{\bengalinumeral{section}}
-      \def\thesubsection{\bengalinumeral{subsection}}
-      \def\thesubsubsection{\bengalinumeral{subsubsection}}
-      \def\theparagraph{\bengalinumeral{paragraph}}
-      \def\thesubparagraph{\bengalinumeral{subparagraph}}
-    }
-    \def\noextras at bengali{%
-      \let\thepage\savethepage
-      \let\thesection\savethesection
-      \let\thesubsection\savethesubsection
-      \let\thesubsubsection\savethesubsubsection
-      \let\theparagraph\savetheparagraph
-      \let\thesubparagraph\savethesubparagraph
-    }
-  \fi
-}
+\define at boolkey{bengali}[bengali@]{changecounternumbering}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{bengali}{changecounternumbering=false,numerals=Devanagari}
+
 \def\captionsbengali{%
   \def\refname{তথ্যসূত্রসমূহ}%
   \def\abstractname{সারসংক্ষেপ}%
@@ -125,13 +108,19 @@
     \else % Assumed Western
       \number#1%
     \fi
-  \fi}
+  \fi%
+}
 
-\def\bengalinumeral#1{\expandafter\bengalinumber\expandafter{\the##1}}% Takes counter
+% Backwards compatibility. This command was never documented, but
+% some people might use it nevertheless (see #381).
+% This takes a counter.
+\newcommand\bengalinumeral[1]{\localnumeral*[lang=bengali]{#1}}
 
 \def\bengali at globalnumbers{%
-   \let\@arabic\bengalinumber%
-   \renewcommand\thefootnote{\localnumeral*{footnote}}%
+   \ifbengali at changecounternumbering
+     \let\@arabic\bengalinumber%
+     \renewcommand\thefootnote{\localnumeral*{footnote}}%
+  \fi
 }
 
 % Store original definition

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bg.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bg.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bg.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-bg.ldf}[polyglossia: module for bg (bulgarian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bulgarian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bg.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-bn.ldf}[polyglossia: module for bn (bengali)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bengali}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bo.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bo.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bo.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-bo.ldf}[polyglossia: module for bo (tibetan)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{tibetan}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bo.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bosnian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-bosnian.ldf}[polyglossia: module for bosnian]
 
 \PolyglossiaSetup{bosnian}{
+  bcp47=bs,
   langtag=BOS,
   hyphennames={bosnian,croatian},
   hyphenmins={2,2}, % adapted from gloss-croatian
@@ -9,6 +10,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{bosnian}{bs}
+
 % TODO: Add script=Cyrillic
 
 % from babel-bosnian

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-br.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-br.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-br.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-br.ldf}[polyglossia: module for br (breton)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{breton}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-br.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-breton.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-breton.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-breton.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-breton.ldf}[polyglossia: module for breton]
 \PolyglossiaSetup{breton}{
+  bcp47=br,
   hyphennames={breton},
   hyphenmins={2,2},
   langtag=BRE,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{breton}{br}
+
 \ifluatex
   % TODO
 \else

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-british.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-british.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-british.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,4 +1,4 @@
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for british english]
+\ProvidesFile{gloss-british.ldf}[polyglossia: module for british english]
 
 % We provide this as a babel alias
 

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bs.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bs.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bs.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-bs.ldf}[polyglossia: module for bs (bosnian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{bosnian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bs.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bulgarian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bulgarian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-bulgarian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-bulgarian.ldf}[polyglossia: module for bulgarian]
 \PolyglossiaSetup{bulgarian}{
+  bcp47=bg,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=BGR,
@@ -10,6 +11,9 @@
   %TODO localalph=bulgarian at alph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{bulgarian}{bg}
+
 \def\bulgarian at Alph#1{%
    \ifcase#1\or
    А\or Б\or В\or Г\or Д\or Е\or Ж\or

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ca.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ca.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ca.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ca.ldf}[polyglossia: module for ca (catalan)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{catalan}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ca.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-canadien.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-canadien.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-canadien.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,4 +1,4 @@
-\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for canadian french]
+\ProvidesFile{gloss-canadien.ldf}[polyglossia: module for canadian french]
 
 % We provide this as a babel alias
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-catalan.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-catalan.ldf}[polyglossia: module for catalan]
 \PolyglossiaSetup{catalan}{
+  bcp47=ca,
   hyphennames={catalan},
   hyphenmins={2,2},
   langtag=CAT,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{catalan}{ca}
+
 \define at boolkey{catalan}[catalan@]{babelshorthands}[true]{}
 \ifsystem at babelshorthands
   \setkeys{catalan}{babelshorthands=true}
@@ -15,6 +19,9 @@
   \setkeys{catalan}{babelshorthands=false}
 \fi
 
+% Register default options
+\xpg at initialize@gloss at options{catalan}{babelshorthands=false}
+
 \ifcsundef{initiate at active@char}{%
   \input{babelsh.def}%
   \initiate at active@char{"}%
@@ -23,18 +30,12 @@
 
 %%% adapted from Babel's catalan.ldf
 \newdimen\leftllkern \newdimen\rightllkern \newdimen\raiselldim
+
 % we check if char · exists, and use it instead of raised dot:
 \def\xpg at raiseddot{%
-  \ifluatex %
-    \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\hbox{\char"00B7}%
-    \else\raise\raiselldim\hbox{.}%
-    \fi %
-  \else %
-    \ifnum\XeTeXcharglyph"00B7 > 0\hbox{\char"00B7}% why a hbox here?
-      \else\raise\raiselldim\hbox{.}%
-    \fi %
-  \fi %
-  }
+  \charifavailable{00B7}{\raise\raiselldim\hbox{.}}%
+}
+
 \def\lgem{%
   \ifmmode
     \csname normal at char\string"\endcsname l%
@@ -41,15 +42,9 @@
   \else
     \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
     \setbox0\hbox{l}\setbox1\hbox{l\/}%
-    \ifluatex %
-      \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\setbox2\hbox{\char"00B7}%
-      \else\setbox2\hbox{.}%
-      \fi %
-    \else %
-      \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}%
-        \else\setbox2\hbox{.}%
-      \fi %
-    \fi %
+    \xpg at if@char at available{00B7}%
+          {\setbox2\hbox{\char"00B7}}%
+          {\setbox2\hbox{.}}%
     \advance\raiselldim by \the\fontdimen5\the\font
     \advance\raiselldim by -\ht2%
     \leftllkern=-.25\wd0%
@@ -63,6 +58,7 @@
       \kern\rightllkern\hbox{l}}\allowhyphens
   \fi
 }
+
 \def\Lgem{%
   \ifmmode
     \csname normal at char\string"\endcsname L%
@@ -69,15 +65,9 @@
   \else
     \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
     \setbox0\hbox{L}\setbox1\hbox{L\/}%
-    \ifluatex %
-      \expandafter\ifnum\directlua{polyglossia.check_char(183)} > 0\setbox2\hbox{\char"00B7}%
-      \else\setbox2\hbox{.}%
-      \fi %
-    \else %
-      \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}%
-        \else\setbox2\hbox{.}%
-      \fi %
-    \fi %
+    \xpg at if@char at available{00B7}%
+          {\setbox2\hbox{\char"00B7}}%
+          {\setbox2\hbox{.}}%
     \advance\raiselldim by .5\ht0%
     \advance\raiselldim by -.5\ht2%
     \leftllkern=-.125\wd0%
@@ -92,6 +82,7 @@
       \kern\rightllkern\hbox{L}}\allowhyphens
   \fi
 }
+
 \AtBeginDocument{%
   \let\lslash\l
   \let\Lslash\L

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Arab.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Arab.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Arab.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ckb-Arab.ldf}[polyglossia: module for ckb-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Arab.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Latn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Latn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Latn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ckb-Latn.ldf}[polyglossia: module for ckb-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb-Latn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ckb.ldf}[polyglossia: module for ckb (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ckb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cop.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cop.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cop.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-cop.ldf}[polyglossia: module for cop (coptic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{coptic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cop.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-coptic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-coptic.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-coptic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-coptic.ldf}[polyglossia: module for coptic]
 \PolyglossiaSetup{coptic}{
+  bcp47=cop,
   script=Coptic,
   scripttag=copt,
   langtag=COP,
@@ -8,6 +9,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{coptic}{cop}
+
 %\def\captionscoptic{%
 %   \def\refname{<++>}%
 %   \def\abstractname{<++>}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-croatian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-croatian.ldf}[polyglossia: module for croatian]
 \PolyglossiaSetup{croatian}{
+  bcp47=hr,
   langtag=HRV,
   hyphennames={croatian},
   hyphenmins={2,2}, % aligned with https://ctan.org/pkg/hrhyph patterns and http://lebesgue.math.hr/~nenad/Diplomski/Maja_Ribaric_2011.pdf
@@ -8,12 +9,134 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{croatian}{hr}
+
+\define at boolkey{croatian}[croatian@]{babelshorthands}[true]{}
+
+\define at boolkey{croatian}[croatian@]{disableligatures}[true]{}
+
+% Register default options
+\xpg at initialize@gloss at options{croatian}{babelshorthands=false,disableligatures=false}
+
+\ifsystem at babelshorthands
+  \setkeys{croatian}{babelshorthands=true}
+\else
+  \setkeys{croatian}{babelshorthands=false}
+\fi
+
+\ifcsundef{initiate at active@char}{%
+  \input{babelsh.def}%
+  \initiate at active@char{"}%
+  \shorthandoff{"}%
+}{}
+
+\def\croatian at shorthands{%
+  \bbl at activate{"}%
+  \def\language at group{croatian}%
+  \declare at shorthand{croatian}{"=}{\penalty\@M-\hskip\z at skip}%
+  \declare at shorthand{croatian}{""}{\hskip\z at skip}%
+  \declare at shorthand{croatian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{croatian}{"-}{\nobreak\-\bbl at allowhyphens}%
+  \declare at shorthand{croatian}{"|}{%
+      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
+      \bbl at allowhyphens}{}%
+  }%
+  \declare at shorthand{croatian}{"/}{\textormath
+    {\bbl at allowhyphens\discretionary{/}{}{/}\bbl at allowhyphens}{}}%
+  \declare at shorthand{croatian}{"`}{„}%
+  \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}}%
+}
+
+\def\nocroatian at shorthands{%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+}
+
+\newcommand*\hr at charifavailable[2]{%
+   \ifcroatian at disableligatures
+     \bgroup#2\egroup%
+   \else
+     \charifavailable{#1}{#2}%
+   \fi%
+}
+
+% Provide croatian ligatures if available in current font
+\def\xpg at hr@lig#1#2{%
+ \bgroup%
+  % 1. DŽ, Dž and dž
+  \ifx#1D%
+    \ifx#2Z\relax%
+       \hr at charifavailable{01C4}{DŽ}%
+    \else%
+       \ifx#2z\relax
+          \hr at charifavailable{01C5}{Dž}%
+       \else
+           D#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1d%
+    \ifx#2z\relax
+       \hr at charifavailable{01C6}{dž}%
+    \else
+       d#2%
+    \fi%
+  \fi%
+  % 2. LJ, Lj and lj
+  \ifx#1L%
+    \ifx#2J\relax%
+       \hr at charifavailable{01C7}{LJ}%
+    \else%
+       \ifx#2j\relax
+          \hr at charifavailable{01C8}{Lj}%
+       \else
+           L#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1l%
+    \ifx#2j\relax
+       \hr at charifavailable{01C9}{lj}%
+    \else
+       l#2%
+    \fi%
+  \fi%
+  % 2. NJ, Nj and nj
+  \ifx#1N%
+    \ifx#2J\relax%
+       \hr at charifavailable{01CA}{NJ}%
+    \else%
+       \ifx#2j\relax
+          \hr at charifavailable{01CB}{Nj}%
+       \else
+           N#2%
+       \fi%
+    \fi%
+  \fi%
+  \ifx#1n%
+    \ifx#2j\relax
+       \hr at charifavailable{01CC}{nj}%
+    \else
+       n#2%
+    \fi%
+  \fi%
+  \egroup%
+}
+
 \def\captionscroatian{%
   \def\prefacename{Predgovor}%
   \def\refname{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
-  \def\chaptername{Poglavlje}%
+  \def\chaptername{Poglav\hr at charifavailable{01C9}{lj}e}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Popis slika}%
@@ -31,10 +154,24 @@
   \def\proofname{Dokaz}%
   \def\glossaryname{Pojmovnik}%
 }
+
 \def\datecroatian{%
   \def\today{\number\day.~\ifcase\month\or
     siječnja\or veljače\or ožujka\or travnja\or svibnja\or
     lipnja\or srpnja\or kolovoza\or rujna\or listopada\or studenoga\or
-    prosinca\fi \space \number\year.}}
+    prosinca\fi \space \number\year.}%
+}
 
+\def\noextras at croatian{%
+  \nocroatian at shorthands%
+}
+
+\def\blockextras at croatian{%
+  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+}
+
+\def\inlineextras at croatian{%
+  \ifcroatian at babelshorthands\croatian at shorthands\fi%
+}
+
 \endinput

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cy.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cy.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cy.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-cy.ldf}[polyglossia: module for cy (welsh)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{welsh}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cy.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cz.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cz.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cz.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-cz.ldf}[polyglossia: module for cz (czech)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{czech}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-cz.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-czech.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-czech.ldf}[polyglossia: module for czech]
 
 \PolyglossiaSetup{czech}{
+  bcp47=cz,
   hyphennames={czech},
   hyphenmins={2,2},
   langtag=CSY,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{czech}{cz}
+
 \ifluatex
   \RequirePackage{luavlna}
 \fi
@@ -18,7 +22,8 @@
 
 \define at boolkey{czech}[czech@]{vlna}[true]{}
 
-\setkeys{czech}{splithyphens,vlna}
+% Register default options
+\xpg at initialize@gloss at options{czech}{babelshorthands=false,splithyphens=true,vlna=true}
 
 \ifsystem at babelshorthands
   \setkeys{czech}{babelshorthands=true}
@@ -33,8 +38,12 @@
 }{}
 
 \def\cs@@splithyphen#1{%
-  \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
-  \nobreak\hskip\z@%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
 }
 
 \def\cs at splithyphen{%
@@ -212,13 +221,13 @@
 \def\blockextras at czech{%
   \ifczech at babelshorthands\czech at shorthands\fi%
   \ifczech at vlna\czech at vlna\else\noczech at vlna\fi%
-  \ifczech at splithyphens\czech at hyphens\else\noczech at hyhens\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 vlna\czech at vlna\else\noczech at vlna\fi%
-  \ifczech at splithyphens\czech at hyphens\else\noczech at hyhens\fi%
+  \ifczech at splithyphens\czech at hyphens\else\noczech at hyphens\fi%
 }
 
 \endinput

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-da.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-da.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-da.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-da.ldf}[polyglossia: module for da (danish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{danish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-da.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-danish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-danish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-danish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-danish.ldf}[polyglossia: module for danish]
 \PolyglossiaSetup{danish}{
+  bcp47=da,
   hyphennames={danish},
   hyphenmins={2,3},
   langtag=DAN,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{danish}{da}
+
 \def\captionsdanish{%
   \def\prefacename{Forord}%
   \def\refname{Litteratur}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT-1901.ldf}[polyglossia: module for de-AT-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT-1996.ldf}[polyglossia: module for de-AT-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT.ldf}[polyglossia: module for de-AT (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-AT.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH-1901.ldf}[polyglossia: module for de-CH-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH-1996.ldf}[polyglossia: module for de-CH-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH.ldf}[polyglossia: module for de-CH (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-CH.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE-1901.ldf}[polyglossia: module for de-DE-1901 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE-1996.ldf}[polyglossia: module for de-DE-1996 (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE.ldf}[polyglossia: module for de-DE (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-DE.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT-1901-Latf.ldf}[polyglossia: module for de-AT-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT-1996-Latf.ldf}[polyglossia: module for de-AT-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-AT-Latf.ldf}[polyglossia: module for de-AT-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-AT.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH-1901-Latf.ldf}[polyglossia: module for de-CH-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH-1996-Latf.ldf}[polyglossia: module for de-CH-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-CH-Latf.ldf}[polyglossia: module for de-CH-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-CH.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1901.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1901.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1901.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE-1901-Latf.ldf}[polyglossia: module for de-DE-1901-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1901.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1996.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1996.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1996.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE-1996-Latf.ldf}[polyglossia: module for de-DE-1996-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE-1996.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-DE-Latf.ldf}[polyglossia: module for de-DE-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf-DE.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de-Latf.ldf}[polyglossia: module for de-Latf (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de-Latf.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-de.ldf}[polyglossia: module for de (german)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{german}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-de.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-divehi.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-divehi.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-divehi.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -7,6 +7,7 @@
 \fi
 \RequireBidi
 \PolyglossiaSetup{divehi}{
+  bcp47=dv,
   script=Thaana,
   scripttag=thaa,
   langtag=DIV,% TODO Support DHV as well?
@@ -15,6 +16,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{divehi}{dv}
+
 %\def\captionsdivehi{%
 %   \def\refname{<++>}%
 %   \def\abstractname{<++>}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dsb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dsb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dsb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-dsb.ldf}[polyglossia: module for dsb (sorbian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{sorbian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dsb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dutch.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-dutch.ldf}[polyglossia: module for dutch]
 \PolyglossiaSetup{dutch}{
+  bcp47=nl,
   hyphennames={dutch},
   hyphenmins={2,2},
   langtag=NLD,
@@ -7,8 +8,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{dutch}{nl}
+
 \define at boolkey{dutch}[dutch@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{dutch}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{dutch}{babelshorthands=true}
 \else

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dv.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dv.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dv.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-dv.ldf}[polyglossia: module for dv (divehi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{divehi}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-dv.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-monoton.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-monoton.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-monoton.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-el-monoton.ldf}[polyglossia: module for el-monoton (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-monoton.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-polyton.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-polyton.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-polyton.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-el-polyton.ldf}[polyglossia: module for el-polyton (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el-polyton.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-el.ldf}[polyglossia: module for el (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-el.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-AU.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-AU.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-AU.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en-AU.ldf}[polyglossia: module for en-AU (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-AU.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-CA.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-CA.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-CA.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en-CA.ldf}[polyglossia: module for en-CA (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-CA.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-GB.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-GB.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-GB.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en-GB.ldf}[polyglossia: module for en-GB (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-GB.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-NZ.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-NZ.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-NZ.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en-NZ.ldf}[polyglossia: module for en-NZ (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-NZ.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-US.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-US.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-US.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en-US.ldf}[polyglossia: module for en-US (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en-US.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-en.ldf}[polyglossia: module for en (english)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{english}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-en.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-english.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-english.ldf}[polyglossia: module for english]
 
 \PolyglossiaSetup{english}{
+  bcp47=en-US,
   hyphennames={english,american,usenglish,USenglish},
   hyphenmins={2,3},
   langtag=ENG,
@@ -7,6 +8,14 @@
   fontsetup=true,
 }
 
+% 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}
+
 % Babel aliases
 \setlanguagealias[variant=us]{english}{american}
 \setlanguagealias[variant=australian]{english}{australian}
@@ -28,13 +37,13 @@
 % Option ordinalmonthday
 \define at boolkey{english}[english@]{ordinalmonthday}[true]{}
 
-\define at choicekey*+{english}{variant}[\val\nr]{uk,british,us,american,usmax,australian,newzealand,canadian}{%
+\define at choicekey*+{english}{variant}[\val\nr]{uk,british,us,american,usmax,australian,newzealand,canadian}[us]{%
    \ifcase\nr\relax
       % uk:
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdaytrue
-      \SetLanguageKeys{english}{babelname=british}%
+      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB}%
       \xpg at info{Option: English, variant=british}%
    \or
       % british:
@@ -41,7 +50,7 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdaytrue
-      \SetLanguageKeys{english}{babelname=british}%
+      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB}%
       \xpg at info{Option: english variant=british}%
    \or
       % us:
@@ -48,7 +57,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: English, variant=american}%
    \or
       % american:
@@ -55,7 +64,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: English, variant=american}%
    \or
       % usmax:
@@ -62,7 +71,7 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=american}%
+      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
       \xpg at info{Option: english variant=american (with additional patterns)}%
       \xpg at ifdefined{usenglishmax}{}%
          {\xpg at warning{No hyphenation patterns were loaded for "US English Max"\MessageBreak
@@ -77,8 +86,9 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=australian}%
+      \SetLanguageKeys{english}{babelname=australian,bcp47=en-AU}%
       \xpg at info{Option: English, variant=australian}%
+      \adddialect\l at australian\l at english%
    \or
       % newzealand:
       % These use the british hyphenation patterns
@@ -86,8 +96,9 @@
       \british at hyphentrue
       \british at dateformattrue
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=newzealand}%
+      \SetLanguageKeys{english}{babelname=newzealand,bcp47=en-NZ}%
       \xpg at info{Option: English, variant=newzealand}%
+      \adddialect\l at newzealand\l at english%
    \or
       % canadian:
       % This is currently equivalent to usenglish (as in babel)
@@ -94,8 +105,9 @@
       \british at hyphenfalse
       \british at dateformatfalse
       \english at ordinalmonthdayfalse
-      \SetLanguageKeys{english}{babelname=canadian}%
+      \SetLanguageKeys{english}{babelname=canadian,bcp47=en-CA}%
       \xpg at info{Option: English, variant=american}%
+      \adddialect\l at canadian\l at english%
    \fi
    \ifbritish at hyphen
       \xpg at ifdefined{ukenglish}{}%
@@ -107,6 +119,12 @@
    \fi
 }{\xpg at warning{Unknown English variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{english}{variant=us,ordinalmonthday=false}
+% Register alias options
+\xpg at set@alias at values{english}{variant}{us}{american}
+\xpg at set@alias at values{english}{variant}{uk}{british}
+
 \ifxetex
    % Check if \l at english is defined. If not, try to set it to some variety
    % (specific order as in the csv list below), or null language if everything fails
@@ -126,7 +144,7 @@
 \fi
 
 \def\english at language{%
-   \polyglossia at setup@language at patterns{\english at variant}
+   \polyglossia at setup@language at patterns{\english at variant}%
 }%
 
 \def\captionsenglish{%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eo.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eo.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eo.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-eo.ldf}[polyglossia: module for eo (esperanto)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{esperanto}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eo.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-ES.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-ES.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-ES.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-es-ES.ldf}[polyglossia: module for es-ES (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-ES.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-MX.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-MX.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-MX.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-es-MX.ldf}[polyglossia: module for es-MX (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es-MX.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-es.ldf}[polyglossia: module for es (spanish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{spanish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-es.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-esperanto.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-esperanto.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-esperanto.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-esperanto.ldf}[polyglossia: module for esperanto]
 \PolyglossiaSetup{esperanto}{
+  bcp47=eo,
   hyphennames={esperanto},
   hyphenmins={2,2},
   langtag=NTO,
@@ -7,6 +8,9 @@
   %TODO localalph={esperanto at alph,esperanto at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{esperanto}{eo}
+
 \def\captionsesperanto{%
    \def\refname{Citaĵoj}%
    \def\abstractname{Resumo}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-estonian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-estonian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-estonian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-estonian.ldf}[polyglossia: module for estonian]
 \PolyglossiaSetup{estonian}{
+  bcp47=et,
   hyphennames={estonian},
   hyphenmins={2,2},
   langtag=ETI,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{estonian}{et}
+
 \def\captionsestonian{%
    \def\refname{Viited}%
    \def\abstractname{Kokkuvõte}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-et.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-et.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-et.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-et.ldf}[polyglossia: module for et (estonian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{estonian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-et.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eu.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eu.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eu.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-eu.ldf}[polyglossia: module for eu (basque)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{basque}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-eu.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fa.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fa.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fa.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fa.ldf}[polyglossia: module for fa (persian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{persian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fa.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fi.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fi.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fi.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fi.ldf}[polyglossia: module for fi (finnish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{finnish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fi.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-finnish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-finnish.ldf}[polyglossia: module for finnish]
 \PolyglossiaSetup{finnish}{
+  bcp47=fi,
   hyphennames={finnish},
   hyphenmins={2,2},
   langtag=FIN,
@@ -7,8 +8,14 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{finnish}{fi}
+
 \define at boolkey{finnish}[finnish@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{finnish}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{finnish}{babelshorthands=true}
 \else

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CA.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CA.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CA.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fr-CA.ldf}[polyglossia: module for fr-CA (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CA.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CH.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CH.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CH.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fr-CH.ldf}[polyglossia: module for fr-CH (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-CH.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-FR.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-FR.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-FR.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fr-FR.ldf}[polyglossia: module for fr-FR (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr-FR.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fr.ldf}[polyglossia: module for fr (french)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{french}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fr.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-french.ldf}[polyglossia: module for french]
 
 \PolyglossiaSetup{french}{%
+  bcp47=fr-FR,
   language=French,
   script=Latin,
   langtag=FRA,
@@ -10,31 +11,47 @@
   hyphenmins={2,2},
   fontsetup=true}
 
+% BCP-47 compliant aliases
+\setlanguagealias*{french}{fr}
+\setlanguagealias*[variant=french]{french}{fr-FR}
+\setlanguagealias*[variant=canadian]{french}{fr-CA}
+\setlanguagealias*[variant=swiss]{french}{fr-CH}
+
 % Babel aliases
 \setlanguagealias[variant=acadian]{french}{acadien}
 \setlanguagealias[variant=canadian]{french}{canadien}
 
 \def\french at variant{french}
-\define at choicekey*+{french}{variant}[\val\nr]{french,canadian,acadian}[french]{%
+\define at choicekey*+{french}{variant}[\val\nr]{french,canadian,acadian,swiss}[french]{%
    \ifcase\nr\relax
       % french:
       \def\french at variant{french}%
+      \SetLanguageKeys{french}{babelname=french,bcp47=fr-FR}%
+      \french at thincolonspacefalse
    \or
       % canadian:
       \def\french at variant{canadien}%
-      \SetLanguageKeys{french}{babelname=canadien}%
+      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA}%
       \xpg at ifdefined{canadien}{}%
       {\xpg at warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak
         I will use the standard patterns for French instead}%
       \adddialect\l at canadien\l at french\relax}%
+      \french at thincolonspacefalse
    \or
       % acadian:
       \def\french at variant{acadian}%
-      \SetLanguageKeys{french}{babelname=canadien}%
+      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA}%
       \xpg at ifdefined{acadian}{}%
       {\xpg at warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak
         I will use the standard patterns for French instead}%
       \adddialect\l at acadian\l at french\relax}%
+      \french at thincolonspacefalse
+   \or
+      % swiss:
+      \def\french at variant{swissfrench}%
+      \SetLanguageKeys{french}{babelname=french,bcp47=fr-CH}%
+      \adddialect\l at swissfrench\l at french\relax%
+      \french at thincolonspacetrue
    \fi
    \xpg at info{Option: French, variant=\val}%
 }{\xpg at warning{Unknown French variant `#1'}}
@@ -41,15 +58,16 @@
 
 
 \def\french at language{%
-   \polyglossia at setup@language at patterns{\french at variant}
+   \polyglossia at setup@language at patterns{\french at variant}%
 }%
 
 \ifluatex
   \directlua{require('polyglossia-french')}%
 \else
-  \newXeTeXintercharclass\french at openbrackets % ( ] {
-  \newXeTeXintercharclass\french at closebrackets % ( ] {
-  \newXeTeXintercharclass\french at punctthin % ! ? ; et autres
+  \newXeTeXintercharclass\french at openbrackets % ( [ {
+  \newXeTeXintercharclass\french at closebrackets % ) ] }
+  \newXeTeXintercharclass\french at questionexclamation % ! ? et autres
+  \newXeTeXintercharclass\french at punctthin % ; (et :)
   \newXeTeXintercharclass\french at punctthick % :
   \newXeTeXintercharclass\french at punctguillstart % « ‹
   \newXeTeXintercharclass\french at punctguillend % » ›
@@ -62,9 +80,9 @@
 
 \define at boolkey{french}[french@]{frenchfootnote}[true]{%
   \AfterPreamble{%
-    \ifdefstring{\xpg at main@language}{french}{%
-      \iffrench at frenchfootnote
-         \ifx\@makefntext\undefined\else        
+    \iffrench at frenchfootnote
+      \ifdefstring{\xpg at main@language}{french}{%
+         \ifx\@makefntext\undefined\else
              \long\def\french at makefntext##1{%
                 \parindent1em \noindent\quad%
                 \ifx\@thefnmark\empty\else%
@@ -72,10 +90,10 @@
              }
              \let\@makefntext\french at makefntext
          \fi
-      \else
-         \let\@makefntext\xpg at orig@makefntext
-      \fi
-    }{\xpg at warning{Option 'frenchfootnote' only supported if French is main language!}}%
+      }{\xpg at warning{Option 'frenchfootnote' only supported if French is main language!}}%
+    \else
+       \let\@makefntext\xpg at orig@makefntext
+    \fi
   }%
 }
 
@@ -147,20 +165,29 @@
 
 \define at boolkey{french}[french@]{frenchitemlabels}[true]{%
   \AfterPreamble{%
-    \ifdefstring{\xpg at main@language}{french}{%
-      \iffrench at frenchitemlabels
+    \iffrench at frenchitemlabels
+      \ifdefstring{\xpg at main@language}{french}{%
          \renewcommand{\labelitemi}{\french at itemi}%
          \renewcommand{\labelitemii}{\french at itemii}%
          \renewcommand{\labelitemiii}{\french at itemiii}%
          \renewcommand{\labelitemiv}{\french at itemiv}%
-      \else
-         \let\@makefntext\xpg at orig@makefntext
-      \fi
-    }{\xpg at warning{Option 'frenchitemlabels' only supported if French is main language!}}%
+      }{\xpg at warning{Option 'frenchitemlabels' only supported if French is main language!}}%
+    \else
+       \let\@makefntext\xpg at orig@makefntext
+    \fi
   }%
 }
 
+% Register default options
+\xpg at initialize@gloss at options{french}{variant=french,autospacing=true,thincolonspace=false,
+                                      autospaceguillemets=true,autospacetypewriter=false,
+                                      frenchfootnote=false,frenchitemlabels=false,
+                                      itemlabels=\textemdash,itemlabeli=\textemdash,itemlabelii=\textemdash,
+                                      itemlabeliii=\textemdash,itemlabeliv=\textemdash}
+% Register alias options
+\xpg at set@alias at values{french}{variant}{canadian}{acadian}
 
+
 \def\french at fontsetup{%
   \unless\iffrench at autospacetypewriter
     \let\ttfamily\french at ttfamilyFB
@@ -192,12 +219,13 @@
       \fi
     \else
       \XeTeXinterchartokenstate=1
-      \XeTeXcharclass `\! \french at punctthin
-      \XeTeXcharclass `\? \french at punctthin
-      \XeTeXcharclass `\‼ \french at punctthin
-      \XeTeXcharclass `\⁇ \french at punctthin
-      \XeTeXcharclass `\⁈ \french at punctthin
-      \XeTeXcharclass `\⁉ \french at punctthin
+      \XeTeXcharclass `\! \french at questionexclamation
+      \XeTeXcharclass `\? \french at questionexclamation
+      \XeTeXcharclass `\‼ \french at questionexclamation
+      \XeTeXcharclass `\⁇ \french at questionexclamation
+      \XeTeXcharclass `\⁈ \french at questionexclamation
+      \XeTeXcharclass `\⁉ \french at questionexclamation
+      \XeTeXcharclass `\‽ \french at questionexclamation % U+203D (interrobang)
       \XeTeXcharclass `\; \french at punctthin
       \iffrench at thincolonspace
         \XeTeXcharclass `\: \french at punctthin
@@ -216,13 +244,16 @@
       \XeTeXcharclass `\} \french at closebrackets
       \XeTeXcharclass `\⟨ \french at openbrackets
       \XeTeXcharclass `\⟩ \french at closebrackets
+      \XeTeXinterchartoks \z@ \french at questionexclamation = {\xpg at french@thinsp}%
       \XeTeXinterchartoks \z@ \french at punctthin = {\xpg at french@thinsp}%
       \XeTeXinterchartoks \z@ \french at punctthick = {\nobreakspace}%
+      \XeTeXinterchartoks \xpg at boundaryclass \french at questionexclamation = {\xpg at unskip\xpg at french@thinsp}%
       \XeTeXinterchartoks \xpg at boundaryclass \french at punctthin = {\xpg at unskip\xpg at french@thinsp}%
       \XeTeXinterchartoks \xpg at boundaryclass \french at punctthick = {\xpg at unskip\nobreakspace}%
       \iffrench at autospaceguillemets
         \let\xpg at french@guillspace\xpg at french@thinsp%
         \XeTeXinterchartoks \french at punctguillstart \z@ = {\xpg at french@guillspace}% "«a" -> "«\,a"
+        \XeTeXinterchartoks \french at punctguillstart \french at punctguillstart = {\xpg at french@guillspace}% "«‹" -> "«\,‹"
  %      \XeTeXinterchartoks \z@ \french at punctguillstart = {\nobreakspace}% "a«" unchanged?
  %      \XeTeXinterchartoks \french at punctguillend \z@ = {\nobreakspace}% "»a" unchanged?
         \XeTeXinterchartoks \z@ \french at punctguillend = {\xpg at french@guillspace}% "a»" -> "a\,»"
@@ -229,13 +260,19 @@
         \XeTeXinterchartoks \french at punctguillstart \xpg at boundaryclass = {\xpg at french@guillspace\ignorespaces}% "«  " -> "«\,"
         \XeTeXinterchartoks \xpg at boundaryclass \french at punctguillend = {\xpg at unskip\xpg at french@guillspace}% "  »" -> "\,»"
         \XeTeXinterchartoks \french at closebrackets \french at punctguillend = {\xpg at french@guillspace}% ")»" -> ")\,»"
+        \XeTeXinterchartoks \french at questionexclamation \french at punctguillend  = {\xpg at french@guillspace}% "?»" -> "?\,»"
+        \XeTeXinterchartoks \french at punctthin \french at punctguillend  = {\xpg at french@guillspace}% ";»" -> ";\,»"
+        \XeTeXinterchartoks \french at punctguillend \french at punctguillend  = {\xpg at french@guillspace}% "›»" -> "›\,»"
      \else
        \def\xpg at french@guillspace{}%
      \fi
+     \XeTeXinterchartoks \french at punctguillend \french at questionexclamation = {\xpg at french@thinsp}% "»?" -> "»\,?"
      \XeTeXinterchartoks \french at punctguillend \french at punctthin = {\xpg at french@thinsp}% "»;" -> "»\,;"
      \XeTeXinterchartoks \french at punctguillend \french at punctthick = {\nobreakspace}% "»:" -> "» :"
-     \XeTeXinterchartoks \french at punctthin \french at punctguillend  = {\xpg at french@thinsp}% "?»" -> "?\,»"
-     \XeTeXinterchartoks \french at openbrackets \french at punctthin = {\xpg at unskip}% "(?" -> "(?" and not "( ?"      
+     \XeTeXinterchartoks \french at questionexclamation \french at punctthin = {\xpg at french@thinsp}% "?;" -> "?\,;"
+     \XeTeXinterchartoks \french at questionexclamation \french at punctthick = {\xpg at french@thinsp}% "?:" -> "?\,:"
+     \XeTeXinterchartoks \french at openbrackets \french at questionexclamation = {\xpg at unskip}% "(?" -> "(?" and not "( ?"
+     \XeTeXinterchartoks \french at openbrackets \french at punctthin = {\xpg at unskip}% "(;" -> "(;" and not "( ;"
      \XeTeXinterchartoks \french at punctthin \french at closebrackets = {\xpg at unskip}% "?)" -> "?)" (code not need, just for symetry with previous one)
      \XeTeXinterchartoks \french at closebrackets \french at punctthin = {\xpg at french@thinsp}% ")?" -> ")\,?"
      \XeTeXinterchartoks \french at closebrackets \french at punctthick = {\nobreakspace}% "):" -> ") :"
@@ -253,6 +290,7 @@
       \XeTeXcharclass `\⁇ \z@
       \XeTeXcharclass `\⁈ \z@
       \XeTeXcharclass `\⁉ \z@
+      \XeTeXcharclass `\‽ \z@
       \XeTeXcharclass `\; \z@
       \XeTeXcharclass `\: \z@
       \XeTeXcharclass `\« \z@

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-friulian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-friulian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-friulian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-friulian.ldf}[polyglossia: module for friulian]
 
 \PolyglossiaSetup{friulian}{%
+  bcp47=fur,
   language=Friulian,
   babelname=friulan,
   hyphennames={friulan,furlan},
@@ -11,6 +12,9 @@
   frenchspacing=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{friulian}{fur}
+
 % Babel and backwards compat. alias
 \setlanguagealias{friulian}{friulan}
 

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fur.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fur.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fur.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-fur.ldf}[polyglossia: module for fur (friulian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{friulian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-fur.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ga.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ga.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ga.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ga.ldf}[polyglossia: module for ga (gaelic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{gaelic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ga.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gaelic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gaelic.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gaelic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-gaelic.ldf}[polyglossia: module for gaelic]
 
 \PolyglossiaSetup{gaelic}{
+  bcp47=ga,
   language=Irish,
   babelname=irish,
   hyphennames={irish},
@@ -9,6 +10,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=irish]{gaelic}{ga}
+\setlanguagealias*[variant=scottish]{gaelic}{gd} 
 % Babel aliases
 \setlanguagealias[variant=irish]{gaelic}{irish}
 \setlanguagealias[variant=scottish]{gaelic}{scottish}
@@ -18,17 +22,20 @@
    \ifcase\nr\relax
       % irish:
       \gdef\gaelic at variant{irish}%
-      \SetLanguageKeys{gaelic}{language=Irish,langtag=IRI,babelname=irish}%
+      \SetLanguageKeys{gaelic}{language=Irish,langtag=IRI,babelname=irish,bcp47=ga}%
       \xpg at fontsetup@latin{gaelic}%
    \or
       % scottish:
       \gdef\gaelic at variant{scottish}%
-      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish}%
+      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish,bcp47=gd}%
       \xpg at fontsetup@latin{gaelic}%
    \fi
    \xpg at info{Option: gaelic, variant=\val}%
 }{\xpg at warning{Unknown gaelic variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{gaelic}{variant=irish}
+
 \def\captionsgaelic at irish{%
    \def\refname{Tagairtí}%
    \def\abstractname{Achoimre}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-galician.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-galician.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-galician.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-galician.ldf}[polyglossia: module for galician]
 \PolyglossiaSetup{galician}{
+  bcp47=gl,
   hyphennames={galician},
   hyphenmins={2,2},
   langtag=GAL,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{galician}{gl}
+
 \def\captionsgalician{%
    \def\refname{Referencias}%
    \def\abstractname{Resumo}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gd.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gd.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gd.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-gd.ldf}[polyglossia: module for gd (gaelic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{gaelic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gd.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-georgian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-georgian.ldf}[polyglossia: module for georgian]
 
 \PolyglossiaSetup{georgian}{
+  bcp47=ka,
   script=Georgian,
   scripttag=geor,
   langtag=KAT,
@@ -9,6 +10,9 @@
   localnumeral=georgiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{georgian}{ka}
+
 \newif\ifgeorgian at numerals
 \define at key{georgian}{numerals}[arabic]{%
    \ifstrequal{#1}{georgian}%
@@ -20,6 +24,9 @@
 
 \define at boolkey{georgian}[georgian@]{oldmonthnames}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{georgian}{babelshorthands=false,oldmonthnames=false,numerals=arabic}
+
 \ifsystem at babelshorthands
   \setkeys{georgian}{babelshorthands=true}
 \else

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-german.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-german.ldf}[polyglossia: module for german]
 
 \PolyglossiaSetup{german}{
+  bcp47=de-DE,
   hyphenmins={2,2},
   frenchspacing=true,
   fontsetup=true,
@@ -8,6 +9,28 @@
   babelname=ngerman
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{german}{de}
+\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH}
+\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT}
+\setlanguagealias*[variant=german,spelling=new]{german}{de-DE}
+\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH}
+\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE}
+\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT}
+\setlanguagealias*[variant=austrian,spelling=old]{german}{de-AT-1901}
+\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH-1996}
+\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT-1996}
+\setlanguagealias*[variant=german,spelling=old]{german}{de-DE-1901}
+\setlanguagealias*[variant=swiss,spelling=old,script=blackletter]{german}{de-Latf-CH-1901}
+\setlanguagealias*[variant=swiss,spelling=old]{german}{de-CH-1901}
+\setlanguagealias*[variant=austrian,spelling=old,script=blackletter]{german}{de-Latf-AT-1901}
+\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH-1996}
+\setlanguagealias*[script=blackletter]{german}{de-Latf}
+\setlanguagealias*[variant=german,spelling=new]{german}{de-DE-1996}
+\setlanguagealias*[variant=german,spelling=old,script=blackletter]{german}{de-Latf-DE-1901}
+\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE-1996}
+\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT-1996}
+
 % Babel aliases
 \setlanguagealias[variant=austrian,spelling=old]{german}{austrian}
 \setlanguagealias[variant=austrian,spelling=new]{german}{naustrian}
@@ -18,7 +41,7 @@
 
 \newif\if at german@oldspelling
 \@german at oldspellingfalse
-\define at choicekey*+{german}{spelling}[\val\nr]{new,old,1901}[new]{%
+\define at choicekey*+{german}{spelling}[\val\nr]{new,old,1901,1996}[new]{%
    \ifcase\nr\relax
       % new:
       \@german at oldspellingfalse
@@ -28,6 +51,9 @@
    \or
       % 1901:
       \@german at oldspellingtrue
+   \or
+      % 1996:
+      \@german at oldspellingfalse
    \fi
    \german at set@babelname%
    \xpg at info{Option: German, spelling=\val}%
@@ -64,21 +90,45 @@
 \def\german at set@babelname{%
   \if at german@oldspelling
      \if at swiss@locale
-         \SetLanguageKeys{german}{babelname=swissgerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-Latf-CH-1901}%
+         \else
+           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-CH-1901}%
+         \fi
      \else
      \if at austrian@locale
-         \SetLanguageKeys{german}{babelname=austrian}%
+         \if at german@blackletter
+            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-Latf-AT-1901}%
+         \else
+            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-AT-1901}%
+         \fi
      \else
-         \SetLanguageKeys{german}{babelname=german}%
+         \if at german@blackletter
+            \SetLanguageKeys{german}{babelname=german,bcp47=de-Latf-DE-1901}%
+         \else
+            \SetLanguageKeys{german}{babelname=german,bcp47=de-DE-1901}%
+         \fi
      \fi\fi
   \else
      \if at swiss@locale
-         \SetLanguageKeys{german}{babelname=nswissgerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-Latf-CH}%
+         \else
+           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-CH}%
+         \fi
      \else
      \if at austrian@locale
-         \SetLanguageKeys{german}{babelname=naustrian}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-Latf-AT}%
+         \else
+           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-AT}%
+         \fi
      \else
-         \SetLanguageKeys{german}{babelname=ngerman}%
+         \if at german@blackletter
+           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-Latf-DE}%
+         \else
+           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-DE}%
+         \fi
      \fi\fi
   \fi
 }
@@ -95,15 +145,25 @@
       % fraktur:
       \@german at blacklettertrue%
    \fi
+   \german at set@babelname%
    \xpg at info{Option: German, script=\val}%
 }{\xpg at warning{Unknown German script `#1'}}
 
-\define at boolkey{german}[german@]{latesthyphen}[false]{}
+% Option defunc'ed, as bot XeTeX and LuaTeX meanwhile
+% use the experimental German hyphenation patterns by default.
+\define at boolkey{german}[german@]{latesthyphen}[true]{}
 
 \define at boolkey{german}[german@]{babelshorthands}[true]{}
 
-\setkeys{german}{spelling,latesthyphen,script,variant}
+\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}
+% Register alias options
+\xpg at set@alias at values{german}{spelling}{new}{1996}
+\xpg at set@alias at values{german}{spelling}{old}{1901}
+\xpg at set@alias at values{german}{script}{blackletter}{fraktur}
+
 \ifsystem at babelshorthands
   \setkeys{german}{babelshorthands=true}
 \else
@@ -229,26 +289,23 @@
 }
 
 \def\german at language{%
-  \ifgerman at latesthyphen
-    \if at german@oldspelling
-        \if at swiss@locale
-            \polyglossia at setup@language at patterns{swissgerman}%
-        \else
-            \polyglossia at setup@language at patterns{german-x-latest}%
-        \fi
-    \else
-        \polyglossia at setup@language at patterns{ngerman-x-latest}%
-    \fi
-  \else% (latesthyphen=false)
-    \if at german@oldspelling
-        \if at swiss@locale
-            \polyglossia at setup@language at patterns{swissgerman}%
-        \else
-            \polyglossia at setup@language at patterns{german}%
-        \fi
-    \else
-        \polyglossia at setup@language at patterns{ngerman}%
-    \fi
+  \if at german@oldspelling
+      \if at swiss@locale
+          \polyglossia at setup@language at patterns{swissgerman}%
+      \else
+          \polyglossia at setup@language at patterns{german}%
+      \fi
+      \if at austrian@locale
+         \adddialect\l at austrian\l at german%
+      \fi
+  \else
+      \polyglossia at setup@language at patterns{ngerman}%
+      \if at austrian@locale
+         \adddialect\l at naustrian\l at ngerman%
+      \fi
+      \if at swiss@locale
+         \adddialect\l at nswissgerman\l at ngerman%
+      \fi
   \fi
 }
 

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gl.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gl.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gl.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-gl.ldf}[polyglossia: module for gl (galician)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{galician}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-gl.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-grc.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-grc.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-grc.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-grc.ldf}[polyglossia: module for grc (greek)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{greek}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-grc.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-greek.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-greek.ldf}[polyglossia: module for greek]
 
 \PolyglossiaSetup{greek}{
+  bcp47=el-monoton,
   script=Greek,
   scripttag=grek,
   langtag=ELL,
@@ -12,6 +13,12 @@
   %TODO localalph={greek at alph,greek at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=ancient]{greek}{grc}
+\setlanguagealias*[varant=polytonic]{greek}{el-polyton}
+\setlanguagealias*[variant=monotonic]{greek}{el-monoton}
+\setlanguagealias*{greek}{el}
+
 % Babel aliases
 \setlanguagealias[variant=polytonic]{greek}{polutonikogreek}
 
@@ -48,7 +55,7 @@
     \def\greek at variant{polygreek}%
     \def\captionsgreek{\polygreekcaptions}%
     \def\dategreek{\datepolygreek}%
-    \SetLanguageKeys{greek}{babelname=polutonikogreek}%
+    \SetLanguageKeys{greek}{babelname=polutonikogreek,bcp47=el-polyton}%
     \xpg at info{Option: Polytonic Greek}%
   \else
     \ifx\@tmpa\tmp at ancient
@@ -59,6 +66,7 @@
       \def\greek at variant{ancientgreek}%
       \def\captionsgreek{\ancientgreekcaptions}%
       \def\dategreek{\dateancientgreek}%
+      \SetLanguageKeys{greek}{babelname=greek,bcp47=grc}%
       \xpg at info{Option: Ancient Greek}%
     \else %monotonic
       \xpg at ifdefined{monogreek}{}%
@@ -68,12 +76,13 @@
       \def\greek at variant{monogreek}% monotonic
       \def\captionsgreek{\monogreekcaptions}%
       \def\dategreek{\datemonogreek}%
+      \SetLanguageKeys{greek}{babelname=greek,bcp47=el-monoton}%
       \xpg at info{Option: Monotonic Greek}%
     \fi
   \fi}
 
 \def\greek at language{%
-  \polyglossia at setup@language at patterns{\greek at variant}
+  \polyglossia at setup@language at patterns{\greek at variant}%
 }
 
 
@@ -84,8 +93,11 @@
 
 \define at boolkey{greek}{attic}[true]{\xpg at warning{Greek option `attic' is no longer required.}}
 
-% This sets the defaults
-\setkeys{greek}{numerals,variant}
+% Register default options
+\xpg at initialize@gloss at options{greek}{variant=monotonic,numerals=greek}
+% Register alias options
+\xpg at set@alias at values{greek}{variant}{monotonic}{mono}
+\xpg at set@alias at values{greek}{variant}{polytonic}{poly}
 
 \def\monogreekcaptions{%
    \def\refname{Αναφορές}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-he.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-he.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-he.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-he.ldf}[polyglossia: module for he (hebrew)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hebrew}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-he.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hebrew.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hebrew.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hebrew.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -9,6 +9,7 @@
 \RequirePackage{hebrewcal}
 
 \PolyglossiaSetup{hebrew}{
+  bcp47=he,
   script=Hebrew,
   direction=RL,
   scripttag=hebr,
@@ -20,6 +21,9 @@
   %digits = hebrewnumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hebrew}{he}
+
 \newif\if at calendar@hebrew
 \def\tmp at hebrew{hebrew}
 \define at key{hebrew}{calendar}[gregorian]{%
@@ -50,6 +54,9 @@
 
 \setkeys{hebrew}{numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{hebrew}{numerals=arabic,calendar=gregorian,marcheshvan=false}
+
 \def\captionshebrew{%
   \def\prefacename{מבוא}%
   \def\refname{מקורות}%
@@ -104,19 +111,45 @@
    \fi
 }
 
+% Bidi inserts an RTL mark (0x200f) before any number, forcing numbers to
+% RTL. Hebrew uses LTR numbers, though. So we insert an LTR mark to revert
+% the directionality
+\ifxetex
+  \newcommand\xpg at hebrew@DigitsDotDashInterCharToks{\if at nonlatin\char"200E \fi}
+\fi
+
+\def\hebrew at ltr@numbers{%
+    \ifxetex
+      \XeTeXinterchartoks \bidi at sepmark@charclass  \bidi at digits@charclass = {\xpg at hebrew@DigitsDotDashInterCharToks}
+    \fi%
+}
+
+\def\nohebrew at ltr@numbers{%
+    \ifxetex
+      % This is bidi's original intervention
+      \XeTeXinterchartoks \bidi at sepmark@charclass  \bidi at digits@charclass = {\DigitsDotDashInterCharToks}
+    \fi%
+}
+
 \def\hebrew at numbers{%
    \let\@alph\hebrewnumeral%
    \let\@Alph\Hebrewnumeral%
+   % Prevent bidi from setting the numbers RTL
+   \hebrew at ltr@numbers%
 }
 
 \def\nohebrew at numbers{%
   \let\@alph\latin at alph%
   \let\@Alph\latin at Alph%
+  % Restore previous bidi numbers definition
+  \nohebrew at ltr@numbers
 }
 
 \def\hebrew at globalnumbers{%
    \let\@arabic\hebrewnumber%
    \renewcommand\thefootnote{\localnumeral*{footnote}}%
+   % Prevent bidi from setting the numbers RTL
+   \hebrew at ltr@numbers%
 }
 
 % Store original definition

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hi.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hi.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hi.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-hi.ldf}[polyglossia: module for hi (hindi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hindi}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hi.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hindi.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hindi.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hindi.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -6,6 +6,7 @@
 \ProvidesFile{gloss-hindi.ldf}[polyglossia: module for hindi]
 \RequirePackage{devanagaridigits}
 \PolyglossiaSetup{hindi}{
+  bcp47=hi,
   script=Devanagari,
   scripttag=deva,
   langtag=HIN,
@@ -15,6 +16,9 @@
   %TODO nouppercase=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hindi}{hi}
+
 \ifx\l at hindi\@undefined%
   \ifx\l at sanskrit\@undefined%
     \xpg at nopatterns{Hindi}%
@@ -38,8 +42,12 @@
   \def\@tmpa{#1}%
   \ifx\@tmpa\tmp at western
     \hindi at devanagari@numeralsfalse
-  \fi}
+  \fi%
+}
 
+% Register default options
+\xpg at initialize@gloss at options{hindi}{numerals=Devanagari}
+
 \newcommand{\hindinumerals}[2]{\hindinumber{#2}}
 
 \def\hindinumber#1{%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hr.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hr.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hr.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-hr.ldf}[polyglossia: module for hr (croatian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{croatian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hr.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hsb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hsb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hsb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-hsb.ldf}[polyglossia: module for hsb (sorbian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{sorbian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hsb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hu.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hu.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hu.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-hu.ldf}[polyglossia: module for hu (hungarian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{hungarian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hu.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hungarian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hungarian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hungarian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-hungarian.ldf}[polyglossia: module for hungarian]
 
 \PolyglossiaSetup{hungarian}{
+  bcp47=hu,
   babelname=magyar,
   hyphennames={hungarian,magyar},
   langtag=HUN,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{hungarian}{hu}
+
 \frenchspacing
 
 % Babel and backwards compat. alias
@@ -51,8 +55,14 @@
    \xpg at info{Option: Hungarian, swapstrings=\val}%
 }{\xpg at warning{Unknown Hungarian swapstrings value `#1'}}
 
-\setkeys{hungarian}{swapstrings}
+% Register default options
+\xpg at initialize@gloss at options{hungarian}{swapstrings=all}
 
+\def\hungarian at language{%
+   \polyglossia at setup@language at patterns{hungarian}%
+   \xpg at ifdefined{hungarian}{\adddialect\l at magyar\l at hungarian}{}%
+}%
+
 \def\captionshungarian{%
    \def\refname{Hivatkozások}%
    \def\abstractname{Kivonat}%
@@ -122,8 +132,8 @@
   % change chapter and part headings
   \if at hungarian@swapheadings
      % With titlesec
-     \ifdefined\titleformat%
-       \ifdefined\@part%
+     \ifcsdef{titleformat}{%
+       \ifcsdef{@part}{%
           \let\xpg at save@part at format\@part%
           \patchcmd{\@part}%
                     {\partname\nobreakspace\thepart}%
@@ -130,44 +140,44 @@
                     {\thepart.\nobreakspace\partname}%
                     {}%
                     {\xpg at warning{Failed to patch part for Hungarian}}%
-       \fi%
-       \ifdefined\chapter%
+       }{}%
+       \ifcsdef{chapter}{%
           \titleformat\chapter[display]%
              {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}
              {\thechapter.\space\@chapapp}{.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}{\thepart.~\partname}%
-          \fi%
-          \ifdefined\chapterformat%
+          }{}%
+          \ifcsdef{chapterformat}{%
             \let\xpg at save@chap at format\chapterformat%
             \renewcommand{\chapterformat}{\mbox{\thechapter\autodot%
                                           \IfUsePrefixLine{\nobreakspace\chapapp}{\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}%
                        {\printchapternum.\chapternamenum\printchaptername}%
                        {}%
                        {\xpg at warning{Failed to patch chapter for Hungarian}}%
-           \fi%
-           \ifdefined\@part%
+           }{}%
+           \ifcsdef{@part}{%
               \let\xpg at save@part at format\@part%
               \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                                {\printpartnum.\partnamenum\printpartname}%
                                {}%
                                {\xpg at warning{Failed to patch part for Hungarian}}%
-           \fi%
-         \else%  (not \ifdefined\@memptsize)
+           }{}%
+         }{%  (not \ifdefined\@memptsize)
            % With standard classes
-            \ifdefined\@makechapterhead%
+            \ifcsdef{@makechapterhead}{%
               \let\xpg at save@chap at format\@makechapterhead%
               \patchcmd{\@makechapterhead}%
                        {\@chapapp\space \thechapter}%
@@ -174,8 +184,8 @@
                        {\thechapter.\space \@chapapp}%
                        {}%
                        {\xpg at warning{Failed to patch chapter for Hungarian}}%
-            \fi%
-            \ifdefined\@part%
+            }{}%
+            \ifcsdef{@part}{%
               \let\xpg at save@part at format\@part%
               \patchcmd{\@part}%
                        {\partname\nobreakspace\thepart}%
@@ -182,21 +192,21 @@
                        {\thepart.\nobreakspace\partname}%
                        {}%
                        {\xpg at warning{Failed to patch part for Hungarian}}%
-            \fi%  (end \ifdefined\@part)
-          \fi% (end \ifdefined\@memptsize)
-        \fi% (end \ifdefined\sectionformat)
-     \fi% (end \ifdefined\titleformat)
+            }{}%  (end \ifdefined\@part)
+          }% (end \ifdefined\@memptsize)
+        }% (end \ifdefined\sectionformat)
+     }% (end \ifdefined\titleformat)
   \fi% (end \if at hungarian@swapheadings)
   %
   % Change running headers
   \if at hungarian@swapheaders
-    \ifdefined\chapterformat%
+    \ifcsdef{chapterformat}{%
       % With KOMA
       \let\xpg at save@chaptermark at format\chaptermarkformat%
       \renewcommand*\chaptermarkformat{%
          \thechapter\autodot\ \IfChapterUsesPrefixLine{\chapapp\enskip}{}}
-    \else% (not \ifdefined\chapterformat)
-      \ifdefined\@memptsize%
+    }{% (not \ifdefined\chapterformat)
+      \ifcsdef{@memptsize}{%
         % With memoir
         \let\xpg at save@chaptermark at format\chaptermark%
         \renewcommand*\chaptermark[1]{%
@@ -207,18 +217,21 @@
               \fi
             \fi
             ##1}}{}}%
-      \else% (not \ifdefined\@memptsize)
+      }{% (not \ifdefined\@memptsize)
         % With standard classes
-        \ifdefined\chaptermark%
-           \let\xpg at save@chaptermark at format\chaptermark%
-           \patchcmd{\chaptermark}%
+        \ifcsdef{chaptermark}{%
+          \ifpatchable{\chaptermark}%
+               {\@chapapp\ \thechapter.}%
+               {\let\xpg at save@chaptermark at format\chaptermark%
+                \patchcmd{\chaptermark}%
                     {\@chapapp\ \thechapter.}%
                     {\thechapter.\ \@chapapp}%
                     {}%
-                    {\xpg at warning{Failed to patch chaptermark for Hungarian}}%
-        \fi% (end \ifdefined\chaptermark)
-      \fi% (end \ifdefined\@memptsize)
-    \fi% (end \ifdefined\chapterformat)
+                    {\xpg at warning{Failed to patch chaptermark for Hungarian}}}%
+               {}%
+        }{}% (end \ifdefined\chaptermark)
+      }% (end \ifdefined\@memptsize)
+    }% (end \ifdefined\chapterformat)
   \fi% (end \if at hungarian@swapheaders)
 }
 
@@ -229,50 +242,50 @@
    \let\fnum at figure\xpg at save@fnum at figure%
    %
    % Reset chapter and part heading
-   \ifdefined\titleformat%
+   \ifcsdef{titleformat}{%
       % With titlesec
-     \ifdefined\xpg at save@part at format
+     \ifcsdef{xpg at save@part at format}{%
         \let\@part\xpg at save@part at format
-     \fi%
-     \ifdefined\chapter
+     }{}%
+     \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
+        \ifcsdef{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@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\blockextras at hungarian{%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hy.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hy.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hy.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-hy.ldf}[polyglossia: module for hy (armenian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{armenian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-hy.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ia.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ia.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ia.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ia.ldf}[polyglossia: module for ia (interlingua)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{interlingua}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ia.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-icelandic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-icelandic.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-icelandic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-icelandic.ldf}[polyglossia: module for icelandic]
 \PolyglossiaSetup{icelandic}{
+  bcp47=is,
   hyphennames={icelandic},
   hyphenmins={2,2},
   langtag=ISL,
@@ -6,6 +7,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{icelandic}{is}
+
 \def\captionsicelandic{%
    \def\refname{Heimildir}%
    \def\abstractname{Útdráttur}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-id.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-id.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-id.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-id.ldf}[polyglossia: module for id (malay)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{malay}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-id.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-interlingua.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-interlingua.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-interlingua.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-interlingua.ldf}[polyglossia: module for interlingua]
 \PolyglossiaSetup{interlingua}{
+  bcp47=ia,
   hyphennames={interlingua},
   hyphenmins={2,2},
   langtag=INA,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{interlingua}{ia}
+
 \def\captionsinterlingua{%
    \def\refname{Referentias}%
    \def\abstractname{Summario}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-is.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-is.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-is.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-is.ldf}[polyglossia: module for is (icelandic)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{icelandic}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-is.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-it.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-it.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-it.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-it.ldf}[polyglossia: module for it (italian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{italian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-it.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-italian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 % !TEX encoding = UTF-8 Unicode
 \ProvidesFile{gloss-italian.ldf}[polyglossia: module for italian]
 \PolyglossiaSetup{italian}{
+  bcp47=it,
   hyphennames={italian},
   hyphenmins={2,2},
   langtag=ITA,
@@ -9,10 +10,16 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{italian}{it}
 
+
 %%% CHANGES START %%% by Enrico Gregorio
 \define at boolkey{italian}[italian@]{babelshorthands}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{italian}{babelshorthands=false}
+
 \ifsystem at babelshorthands
   \setkeys{italian}{babelshorthands=true}
 \else

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ja.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ja.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ja.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ja.ldf}[polyglossia: module for ja (japanese)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{japanese}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ja.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-japanese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-japanese.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-japanese.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,19 +1,25 @@
 \ProvidesFile{gloss-japanese.ldf}[polyglossia: module for japanese]
+
 \PolyglossiaSetup{japanese}{
+	bcp47=ja,
 	script=CJK,
 	language=Japanese,
 	langtag=JAN,
 	hyphennames={nohyphenation},
 	frenchspacing=false,
-	fontsetup=true
+	fontsetup=true,
+	localnumeral=japanesenumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{japanese}{ja}
+
 \def\japanese at capsformat{%
 	\def\@seccntformat##1{%
 		\csname pre##1\endcsname%
 		\csname the##1\endcsname%
 		\csname post##1\endcsname%
-	}
+	}%
 	\def\postsection{節\space}%
 	\def\postsubsection{節\space}%
 	\def\postsubsubsection{節\space}%
@@ -53,33 +59,33 @@
 \newif\if at IzumoTuki \@IzumoTukifalse%
 \newcount\c at TempJNum%
 
-\def\@JapaneseDigit#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 五十七\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 九十九
+\def\@JapaneseDigit#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 五十七\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
-		\@ctrerr
-	\fi\relax
+		\@ctrerr%
+	\fi\relax%
 }
 
-\def\@JapaneseNum#1{
+\def\@JapaneseNum#1{%
 	\c at TempJNum=#1\divide\c at TempJNum by 1000\relax%
 	\ifnum\c at TempJNum=\z@\c at TempJNum=#1%
 		\divide\c at TempJNum by 100\relax%
@@ -89,7 +95,7 @@
 				六百\or 七百\or 八百\or 九百%
 			\fi
 			\c at TempJNum=#1\divide\c at TempJNum by 100\multiply\c at TempJNum by -100\advance\c at TempJNum#1\@JapaneseDigit\c at TempJNum\relax%
-		\fi
+		\fi%
 	\else
 		\ifcase\c at TempJNum\or 千\or 二千\or 三千\or 四千\or 五千\or
 			六千\or 七千\or 八千\or 九千%
@@ -106,7 +112,7 @@
 	\fi
 }
 
-\def\@japanesenumber#1{
+\def\@japanesenumber#1{%
 	\@tempcnta=#1%
 	\ifnum\@tempcnta=\z@{〇}%
 	\else
@@ -139,12 +145,14 @@
 	\fi
 }
 
-\def\japanesenumber#1{
+\def\japanesenumber#1{%
 	\expandafter\@japanesenumber\csname c@#1\endcsname%
 }
 
-\def\datejapanese{
-	{
+\newcommand{\japanesenumerals}[2]{\@japanesenumber{#2}}
+
+\def\datejapanese{%
+	{%
 		\ifnum\year<1868%
 			\xdef\the at WarekiCur{}%
 		\else
@@ -163,7 +171,7 @@
 			\fi
 		\fi
 		\xdef\the at WameiTosi{\the\year}%
-	}
+	}%
 	\def\西暦{\@WameiRekifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\和暦{\@WameiRekitrue \@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\和名暦{\@WameiTositrue \@WameiTukitrue \@WameiHitrue}%
@@ -170,7 +178,7 @@
 	\def\数字暦{\@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
 	\def\出雲月{\@IzumoTukitrue}%
 	\def\大和月{\@IzumoTukifalse}%
-	\def\today{
+	\def\today{%
 		\if at WameiReki%
 			\the at WarekiCur%
 			\if at WameiTosi%
@@ -197,8 +205,8 @@
 		\else
 			\,\number\day\,%
 		\fi
-		{日}
-	}
+		{日}%
+	}%
 }
 
 \def\noextras at japanese{%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ka.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ka.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ka.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ka.ldf}[polyglossia: module for ka (georgian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{georgian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ka.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kannada.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kannada.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kannada.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -24,6 +24,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{kannada}{
+  bcp47=kn,
   script=Kannada,
   scripttag=knda,
   langtag=KAN,
@@ -33,6 +34,9 @@
   localnumeral=kannadanumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{kannada}{kn}
+
 %% Defining Kannada digits equivalents to english
 \def\kannadadigits#1{\expandafter\@kannada at digits #1@}
 \def\@kannada at digits#1{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-khmer.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-khmer.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-khmer.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-khmer.ldf}[polyglossia: module for Khmer]
 \PolyglossiaSetup{khmer}{
+  bcp47=km,
 	script=Khmer,%
 	scripttag=khmr,%
 	langtag=KHM,%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-km.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-km.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-km.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-km.ldf}[polyglossia: module for km (khmer)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{khmer}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-km.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Arab.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Arab.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Arab.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-kmr-Arab.ldf}[polyglossia: module for kmr-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Arab.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Latn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Latn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Latn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-kmr-Latn.ldf}[polyglossia: module for kmr-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr-Latn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-kmr.ldf}[polyglossia: module for kmr (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kmr.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-kn.ldf}[polyglossia: module for kn (kannada)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kannada}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ko.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ko.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ko.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ko.ldf}[polyglossia: module for ko (korean)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{korean}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ko.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-korean.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-korean.ldf}[polyglossia: module for Korean]
 
 \PolyglossiaSetup{korean}{
+  bcp47=ko,
     script=Hangul,
     scripttag=hang,
     language=Korean,
@@ -10,6 +11,9 @@
     fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{korean}{ko}
+
 % variant : plain (0), classic (1), or modern (2)
 \define at choicekey{korean}{variant}[\val\nr]{plain,classic,modern}[plain]{%
     \let\xpg at korean@variant\nr
@@ -18,8 +22,33 @@
 \define at choicekey{korean}{captions}[\val\nr]{hangul,hanja}[hangul]{%
     \let\xpg at korean@captions\nr
 }
-\setkeys{korean}{variant,captions}
+% swapstrings: all (0), headings (1), headers (2), or none (3)
+\newif\if at korean@swapheadings
+\newif\if at korean@swapheaders
+\define at choicekey*+{korean}{swapstrings}[\val\nr]{all,headings,headers,none}[all]{%
+   \ifcase\nr\relax
+      % all:
+      \@korean at swapheadingstrue%
+      \@korean at swapheaderstrue%
+   \or
+      % headings:
+      \@korean at swapheadingstrue%
+      \@korean at swapheadersfalse%
+   \or
+      % headers:
+      \@korean at swapheadingsfalse%
+      \@korean at swapheaderstrue%
+   \or
+      % none:
+      \@korean at swapheadingsfalse%
+      \@korean at swapheadersfalse%
+   \fi
+   \xpg at info{Option: Korean, swapstrings=\val}%
+}{\xpg at warning{Unknown Korean swapstrings value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{korean}{variant=plain,swapstrings=all,captions=hangul}
+
 \def\captionskorean{%
     \ifcase\xpg at korean@captions\relax
         \captions at korean@hangul
@@ -31,7 +60,7 @@
 }
 \def\captions at korean@hangul{%
     \def\koreanTHEname{제}%
-    \def\partname##1##2{제##1##2 편}%
+    \def\partname{편}%
     \def\chaptername{장}%
     \def\refname{참고문헌}%
     \def\abstractname{요약}%
@@ -49,10 +78,11 @@
     \def\proofname{증명}%
     \def\headtoname{수신:}%
     \def\ccname{사본}%
+    \def\glossaryname{용어집}%
 }
 \def\captions at korean@hanja{%
     \def\koreanTHEname{第}%
-    \def\partname##1##2{第##1##2 篇}%
+    \def\partname{篇}%
     \def\chaptername{章}%
     \def\refname{參考文獻}%
     \def\abstractname{要約}%
@@ -70,8 +100,219 @@
     \def\proofname{證明}%
     \def\headtoname{受信:}%
     \def\ccname{寫本}%
+    \def\glossaryname{用語集}%
 }
 
+\def\korean at appendix@chapapp{\appendixname}% to exclude appendix
+
+\def\korean at headingsformat{%
+  % 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}%
+                 {\partname\nobreakspace\thepart}%
+                 {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
+                 {}%
+                 {\xpg at warning{Failed to patch part for Korean}}%
+      \fi
+      \ifdefined\chapter
+        \titleformat\chapter[display]%
+          {\@ifundefined{ttl at fil}{\raggedright}{\ttl at fil}\ttl at fonts\ttl at sizes6}%
+          {%
+            \ifx\@chapapp\korean at appendix@chapapp
+              \appendixname\space \thechapter
+            \else
+              \koreanTHEname\space \thechapter\space \@chapapp
+            \fi
+          }{.8\baselineskip}{\ttl at sizes\z@\ttl at passexplicit}%
+      \fi
+    \else % (not \ifdefined\titleformat)
+      % With KOMA
+      \ifdefined\sectionformat
+        \ifdefined\partformat
+          \let\xpg at save@part at format\partformat
+          \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
+        \fi
+        \ifdefined\chapterformat
+          \let\xpg at save@chap at format\chapterformat
+          \renewcommand*{\chapterformat}{\mbox{%
+            \IfChapterUsesPrefixLine
+            {%
+              \ifx\@chapapp\korean at appendix@chapapp
+                \chapappifchapterprefix\nobreakspace \thechapter\autodot
+              \else
+                \koreanTHEname\nobreakspace \thechapter\nobreakspace \chapappifchapterprefix{}%
+              \fi
+            }%
+            {\thechapter\autodot\enskip}%
+          }}%
+        \fi
+      \else % (not \ifdefined\sectionformat)
+        % With memoir
+        \ifdefined\@memptsize
+          \ifdefined\@makechapterhead
+            \let\xpg at save@chap at format\@makechapterhead
+            \patchcmd{\@makechapterhead}%
+                     {\printchaptername \chapternamenum \printchapternum}%
+                     {%
+                       \ifx\@chapapp\korean at appendix@chapapp
+                         \printchaptername\relax\chapternamenum \printchapternum
+                       \else
+                         \printkoreanchapterthe \printchapternum\chapternamenum \printchaptername
+                       \fi
+                     }%
+                     {}%
+                     {\xpg at warning{Failed to patch chapter for Korean}}%
+            \ifdefined\printkoreanchapterthe\else
+              \def\printkoreanchapterthe{%
+                \ifpatchable\printchaptername\@chapapp
+                  {\chapnamefont\koreanTHEname\chapternamenum}{}}%
+            \fi
+          \fi
+          \ifdefined\@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
+          \fi
+        \else % (not \ifdefined\@memptsize)
+          % With standard classes
+          \ifdefined\@makechapterhead
+            \let\xpg at save@chap at format\@makechapterhead
+            \patchcmd{\@makechapterhead}%
+                     {\@chapapp\space \thechapter}%
+                     {%
+                       \ifx\@chapapp\korean at appendix@chapapp
+                         \appendixname\space \thechapter
+                       \else
+                         \koreanTHEname\space \thechapter\space \@chapapp
+                       \fi
+                     }%
+                     {}%
+                     {\xpg at warning{Failed to patch chapter for Korean}}%
+          \fi
+          \ifdefined\@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}}%
+          \fi % (end \ifdefined\@part)
+        \fi % (end \ifdefined\@memptsize)
+      \fi % (end \ifdefined\sectionformat)
+    \fi % (end \ifdefined\titleformat)
+  \fi % (end \if at korean@swapheadings)
+  %
+  % Change running headers
+  \if at korean@swapheaders
+    \ifdefined\chapterformat
+      % With KOMA
+      \let\xpg at save@chaptermark at format\chaptermarkformat
+      \renewcommand*\chaptermarkformat{%
+        \IfChapterUsesPrefixLine
+        {%
+          \ifx\@chapapp\korean at appendix@chapapp
+            \chapappifchapterprefix\ \thechapter\autodot
+          \else
+            \koreanTHEname\ \thechapter\ \chapappifchapterprefix{}%
+          \fi
+        }%
+        {\thechapter\autodot}%
+        \enskip
+      }%
+    \else % (not \ifdefined\chapterformat)
+      \ifdefined\@memptsize
+        % With memoir
+        \let\xpg at save@chaptermark at format\chaptermark
+        \patchcmd{\chaptermark}%
+                 {\@chapapp\ \@nameuse{thechapter}}%
+                 {%
+                   \ifx\@chapapp\korean at appendix@chapapp
+                     \appendixname\ \@nameuse{thechapter}%
+                   \else
+                     \koreanTHEname\ \@nameuse{thechapter}\ \@chapapp
+                   \fi
+                 }%
+                 {}%
+                 {}%
+      \else % (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)
+  \fi % (end \if at korean@swapheaders)
+}
+
+\def\nokorean at headingsformat{%
+  % Reset chapter and part heading
+  \ifdefined\titleformat
+    % With titlesec
+    \ifdefined\xpg at save@part at format
+      \let\@part\xpg at save@part at format
+    \fi
+    \ifdefined\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
+      % With KOMA
+      \ifdefined\xpg at save@part at format
+        \let\partformat\xpg at save@part at format
+      \fi
+      \ifdefined\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
+        \let\@makechapterhead\xpg at save@chap at format
+      \fi
+    \fi % (end \ifdefined\sectionformat)
+  \fi % (end \ifdefined\titleformat)
+  %
+  % Reset headers
+  \ifdefined\chaptermarkformat
+    % With KOMA
+    \ifdefined\xpg at save@chaptermark at format
+      \let\chaptermarkformat\xpg at save@chaptermark at format
+    \fi
+  \else
+    \ifdefined\chaptermark
+      % With memoir and standard classes
+      \ifdefined\xpg at save@chaptermark at format
+        \let\chaptermark\xpg at save@chaptermark at format
+      \fi
+    \fi % (end \ifdefined\chaptermark)
+  \fi % (end \ifdefined\chapterformat)
+}
+
 \def\datekorean{%
     \ifcase\xpg at korean@captions\relax
         \def\today{\the\year 년 \the\month 월 \the\day 일}%
@@ -145,17 +386,11 @@
 
 \def\blockextras at korean{%
     \inlineextras at korean
-    \ifdefined\@chapapp
-        \long\def\@tmpa{\chaptername}\def\@tmpb{\chaptername}%
-        \ifnum0\ifx\@chapapp\@tmpa1\else\ifx\@chapapp\@tmpb1\fi\fi>\z@
-            \let\xpg at orig@@chapapp\@chapapp
-            \def\@chapapp##1##2{\koreanTHEname ##1##2##1\chaptername}%
-        \fi
-    \fi
+    \korean at headingsformat
 }
 
 \def\noextras at korean@common{%
-    \ifdefined\xpg at orig@@chapapp \let\@chapapp\xpg at orig@@chapapp \fi
+    \nokorean at headingsformat
 }
 
 \ifluatex % luatex

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Arab.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Arab.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Arab.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ku-Arab.ldf}[polyglossia: module for ku-Arab (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Arab.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Latn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Latn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Latn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ku-Latn.ldf}[polyglossia: module for ku-Latn (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku-Latn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ku.ldf}[polyglossia: module for ku (kurdish)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ku.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurdish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -8,6 +8,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{kurdish}{
+  bcp47=ckb,
   script=Arabic,
   direction=RL,
   scripttag=arab,
@@ -17,6 +18,17 @@
   localnumeral=kurdishnumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{kurdish}{ku}
+\setlanguagealias*[variant=kurmanji,script=Latin]{kurdish}{kmr-Latn}
+\setlanguagealias*[variant=sorani]{kurdish}{ckb}
+\setlanguagealias*[variant=kurmanji,script=Arabic]{kurdish}{kmr-Arab}
+\setlanguagealias*[script=Latin]{kurdish}{ku-Latn}
+\setlanguagealias*[variant=sorani,script=Arabic]{kurdish}{ckb-Arab}
+\setlanguagealias*[variant=sorani,script=Latin]{kurdish}{ckb-Latn}
+\setlanguagealias*[script=Arabic]{kurdish}{ku-Arab}
+\setlanguagealias*[variant=kurmanji]{kurdish}{kmr}
+
 % Babel aliases
 \setlanguagealias[variant=kurmanji]{kurdish}{kurmanji}
 
@@ -63,9 +75,9 @@
      \@western at numeralstrue%
      \if at kurdish@kurmanji
          \def\kurdish at pattern{kurmanji}%
-         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji}%
+         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn}%
      \else
-         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish}%
+         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish,bcp47=ckb-Arab}%
      \fi
      \def\kurdish at script{latin}
      \xpg at fontsetup@latin{kurdish}%
@@ -73,20 +85,20 @@
      \if at kurdish@arabic% Arabic explicitly set
         \if at kurdish@kurmanji
             \if at force@western at numerals\else\@western at numeralsfalse\fi%
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurmanji}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurmanji,bcp47=kmr-Arab}%
             \def\kurdish at script{arabic}%
         \else
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab}%
         \fi
         \xpg at fontsetup@nonlatin{kurdish}%
      \else% sorani=Arabic, kurmanji=Latin
         \if at kurdish@kurmanji
             \@western at numeralstrue%
-            \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji}%
+            \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn}%
             \xpg at fontsetup@latin{kurdish}%
             \def\kurdish at script{latin}
         \else
-            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish}%
+            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab}%
             \xpg at fontsetup@nonlatin{kurdish}%
         \fi
      \fi
@@ -118,7 +130,8 @@
 
 %TODO add option for CALENDAR
 
-\setkeys{kurdish}{variant,locale}
+% Register default options
+\xpg at initialize@gloss at options{kurdish}{variant=sorani,locale=default,script=Arabic,abjadjimnotail=false,numerals=eastern}
 
 \def\kurdish at language{%
    \polyglossia at setup@language at patterns{\kurdish at pattern}%
@@ -325,19 +338,9 @@
   \if at western@numerals
     \number#1%
   \else
-    \ifxetex
-      \ifnum\XeTeXcharglyph"06F0 > 0\relax
-        \farsidigits{\number#1}%
-      \else%
-         \arabicdigits{\number#1}%
-      \fi
-    \else\ifluatex
-      \expandafter\ifnum\directlua{polyglossia.check_char(0x6F0)} > 0\relax
-        \farsidigits{\number#1}%
-      \else%
-         \arabicdigits{\number#1}%
-      \fi
-    \fi\fi
+    \xpg at if@char at available{06F0}%
+          {\farsidigits{\number#1}}%
+          {\arabicdigits{\number#1}}%
   \fi
 }
 

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurmanji.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurmanji.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurmanji.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-kurmanji.ldf}[polyglossia: module for kurmanji kurdish]
+
+% We provide this gloss for babel compatibility.
+
+\xpg at load@master at language{kurdish}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-kurmanji.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-classic.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-classic.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-classic.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-la-xclassic.ldf}[polyglossia: module for la-xclassic (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-classic.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-ecclesia.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-ecclesia.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-ecclesia.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-la-xecclesiastic.ldf}[polyglossia: module for la-xecclesiastic (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-ecclesia.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-medieval.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-medieval.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-medieval.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-la-xmedieval.ldf}[polyglossia: module for la-xmedieval (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la-x-medieval.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-la.ldf}[polyglossia: module for la (latin)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latin}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-la.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lao.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lao.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lao.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -6,6 +6,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{lao}{
+  bcp47=lo,
   script=Lao,
   scripttag=lao,
   langtag=LAO,
@@ -17,6 +18,9 @@
   %TODO localdigits=laonumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{lao}{lo}
+
 \newif\if at lao@numerals
 \def\tmp at lao{lao}
 \define at key{lao}{numerals}[arabic]{%
@@ -25,7 +29,8 @@
 	  \@lao at numeralsfalse\fi
 }
 
-\setkeys{lao}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{lao}{numerals=arabic}
 
 % Translations provided by Brian Wilson <bountonw at gmail.com>
 \def\captionslao{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latin.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,10 +1,10 @@
-\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.0 2019-10-28]
+\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.2 2020-01-03]
 
 \ExplSyntaxOn
 
 \PolyglossiaSetup {latin}
   {
-    hyphennames = {latin},
+    bcp47 = la,
     hyphenmins = {2,2},
     frenchspacing = true,
     fontsetup = true,
@@ -11,10 +11,16 @@
     langtag = LAT
   }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{latin}{la}
+\setlanguagealias*[variant=classic]{latin}{la-x-classic}
+\setlanguagealias*[variant=ecclesiastic]{latin}{la-x-ecclesia}
+\setlanguagealias*[variant=medieval]{latin}{la-x-medieval}
+
 % Babel aliases
-\setlanguagealias[variant=classic]{latin}{latinclassic}
-\setlanguagealias[variant=ecclesiastic]{latin}{latinecclesiastic}
-\setlanguagealias[variant=medieval]{latin}{latinmedieval}
+\setlanguagealias[variant=classic]{latin}{classiclatin}
+\setlanguagealias[variant=ecclesiastic]{latin}{ecclesiasticlatin}
+\setlanguagealias[variant=medieval]{latin}{medievallatin}
 
 
 %%%%% Variables and commands concerning spelling
@@ -47,8 +53,7 @@
 
 \msg_new:nnn {polyglossia} {latin / missing modern patterns}
   {
-    No~hyphenation~patterns~were~found~for~Latin~\msg_line_context:.~
-    I~will~not~hyphenate~Latin~words.
+    The~hyphenation~patterns~for~modern~Latin~were~not~found~\msg_line_context:.
   }
 
 \msg_new:nnn {polyglossia} {latin / missing patterns}
@@ -64,11 +69,23 @@
         \def \latin at language
           {
             \polyglossia at setup@language at patterns {latin}
+            \str_case:Vn \l_polyglossia_latin_variant_str
+              {
+                {classic}      { \adddialect \l at classiclatin \l at latin }
+                {medieval}     { \adddialect \l at medievallatin \l at latin }
+                {ecclesiastic} { \adddialect \l at ecclesiasticlatin \l at latin }
+              }
           }
       }
       {
         \msg_warning:nn {polyglossia} {latin / missing modern patterns}
-        \adddialect \l at latin \l at nohyphenation
+        \str_case:Vn \l_polyglossia_latin_variant_str
+          {
+            {classic}      { \adddialect \l at classiclatin \l at nohyphenation }
+            {medieval}     { \adddialect \l at medievallatin \l at nohyphenation }
+            {modern}       { \adddialect \l at latin \l at nohyphenation }
+            {ecclesiastic} { \adddialect \l at ecclesiasticlatin \l at nohyphenation }
+          }
       }
   }
 
@@ -80,19 +97,22 @@
         \def \latin at language
           {
             \polyglossia at setup@language at patterns {#1}
+            \str_case:Vn \l_polyglossia_latin_variant_str
+              {
+                {classic}      {
+                                 \str_if_eq:nnTF{#1}{liturgicallatin}
+                                     { \adddialect \l at classiclatin { \use:c {l@#1} } }
+                                     {}
+                               }
+                {medieval}     { \adddialect \l at medievallatin { \use:c {l@#1} } }
+                {modern}       { \adddialect \l at latin { \use:c {l@#1} } }
+                {ecclesiastic} { \adddialect \l at ecclesiasticlatin { \use:c {l@#1} } }
+              }
           }
       }
       {
-        \xpg at ifdefined {latin}
-          {
-            \msg_warning:nnn {polyglossia} {latin / missing patterns} {#1}
-            \adddialect \l@ #1 \l at latin
-            \polyglossia_latin_use_modern_patterns:
-          }
-          {
-            \msg_warning:nn {polyglossia} {latin / missing modern patterns}
-            \adddialect \l@ #1 \l at nohyphenation
-          }
+        \msg_warning:nnn {polyglossia} {latin / missing patterns} {#1}
+        \polyglossia_latin_use_modern_patterns:
       }
   }
 
@@ -106,7 +126,8 @@
     \directlua { require('polyglossia-latin') }
   }
   {
-    \newXeTeXintercharclass \g_polyglossia_latin_punctuation_class
+    \newXeTeXintercharclass \g_polyglossia_latin_question_exclamation_class
+    \newXeTeXintercharclass \g_polyglossia_latin_colon_semicolon_class
     \newXeTeXintercharclass \g_polyglossia_latin_opening_guillemet_class
     \newXeTeXintercharclass \g_polyglossia_latin_closing_guillemet_class
     \newXeTeXintercharclass \g_polyglossia_latin_opening_bracket_class
@@ -137,14 +158,15 @@
       }
       {
         \XeTeXinterchartokenstate = 1
-        \XeTeXcharclass `\! \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\? \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\‼ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁇ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁈ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\⁉ \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\; \g_polyglossia_latin_punctuation_class
-        \XeTeXcharclass `\: \g_polyglossia_latin_punctuation_class
+        \XeTeXcharclass `\! \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\? \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\‼ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁇ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁈ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\⁉ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\‽ \g_polyglossia_latin_question_exclamation_class
+        \XeTeXcharclass `\; \g_polyglossia_latin_colon_semicolon_class
+        \XeTeXcharclass `\: \g_polyglossia_latin_colon_semicolon_class
         \XeTeXcharclass `\« \g_polyglossia_latin_opening_guillemet_class
         \XeTeXcharclass `\» \g_polyglossia_latin_closing_guillemet_class
         \XeTeXcharclass `\‹ \g_polyglossia_latin_opening_guillemet_class
@@ -158,16 +180,31 @@
         \XeTeXcharclass `\⟨ \g_polyglossia_latin_opening_bracket_class
         \XeTeXcharclass `\⟩ \g_polyglossia_latin_closing_bracket_class
 
-        % punctuation followed by a closing guillemet
-        \XeTeXinterchartoks \g_polyglossia_latin_punctuation_class \g_polyglossia_latin_closing_guillemet_class =
+        % question or exclamation mark followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % closing bracket followed by punctuation
-        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_punctuation_class =
+        % question or exclamation mark followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_colon_semicolon_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
+        % colon or semicolon followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_colon_semicolon_class \g_polyglossia_latin_closing_guillemet_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing bracket followed by a question or exclamation mark
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_question_exclamation_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing bracket followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % closing bracket followed by a closing guillemet
         \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_closing_guillemet_class =
           {
@@ -178,31 +215,56 @@
           {
             \polyglossia_latin_replace_following_space:
           }
+        % opening guillemet followed by an opening guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \g_polyglossia_latin_opening_guillemet_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % opening guillemet followed by an ordinary character
         \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \z@ =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % closing guillemet followed by punctuation
-        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_punctuation_class =
+        % closing guillemet followed by a closing guillemet
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
-        % space followed by punctuation
-        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_punctuation_class =
+        % closing guillemet followed by a question or exclamation mark
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_question_exclamation_class =
           {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % closing guillemet followed by a colon or semicolon
+        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
+        % space followed by a question or exclamation mark
+        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_question_exclamation_class =
+          {
             \polyglossia_latin_replace_preceding_space:
           }
+        % space followed by a colon or semicolon
+        \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_replace_preceding_space:
+          }
         % space followed by closing guillemet
         \XeTeXinterchartoks \xpg at boundaryclass \g_polyglossia_latin_closing_guillemet_class =
           {
             \polyglossia_latin_replace_preceding_space:
           }
-        % ordinary character followed by punctuation
-        \XeTeXinterchartoks \z@ \g_polyglossia_latin_punctuation_class =
+        % ordinary character followed by a question or exclamation mark
+        \XeTeXinterchartoks \z@ \g_polyglossia_latin_question_exclamation_class =
           {
             \polyglossia_latin_insert_punctuation_space:
           }
+        % ordinary character followed by a colon or semicolon
+        \XeTeXinterchartoks \z@ \g_polyglossia_latin_colon_semicolon_class =
+          {
+            \polyglossia_latin_insert_punctuation_space:
+          }
         % ordinary character followed by closing guillemet
         \XeTeXinterchartoks \z@ \g_polyglossia_latin_closing_guillemet_class =
           {
@@ -224,6 +286,7 @@
         \XeTeXcharclass `\⁇ \z@
         \XeTeXcharclass `\⁈ \z@
         \XeTeXcharclass `\⁉ \z@
+        \XeTeXcharclass `\‽ \z@
         \XeTeXcharclass `\; \z@
         \XeTeXcharclass `\: \z@
         \XeTeXcharclass `\« \z@
@@ -279,7 +342,9 @@
           }
       }
       {
-        \msg_warning:nn {polyglossia} {latin / ineffective footnote option}
+        \iflatin at ecclesiasticfootnotes
+          \msg_warning:nn {polyglossia} {latin / ineffective footnote option}
+        \fi
       }
   }
 
@@ -301,6 +366,8 @@
 
 %%%%% Language variants: classic, medieval, modern, and ecclesiastic
 
+\str_new:N \l_polyglossia_latin_variant_str
+
 \msg_new:nnn {polyglossia} {latin / language variant}
   {
     Activating~Latin~language~variant~"#1"~\msg_line_context:.
@@ -318,7 +385,8 @@
     \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.classic }
+    \str_set:Nn \l_polyglossia_latin_variant_str {classic}
+    \SetLanguageKeys {latin} { babelname = classiclatin, bcp47 = la-x-classic }
     \polyglossia_latin_set_patterns:n {classiclatin}
   }
 
@@ -329,7 +397,8 @@
     \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.medieval }
+    \str_set:Nn \l_polyglossia_latin_variant_str {medieval}
+    \SetLanguageKeys {latin} { babelname = medievallatin, bcp47 = la-x-medieval }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -340,7 +409,8 @@
     \bool_set_false:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin }
+    \str_set:Nn \l_polyglossia_latin_variant_str {modern}
+    \SetLanguageKeys {latin} { babelname = latin, bcp47 = la }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -351,7 +421,8 @@
     \bool_set_true:N \l_polyglossia_latin_use_digraphs_bool
     \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
     \bool_set_true:N \l_polyglossia_latin_punctuation_spacing_bool
-    \SetLanguageKeys {latin} { babelname = latin.ecclesiastic }
+    \str_set:Nn \l_polyglossia_latin_variant_str {ecclesiastic}
+    \SetLanguageKeys {latin} { babelname = ecclesiasticlatin, bcp47 = la-x-ecclesia }
     \polyglossia_latin_use_modern_patterns:
   }
 
@@ -419,7 +490,7 @@
     The~Latin~hyphenation~variant~"#1"~is~undefined~\msg_line_context:.
   }
 
-\define at key{latin}{hyphenation}
+\define at key {latin} {hyphenation}
   {
     \str_case:nnTF {#1}
       {
@@ -518,6 +589,11 @@
   {
   }
 
+% Register default options
+\xpg at initialize@gloss at options{latin}{variant=modern,hyphenation=modern,babelshorthands=false,
+                                     prosodicshorthands=false,ecclesiasticfootnotes=false,
+                                     usej=false,capitalizemonth=true}
+
 \ifsystem at babelshorthands
   \setkeys{latin}{babelshorthands=true}
 \else
@@ -900,7 +976,7 @@
 
 %%   Copyright (C) Claudio Beccari 2013-2016
 %%   Copyright (C) Élie Roux 2016-2019
-%%   Copyright (C) Keno Wehr 2019
+%%   Copyright (C) Keno Wehr 2019-2020
 %%
 %%   Permission is hereby granted, free of charge, to any person obtaining
 %%   a copy of this software and associated documentation files

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latvian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latvian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-latvian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-latvian.ldf}[polyglossia: module for latvian]
 \PolyglossiaSetup{latvian}{
+  bcp47=lv,
   hyphennames={latvian},
   hyphenmins={2,2},
   langtag=LVI,
@@ -6,6 +7,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{latvian}{lv}
+
 \def\captionslatvian{%
    \def\prefacename{Priekšvārds}%
    \def\refname{Literatūras saraksts}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lithuanian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lithuanian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lithuanian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,6 +2,7 @@
 
 \ProvidesFile{gloss-lithuanian.ldf}[polyglossia: module for lithuanian]
 \PolyglossiaSetup{lithuanian}{
+  bcp47=lt,
   hyphennames={lithuanian},
   hyphenmins={2,2},
   langtag=LTH,
@@ -9,6 +10,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{lithuanian}{lt}
+
 \def\captionslithuanian{%
    \def\prefacename{Pratarmė}%
    \def\refname{Literatūra}%

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lo.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lo.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lo.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-lo.ldf}[polyglossia: module for lo (lao)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{lao}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lo.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lt.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lt.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lt.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-lt.ldf}[polyglossia: module for lt (lithuanian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{lithuanian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lt.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lv.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lv.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lv.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-lv.ldf}[polyglossia: module for lv (latvian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{latvian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-lv.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-macedonian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-macedonian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-macedonian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-macedonian.ldf}[polyglossia: module for macedonian]
 \PolyglossiaSetup{macedonian}{
+  bcp47=mk,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=MKD,
@@ -9,6 +10,9 @@
   fontsetup
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{macedonian}{mk}
+
 \def\macedonian at Alph#1{%
    \ifcase#1\or
    А\or Б\or В\or Г\or Д\or Ѓ\or Е\or

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malay.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -3,12 +3,18 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{malay}{%
+  bcp47=id,
   language=Malay,
   langtag=MLY,
   hyphennames={malay,melayu,bahasam,bahasai,indonesian,indon,bahasa},
   hyphenmins={2,2},
-  fontsetup=true}
+  fontsetup=true
+}
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=malaysian]{malay}{zsm}
+\setlanguagealias*[variant=indonesian]{malay}{id}
+
 % Babel aliases
 \setlanguagealias[variant=indonesian]{malay}{bahasai}
 \setlanguagealias[variant=malaysian]{malay}{bahasa}
@@ -30,7 +36,7 @@
       \malay at melayutrue
    \fi
    \ifmalay at melayu
-      \SetLanguageKeys{malay}{language=Malay,langtag=MLY,babelname=bahasam}%
+      \SetLanguageKeys{malay}{language=Malay,langtag=MLY,babelname=bahasam,bcp47=zsm}%
       \xpg at fontsetup@latin{malay}%
       % Check if \l at malay is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -48,7 +54,7 @@
         }%
       }%
    \else
-      \SetLanguageKeys{malay}{language=Indonesian,langtag=IND,babelname=bahasa}%
+      \SetLanguageKeys{malay}{language=Indonesian,langtag=IND,babelname=bahasa,bcp47=id}%
       \xpg at fontsetup@latin{malay}%
       % Check if \l at indonesian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -69,7 +75,10 @@
    \xpg at info{Option: malay, variant=\val}%
 }{\xpg at warning{Unknown malay variant `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{malay}{variant=malaysian}
 
+
 \def\malay at language{%
    \polyglossia at setup@language at patterns{\malay at variant}%
 }%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malayalam.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malayalam.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-malayalam.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -8,6 +8,7 @@
 % Translations provided by Kevin & Siji, 01-11-2009
 
 \PolyglossiaSetup{malayalam}{
+  bcp47=ml,
   script=Malayalam,
   scripttag=mlym,
   langtag=MAL, %FIXME there is also MLR for "Malayalam Reformed"
@@ -16,6 +17,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{malayalam}{ml}
+
 \def\captionsmalayalam{%
      \def\abstractname{സാരാംശം}%
      \def\appendixname{ശിഷ്ടം}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-marathi.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-marathi.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-marathi.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,4 +1,5 @@
 % Translations provided by Abhijit Navale <abhi_navale at live.in>
+% Ordinals (1-100) added by Niranjan Tambe <niranjanvikastambe at gmail.com> on 14th December, 2019
 % TODO implement Hindu calendar (not used in day-to-day practice)
 
 \ProvidesFile{gloss-marathi.ldf}[polyglossia: module for marathi]
@@ -11,6 +12,7 @@
 \RequirePackage{devanagaridigits}
 
 \PolyglossiaSetup{marathi}{
+  bcp47=mr,
   script=Devanagari,
   scripttag=deva,
   langtag=MAR,
@@ -21,16 +23,26 @@
   %TODO nouppercase=true,
 }
 
-\def\tmp at western{Western}
+% BCP-47 compliant aliases
+\setlanguagealias*{marathi}{mr}
+
 \newif\ifmarathi at devanagari@numerals
 \marathi at devanagari@numeralstrue
 
-\define at key{marathi}{numerals}[Devanagari]{%
-  \def\@tmpa{#1}%
-  \ifx\@tmpa\tmp at western
-    \marathi at devanagari@numeralsfalse
-  \fi}
+\define at choicekey*+{marathi}{numerals}[\val\nr]{Western,Devanagari}[Devanagari]{%
+   \ifcase\nr\relax
+      % Western:
+      \marathi at devanagari@numeralsfalse%
+   \or
+      % Devanagari:
+      \marathi at devanagari@numeralstrue%
+   \fi
+   \xpg at info{Option: Marathi, numerals=\val}%
+}{\xpg at warning{Unknown Marathi numerals value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{marathi}{numerals=Devanagari}
+
 \newcommand{\marathinumerals}[2]{\marathinumber{#2}}
 
 \def\marathinumber#1{%
@@ -38,50 +50,105 @@
     \devanagaridigits{\number#1}%
   \else
     \number#1%
-  \fi}
+  \fi%
+}
 
 \def\captionsmarathi{%
    \def\refname{संदर्भ}%
    \def\abstractname{सारांश}%
-   \def\bibname{संदर्भ ग्रंथांची यादी}%
+   \def\bibname{संदर्भसूची}%
    \def\prefacename{प्रस्तावना}%
    \def\chaptername{प्रकरण}%
    \def\appendixname{परिशिष्ट}%
    \def\contentsname{अनुक्रमणिका}%
-   \def\listfigurename{आकृत्यांची यादी}%
-   \def\listtablename{कोष्टकांची यादी}%
+   \def\listfigurename{आकृत्यांची सूची}%
+   \def\listtablename{कोष्टक सूची}%
    \def\indexname{सूची}%
    \def\figurename{आकृती}%
    \def\tablename{कोष्टक}%
-   %\def\thepart{}% TODO
-   \def\partname{भाग}%
-   \def\pagename{पान}%
-   \def\seename{पहा}%
-   \def\alsoname{हे सुध्दा पहा}%
+   \def\partname{खंड}%
+   \def\pagename{पृष्ठ}%
+   \def\seename{पाहा}%
+   \def\alsoname{हेदेखील पाहा}%
    \def\enclname{समाविष्ट}%
-   \def\ccname{सि.सि.}%
+   \def\ccname{सी.सी.}%
    \def\headtoname{प्रति}%
    \def\proofname{सिद्धता}%
-   \def\glossaryname{स्पष्टीकरणांची यादी}%
+   \def\glossaryname{संक्षेपसूची}%
    \def\authorsand{आणि}%
 }
+
 \def\datemarathi{%
    \def\marathimonth{%
      \ifcase\month\or
-       जानेवारी\or
-       फेब्रुवारी\or
-       मार्च\or
-       एप्रिल\or
-       मे\or
-       जून\or
-       जुलै\or
-       ऑगस्ट\or
-       सप्टेंबर\or
-       ऑक्टोबर\or
-       नोव्हेंबर\or
-       डिसेंबर\fi
+                जानेवारी\or
+                फेब्रुवारी\or
+                मार्च\or
+                एप्रिल\or
+                मे\or
+                जून\or
+                जुलै\or
+               ऑगस्ट\or
+               सप्टेंबर\or
+               ऑक्टोबर\or
+               नोव्हेंबर\or
+               डिसेंबर%
+     \fi%
    }%
-   \def\today{\marathinumber\day\space\marathimonth\space\marathinumber\year}%
+   \def\today{%
+     \marathinumber\day\space\marathimonth\space\marathinumber\year%
+   }%
 }
 
+\def\devanagari at akshar#1{\ifcase#1\or अ\or आ\or इ\or ई\or उ\or ऊ\or ए\or ऐ\or ओ\or औ\or अं\or अः\else\@ctrerr\fi}
+
+\def\devanagari at 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 ळ\else\@ctrerr%
+    \fi%
+}
+
+\def\devanagari at letter#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 अठ्ठावन्न \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\@ctrerr%
+  \fi%
+}
+
+\let\xpg at save@roman\@roman
+\let\xpg at save@Roman\@Roman
+
+\def\marathi at numbers{%
+  \let\@alph\devanagari at akshar
+  \let\@Alph\devanagari at letter
+  \let\@roman\devanagari at alph
+  \let\@Roman\devanagari at letter
+}
+
+\def\nomarathi at numbers{%
+  \let\@alph\latin at alph%
+  \let\@Alph\latin at Alph%
+  \let\@roman\xpg at save@roman
+  \let\@Roman\xpg at save@Roman
+}
+
+\def\blockextras at marathi{%
+  \let\xpg at orig@baselinestretch\baselinestrech%
+  \renewcommand{\baselinestretch}{1.2}%
+  \renewcommand{\labelitemii}{$\rightarrow$}%
+}
+
+\let\xpg at orig@labelitemii\labelitemii
+
+\def\noextras at marathi{%
+  \let\baselinestrech\xpg at orig@baselinestretch%
+  \let\labelitemii\xpg at orig@labelitemii%
+}
+
 \endinput

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mk.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mk.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mk.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-mk.ldf}[polyglossia: module for mk (macedonian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{macedonian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mk.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ml.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ml.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ml.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-ml.ldf}[polyglossia: module for ml (malayalam)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{malayalam}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ml.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mn.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mn.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mn.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-mn.ldf}[polyglossia: module for mn (mongolian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{mongolian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mn.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mongolian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -3,6 +3,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{mongolian}{
+  bcp47=mn,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=MNG,
@@ -14,6 +15,9 @@
   Localnumeral=Mongoliannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{mongolian}{mn}
+
 % This file is derived from mongolian-babel. which
 % provides support for Mongolian (Khalkha variety)
 % with Cyrillic script
@@ -21,15 +25,32 @@
 %       variants of Mongolian
 
 \newif\ifcyrillic at numerals
-\define at key{mongolian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{mongolian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Mongolian, numerals=\val}%
+}{\xpg at warning{Unknown Mongolian numerals value `#1'}}
 
-\define at boolkey{mongolian}[mongolian@]{babelshorthands}[false]{}
+\define at boolkey{mongolian}[mongolian@]{babelshorthands}[true]{}
 
-\setkeys{mongolian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{mongolian}{babelshorthands=false,numerals=arabic}
 
 \ifsystem at babelshorthands
   \setkeys{mongolian}{babelshorthands=true}
@@ -124,7 +145,11 @@
 
 \def\mongoliannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \mongolian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -132,7 +157,11 @@
 
 \def\Mongoliannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \mongolian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -141,25 +170,30 @@
 \let\mongoliannumeral=\mongoliannumber
 \let\Mongoliannumeral=\Mongoliannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\mongolian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\mongolian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\mongolian 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 Я%
+   \else\xpg at ill@value{#1}{mongolian at asbuk@Alph}\fi%
+}
 
-%\def\mongolian at 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 Я\else\xpg at ill@value{#1}{mongolian at Alph}\fi}
+\def\mongolian 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 я%
+   \else\xpg at ill@value{#1}{mongolian at asbuk@alph}\fi%
+}
 
-%\def\mongolian at 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 я\else\xpg at ill@value{#1}{mongolian at alph}\fi}
-
 \def\mongolian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph

Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mr.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mr.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mr.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-mr.ldf}[polyglossia: module for mr (marathi)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{marathi}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-mr.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nb.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nb.ldf	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nb.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -0,0 +1,7 @@
+\ProvidesFile{gloss-nb.ldf}[polyglossia: module for nb (norwegian)]
+
+% We provide this as a bcp47-compliant alias
+
+\xpg at load@master at language{norwegian}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nb.ldf
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nko.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nko.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-nko.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-nko.ldf}[Polyglossia: module for N’Ko v0.1 2013/05/19]
 \PolyglossiaSetup{nko}{%
+  bcp47=nko,
   script=N'ko,
   scripttag=nko~,
   langtag=NKO,
@@ -8,6 +9,7 @@
   direction=RL,
   localnumeral=nkonumerals
 }
+
 \RequirePackage{nkonumbers}%
 
 \newcommand{\nkonumerals}[2]{\nkonumber{#2}}

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-norwegian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-norwegian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-norwegian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-norwegian.ldf}[polyglossia: module for norwegian]
 \PolyglossiaSetup{norwegian}{
+  bcp47=nn,
   hyphennames={nynorsk},
   langtag=NYN,
   hyphenmins={2,2},
@@ -7,6 +8,9 @@
   fontsetup=false,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=bokmal]{norwegian}{nb}
+\setlanguagealias*[variant=nynorsk]{norwegian}{nn} 
 % Babel and backwards compat. aliases
 \setlanguagealias[variant=bokmal]{norwegian}{norsk}
 \setlanguagealias[variant=nynorsk]{norwegian}{nynorsk}
@@ -16,12 +20,12 @@
    \ifcase\nr\relax
       % nynorsk:
       \def\norwegian at variant{nynorsk}%
-      \SetLanguageKeys{norwegian}{langtag=NYN,babelname=nynorsk}%
+      \SetLanguageKeys{norwegian}{langtag=NYN,babelname=nynorsk,bcp47=nn}%
       \xpg at fontsetup@latin{norwegian}%
    \or
       % bokmal:
       \def\norwegian at variant{norsk}%
-      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk}%
+      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk,bcp47=nb}%
       \xpg at fontsetup@latin{norwegian}%
    \fi
    \xpg at info{Option: norwegian, variant=\val}%
@@ -28,8 +32,12 @@
 }{\xpg at warning{Unknown norwegian variant `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{norwegian}{variant=nynorsk}
+
+
 \def\norwegian at language{%
-   \polyglossia at setup@language at patterns{\norwegian at variant}
+   \polyglossia at setup@language at patterns{\norwegian at variant}%
 }%
 
 \def\captionsnorwegian at nynorsk{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-occitan.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -18,6 +18,7 @@
 \ProvidesFile{gloss-occitan.ldf}[2016/02/04 v0.3 polyglossia:
      module for Occitan]
 \PolyglossiaSetup{occitan}{
+  bcp47=oc,
   hyphennames={occitan},
   langtag=OCI,
   hyphenmins={2,2},
@@ -25,6 +26,10 @@
   indentfirst=true,
   fontsetup=true,
 }
+
+% BCP-47 compliant aliases
+\setlanguagealias*{occitan}{oc}
+
 \define at boolkey{occitan}[occitan@]{babelshorthands}[true]{}
 
 \ifsystem at babelshorthands

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-persian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-persian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-persian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -10,6 +10,7 @@
 \RequirePackage{farsical}
 \RequirePackage{hijrical}
 \PolyglossiaSetup{persian}{
+  bcp47=fa,
   babelname=farsi,
   script=Arabic,
   direction=RL,
@@ -20,6 +21,9 @@
   localnumeral=farsinumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{persian}{fa}
+
 % Babel and backwards compat. alias
 \setlanguagealias{persian}{farsi}
 
@@ -46,7 +50,8 @@
 
 %TODO add option for CALENDAR
 
-\setkeys{persian}{locale,numerals}
+% Register default options
+\xpg at initialize@gloss at options{persian}{locale=default,numerals=eastern,abjadjimnotail=false}
 
 \def\farsigregmonth#1{\ifcase#1%
   \or ژانویه\or فوریه\or مارس\or آوریل\or مه\or ژوئن\or ژوئیه\or اوت\or سپتامبر\or اکتبر\or نوامبر\or دسامبر\fi}
@@ -87,28 +92,13 @@
 
 \newcommand{\farsinumerals}[2]{\farsinumber{#2}}
 
-\newif\ifpersiandigits
-
 \def\farsinumber#1{%
   \if at western@numerals
     \number#1%
   \else
-    \ifxetex
-      \ifnum\XeTeXcharglyph"06F0 > 0\relax
-        \persiandigitstrue
-      \fi
-    \else\ifluatex
-      \expandafter\ifnum\directlua{polyglossia.check_char(0x6F0)} > 0\relax
-        \persiandigitstrue
-      \fi
-    \fi\fi
-    \ifpersiandigits
-      \farsidigits{\number#1}%
-      %%{\protect\addfontfeature{Mapping=farsidigits}\number#1}%
-    \else%
-      \arabicdigits{\number#1}%
-      %%{\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-    \fi
+    \xpg at if@char at available{06F0}%
+          {\farsidigits{\number#1}}%
+          {\arabicdigits{\number#1}}%
   \fi
 }
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-piedmontese.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,6 +2,7 @@
 \ProvidesFile{gloss-piedmontese.ldf}[2013/02/12 v1.0 polyglossia: module for piedmontese]
 \makeatletter
 \PolyglossiaSetup{piedmontese}{
+  bcp47=pms,
   hyphennames={piedmontese},
   hyphenmins={2,2},
   langtag=PMS,
@@ -9,6 +10,8 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{piedmontese}{pms}
 
 \define at boolkey{piedmontese}[piedmontese@]{babelshorthands}[true]{}
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-polish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-polish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-polish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,6 @@
 \ProvidesFile{gloss-polish.ldf}[polyglossia: module for polish]
 \PolyglossiaSetup{polish}{
+  bcp47=pl,
   hyphennames={polish},
   hyphenmins={2,2},
   langtag=PLK,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{polish}{pl}
+
 \def\captionspolish{%
   \def\prefacename{Przedmowa}%
   \def\refname{Literatura}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-portuguese.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-portuguese.ldf}[polyglossia: module for portuguese]
 
 \PolyglossiaSetup{portuguese}{
+  bcp47=pt-PT,
   babelname=portuges,
   hyphennames={portuges,portuguese},
   hyphenmins={2,3},
@@ -8,6 +9,11 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=portuguese]{portuguese}{pt-PT}
+\setlanguagealias*[variant=brazilian]{portuguese}{pt-BR}
+\setlanguagealias*{portuguese}{pt}
+
 % Babel aliases
 \setlanguagealias[variant=portuguese]{portuguese}{portuges}
 \setlanguagealias[variant=brazilian]{portuguese}{brazil}
@@ -17,11 +23,11 @@
    \ifcase\nr\relax
       % portuguese:
       \def\portuguese at variant{portuges}%
-      \SetLanguageKeys{portuguese}{babelname=portuges}%
+      \SetLanguageKeys{portuguese}{babelname=portuges,bcp47=pt-PT}%
    \or
       % brazilian:
       \def\portuguese at variant{brazil}%
-      \SetLanguageKeys{portuguese}{babelname=brazil}%
+      \SetLanguageKeys{portuguese}{babelname=brazil,bcp47=pt-BR}%
       \xpg at ifdefined{brazil}{}%
 	    {\xpg at warning{No hyphenation patterns were loaded for "Portuguese (Brazil)"\MessageBreak
 	      I will use the standard patterns for Portuguese instead}%
@@ -31,8 +37,12 @@
 }{\xpg at warning{Unknown portuguese variant `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{portuguese}{variant=portuguese}
+
+
 \def\portuguese at language{%
-   \polyglossia at setup@language at patterns{\portuguese at variant}
+   \polyglossia at setup@language at patterns{\portuguese at variant}%
 }%
 
 \def\captionsportuguese at portuges{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romanian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romanian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romanian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-romanian.ldf}[polyglossia: module for romanian]
 
 \PolyglossiaSetup{romanian}{
+  bcp47=ro,
   hyphennames={romanian},
   hyphenmins={2,2},
   langtag=ROM,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{romanian}{ro}
+
 \def\captionsromanian{%
    \def\refname{Bibliografie}%
    \def\abstractname{Rezumat}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romansh.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romansh.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-romansh.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-romansh.ldf}[polyglossia: module for romansh]
 \makeatletter
 \PolyglossiaSetup{romansh}{%
+  bcp47=rm,
   hyphennames={romansh},
   hyphenmins={2,2},
   langtag=RMS,
@@ -8,6 +9,8 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{romansh}{rm}
 
 \def\captionsromansh{%
   \def\prefacename{Prefaziun}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-russian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -3,6 +3,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{russian}{
+  bcp47=ru,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=RUS,
@@ -15,11 +16,16 @@
   Localnumeral=Russiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{russian}{ru}
+\setlanguagealias*[spelling=modern]{russian}{ru-luna1918}
+\setlanguagealias*[spelling=old]{russian}{ru-petr1708}
+
 \newif\if at russian@modern
 \define at key{russian}{spelling}[modern]{%
   \ifstrequal{#1}{old}%
-    {\@russian at modernfalse}%
-    {\@russian at moderntrue}%
+    {\@russian at modernfalse\SetLanguageKeys{russian}{bcp47=ru-petr1708}}%
+    {\@russian at moderntrue\SetLanguageKeys{russian}{bcp47=ru}}%
 }
 
 \def\captionsrussian{%
@@ -31,13 +37,29 @@
 }%
 
 \newif\ifcyrillic at numerals
-\define at key{russian}{numerals}[arabic]{%
-   \ifstrequal{#1}{cyrillic}%
-      {\cyrillic at numeralstrue}%
-      {\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{russian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Russian, numerals=\val}%
+}{\xpg at warning{Unknown Russian numerals value `#1'}}
 
-\define at boolkey{russian}[russian@]{indentfirst}{
+\define at boolkey{russian}[russian@]{indentfirst}[true]{
    \ifrussian at indentfirst
       \SetLanguageKeys{russian}{indentfirst=true}
    \else
@@ -45,10 +67,13 @@
   \fi
 }
 
-\define at boolkey{russian}[russian@]{babelshorthands}[false]{}
+\define at boolkey{russian}[russian@]{babelshorthands}[true]{}
 
-\setkeys{russian}{spelling,numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{russian}{babelshorthands=false,spelling=modern,numerals=arabic,indentfirst=false}
+
+
 \ifsystem at babelshorthands
   \setkeys{russian}{babelshorthands=true}
 \else
@@ -231,7 +256,11 @@
 
 \def\russiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \russian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -239,7 +268,11 @@
 
 \def\Russiannumber#1{%
   \ifcyrillic at numerals
-    \cyr at Alph{#1}%
+    \ifcyrillic at asbuk@numerals
+      \russian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
   \fi%
@@ -248,25 +281,31 @@
 \let\russiannumeral=\russiannumber
 \let\Russiannumeral=\Russiannumber
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\russian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\russian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
+
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% thus ends at 30.
+\def\russian 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 Я%
+   \else\xpg at ill@value{#1}{russian at asbuk@Alph}\fi%
+}
 
-%\def\russian at 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 Я\else\xpg at ill@value{#1}{russian at Alph}\fi}
+\def\russian 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 я%
+   \else\xpg at ill@value{#1}{russian at asbuk@alph}\fi%
+}
 
-%\def\russian at 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 я\else\xpg at ill@value{#1}{russian at alph}\fi}
-
 \def\russian at numbers{%
    \let\latin at alph\@alph
    \let\latin at Alph\@Alph
@@ -273,8 +312,8 @@
    \ifcyrillic at numerals%
      \def\russian at alph##1{\expandafter\russiannumeral\expandafter{\the##1}}%
      \def\russian at Alph##1{\expandafter\Russiannumeral\expandafter{\the##1}}%
-      \let\@alph\russian at alph%
-      \let\@Alph\russian at Alph%
+     \let\@alph\russian at alph%
+     \let\@Alph\russian at Alph%
    \fi
 }
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sami.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sami.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sami.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-sami.ldf}[polyglossia: module for sami]
 
 \PolyglossiaSetup{sami}{
+  bcp47=se,
   babelname=samin,
   hyphennames={samin},
   hyphenmins={2,2},
@@ -9,6 +10,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{sami}{se}
+
 % Babel and backwards compat. alias
 \setlanguagealias{sami}{samin}
 %\setlanguagealias[variant=northern]{sami}{samin}
@@ -32,7 +36,7 @@
 
 
 %\def\sami at language{%
-%   \polyglossia at setup@language at patterns{\sami at variant}
+%   \polyglossia at setup@language at patterns{\sami at variant}%
 %}%
 
 \def\captionssami at northern{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -9,6 +9,7 @@
 \RequirePackage{devanagaridigits}
 
 \PolyglossiaSetup{sanskrit}{
+  bcp47=sa-Deva,
   langtag=SAN,
   hyphennames={sanskrit,prakrit},
   hyphenmins={1,3},
@@ -17,6 +18,16 @@
   localnumeral=sanskritnumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{sanskrit}{sa}
+\setlanguagealias*[script=Devanagari]{sanskrit}{sa-Deva}
+\setlanguagealias*[script=Malayalam]{sanskrit}{sa-Mlym}
+\setlanguagealias*[script=Telugu]{sanskrit}{sa-Telu}
+\setlanguagealias*[script=Bengali]{sanskrit}{sa-Beng}
+\setlanguagealias*[script=Kannada]{sanskrit}{sa-Knda}
+\setlanguagealias*[script=Gujarati]{sanskrit}{sa-Gujr}
+\setlanguagealias*[script=Latin]{sanskrit}{sa-Latn}
+
 \define at key{sanskrit}{Script}[Devanagari]{%
   \ifcsdef{fontsetup at sanskrit@#1}%
     {\csname fontsetup at sanskrit@#1\endcsname}%
@@ -27,30 +38,28 @@
 \define at key{sanskrit}{script}[Devanagari]{\setkeys{sanskrit}{Script=#1}}
 
 \def\fontsetup at sanskrit@Devanagari{%
-  \SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari}
+  \SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari,bcp47=sa-Deva}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Gujarati{%
-  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati}
+  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati,bcp47=sa-Gujr}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Malayalam{%
-  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam}
+  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam,bcp47=sa-Mlym}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Bengali{%
-  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali}
+  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali,bcp47=sa-Beng}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Kannada{%
-  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada}
+  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada,bcp47=sa-Knda}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Telugu{%
-  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu}
+  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu,bcp47=sa-Relu}
   \xpg at fontsetup@nonlatin{sanskrit}}
 \def\fontsetup at sanskrit@Latin{%
-  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin}
+  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin,bcp47=sa-Latn}
   \xpg at fontsetup@latin{sanskrit}}
 
-\setkeys{sanskrit}{Script} %sets the default for Devanagari
 
-
 \newif\ifsanskrit at devanagari@numerals
 \sanskrit at devanagari@numeralstrue
 \define at choicekey*+{sanskrit}{numerals}[\val\nr]{Devanagari,Western}[Devanagari]{%
@@ -65,6 +74,10 @@
 }{\xpg at warning{Unknown Sanskrit numeral `#1'}}
 
 
+% Register default options
+\xpg at initialize@gloss at options{sanskrit}{script=Devanagari,numerals=Devanagari}
+
+
 \newcommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
 
 \def\sanskritnumber#1{%
@@ -78,7 +91,8 @@
 \ifluatex
   \directlua{require('polyglossia-sanskrit')}%
 \else
-  \newXeTeXintercharclass\sanskrit at punctthin % ! ? ‼ ⁇ ⁈ ⁉ : ; danda double_danda
+  \newXeTeXintercharclass\sanskrit at questionexclamation % ! ? ‼ ⁇ ⁈ ⁉ ‽
+  \newXeTeXintercharclass\sanskrit at punctthin % : ; danda double_danda
 \fi
 
 \def\sanskrit at punctthinspace{{\unskip\thinspace}}
@@ -88,17 +102,20 @@
     \directlua{polyglossia.activate_sanskrit_punct()}%
   \else
     \XeTeXinterchartokenstate=1%
-    \XeTeXcharclass `\! \sanskrit at punctthin
-    \XeTeXcharclass `\? \sanskrit at punctthin
-    \XeTeXcharclass `\‼ \sanskrit at punctthin
-    \XeTeXcharclass `\⁇ \sanskrit at punctthin
-    \XeTeXcharclass `\⁈ \sanskrit at punctthin
-    \XeTeXcharclass `\⁉ \sanskrit at punctthin
+    \XeTeXcharclass `\! \sanskrit at questionexclamation
+    \XeTeXcharclass `\? \sanskrit at questionexclamation
+    \XeTeXcharclass `\‼ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁇ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁈ \sanskrit at questionexclamation
+    \XeTeXcharclass `\⁉ \sanskrit at questionexclamation
+    \XeTeXcharclass `\‽ \sanskrit at questionexclamation % interrobang, U+203D
     \XeTeXcharclass `\: \sanskrit at punctthin
     \XeTeXcharclass `\; \sanskrit at punctthin
     \XeTeXcharclass `\। \sanskrit at punctthin % danda, U+0964
     \XeTeXcharclass `\॥ \sanskrit at punctthin % double danda, U+0965
+    \XeTeXinterchartoks \z@ \sanskrit at questionexclamation = \sanskrit at punctthinspace
     \XeTeXinterchartoks \z@ \sanskrit at punctthin = \sanskrit at punctthinspace
+    \XeTeXinterchartoks \sanskrit at questionexclamation \sanskrit at punctthin = \sanskrit at punctthinspace
   \fi
 }
 
@@ -112,6 +129,7 @@
     \XeTeXcharclass `\⁇ \z@
     \XeTeXcharclass `\⁈ \z@
     \XeTeXcharclass `\⁉ \z@
+    \XeTeXcharclass `\‽ \z@
     \XeTeXcharclass `\: \z@
     \XeTeXcharclass `\; \z@
     \XeTeXcharclass `\। \z@

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-serbian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -7,6 +7,7 @@
 \RequirePackage{xpg-cyrillicnumbers}
 
 \PolyglossiaSetup{serbian}{
+  bcp47=sr-Latn,
   langtag=SRB,
   hyphennames={serbian},
   hyphenmins={2,2},
@@ -17,6 +18,11 @@
   %TODO localalph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{serbian}{sr}
+\setlanguagealias*[script=Cyrillic]{serbian}{sr-Cyrl}
+\setlanguagealias*[script=Latin]{serbian}{sr-Latn}
+
 % Babel aliases
 \setlanguagealias[script=Cyrillic]{serbian}{serbianc}
 
@@ -25,12 +31,12 @@
    \ifcase\nr\relax
       % cyrillic:
       \@serbian at cyrtrue
-      \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc}
+      \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl}
       \xpg at fontsetup@nonlatin{serbian}%
    \or
       % latin:
       \@serbian at cyrfalse
-      \SetLanguageKeys{serbian}{scripttag=latn,script=Latin}
+      \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,bcp47=sr-Latn}
       \xpg at fontsetup@latin{serbian}%
       %TODO \def\serbian at language{\language=\l at serbianlat}%
       % or should we use Croatian patterns as a fallback for the time being???
@@ -40,17 +46,34 @@
 
 \define at key{serbian}{script}[Cyrillic]{\setkeys{serbian}{Script=#1}}
 
-\newif\ifserbian at numerals
-\define at key{serbian}{numerals}[arabic]{%
-   \ifstrequal{#1}{latin}{\serbian at numeralsfalse}{%
-       \ifstrequal{#1}{cyrillic}%
-          {\serbian at numeralstrue}
-          {\serbian at numeralsfalse}%
-   }%
-}
+\newif\ifcyrillic at numerals
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{serbian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Serbian, numerals=\val}%
+}{\xpg at warning{Unknown Serbian numerals value `#1'}}
 
 \setkeys{serbian}{Script,numerals}
 
+% Register default options
+\xpg at initialize@gloss at options{serbian}{script=Cyrillic,numerals=arabic}
+
 \def\captionsserbian{%
    \if at serbian@cyr\captionsserbian at cyr\else\captionsserbian at lat\fi
 }
@@ -135,19 +158,27 @@
 \newcommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}
 
 \def\serbiannumber#1{%
-  \ifserbian at numerals
-    \cyr at alph{#1}%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
   \else
     \number#1%
-  \fi
+  \fi%
 }
 
 \def\Serbiannumber#1{%
-  \ifserbian at numerals
-    \cyr at Alph{#1}%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
   \else
     \number#1%
-  \fi
+  \fi%
 }
 
 \let\serbiannumeral=\serbiannumber
@@ -177,25 +208,30 @@
    \ifserbian at numerals\noserbian at numbers\fi
 }
 
-\def\Asbuk#1{\expandafter\cyr at Alph\csname c@#1\endcsname}
+\def\Asbuk#1{\expandafter\serbian at asbuk@Alph\csname c@#1\endcsname}
+\def\asbuk#1{\expandafter\serbian at asbuk@alph\csname c@#1\endcsname}
 
-\def\asbuk#1{\expandafter\cyr at 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}
 
 % This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
-% thus ends at 30. We now use proper cyrillic numbering.
+% 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 Я%
+   \else\xpg at ill@value{#1}{serbian at asbuk@Alph}\fi%
+}
 
-%\def\cyr at 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 Ш\else\xpg at ill@value{#1}{cyr at 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 я%
+   \else\xpg at ill@value{#1}{serbian at asbuk@alph}\fi%
+}
 
-%\def\cyr at 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 ш\else\xpg at ill@value{#1}{cyr at alph}\fi}
-
  
 \endinput
 

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovak.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-slovak.ldf}[polyglossia: module for slovak]
 
 \PolyglossiaSetup{slovak}{
+  bcp47=sk,
   hyphennames={slovak},
   hyphenmins={2,2},
   langtag=SKY,
@@ -7,6 +8,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{slovak}{sk}
+
 \ifluatex
   \RequirePackage{luavlna}
 \fi
@@ -17,7 +21,8 @@
 
 \define at boolkey{slovak}[slovak@]{vlna}[true]{}
 
-\setkeys{slovak}{splithyphens,vlna}
+% Register default options
+\xpg at initialize@gloss at options{slovak}{babelshorthands=false,splithyphens=true,vlna=true}
 
 \ifsystem at babelshorthands
   \setkeys{slovak}{babelshorthands=true}
@@ -32,8 +37,12 @@
 }{}
 
 \def\slovak@@splhyphen#1{%
-  \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
-  \nobreak\hskip\z@%
+  \ifnum\hyphenchar \font>0%
+    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
+    \nobreak\hskip\z@%
+  \else%
+    #1%
+  \fi%
 }
 
 \def\slovak at splhyphen{%
@@ -220,13 +229,13 @@
 \def\blockextras at slovak{%
   \ifslovak at babelshorthands\slovak at shorthands\fi%
   \ifslovak at vlna\slovak at vlna\else\noslovak at vlna\fi%
-  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyhens\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 vlna\slovak at vlna\else\noslovak at vlna\fi%
-  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyhens\fi%
+  \ifslovak at splithyphens\slovak at hyphens\else\noslovak at hyphens\fi%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovenian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovenian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-slovenian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-slovenian.ldf}[polyglossia: module for slovenian]
 
 \PolyglossiaSetup{slovenian}{
+  bcp47=sl,
   hyphennames={slovenian,slovene},
   babelname=slovene,
   hyphenmins={2,2},
@@ -8,20 +9,18 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{slovenian}{sl}
+
 % Babel aliases
 \setlanguagealias{slovenian}{slovene}
 
-\providebool{slovenian at localalph}
-\define at boolkey{slovenian}[slovenian@]{localalph}[false]{%
-  \def\@tmpa{#1}%
-  \def\@tmptrue{true}%
-  \ifx\@tmpa\@tmptrue
-    \slovenian at localalphtrue
-  \fi
-  \setlocalalph
-}
+\define at boolkey{slovenian}[slovenian@]{localalph}[true]{}
 
+% Register default options
+\xpg at initialize@gloss at options{slovenian}{localalph=false}
 
+
 \def\captionsslovenian{%
    \def\refname{Literatura}%
    \def\abstractname{Povzetek}%
@@ -45,7 +44,7 @@
    \def\headtoname{Prejme}%
    \def\proofname{Dokaz}%
    \def\glossaryname{Slovar}%
-   }
+}
 
 \def\dateslovenian{%   
   \def\today{\number\day.~\ifcase\month\or
@@ -52,7 +51,7 @@
     januar\or februar\or marec\or april\or maj\or junij\or
     julij\or avgust\or september\or oktober\or november\or december\fi
     \space \number\year}%
-  }
+}
 
 \def\slovenian at alph#1{%
   \ifcase#1\or a\or b\or c\or č\or d\or e\or f\or g\or h\or i\or j\or k\or l\or
@@ -60,15 +59,20 @@
 }
 \def\slovenian at Alph#1{%
   \ifcase#1\or A\or B\or C\or Č\or D\or E\or F\or G\or H\or I\or J\or K\or L\or
-  M\or N\or O\or P\or R\or S\or Š\or T\or U\or V\or Z\or Ž\else#1\fi}
+  M\or N\or O\or P\or R\or S\or Š\or T\or U\or V\or Z\or Ž\else#1\fi
+}
+
 \def\abeceda#1{\expandafter\slovenian at alph\csname c@#1\endcsname}
 \def\Abeceda#1{\expandafter\slovenian at Alph\csname c@#1\endcsname}
 
-\def\setlocalalph{%
-  \def\extras at slovenian{\let\alph\abeceda\let\Alph\Abeceda}
-  \def\blockextras at slovenian{\extras at slovenian}
-  \def\inlineextras at slovenian{\extras at slovenian}
-  \def\noextras at slovenian{\let\alph\latinalph\let\Alph\latinAlph}
+\def\extras at slovenian{%
+  \ifslovenian at localalph\let\alph\abeceda\let\Alph\Abeceda\fi%
 }
 
+\def\blockextras at slovenian{\extras at slovenian}
+
+\def\inlineextras at slovenian{\extras at slovenian}
+
+\def\noextras at slovenian{\let\alph\latinalph\let\Alph\latinAlph}
+
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sorbian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sorbian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-sorbian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-sorbian.ldf}[polyglossia: module for sorbian]
 
 \PolyglossiaSetup{sorbian}{
+  bcp47=hsb,
   language=Upper Sorbian,
   babelname=uppersorbian,
   hyphennames={usorbian,uppersorbian},
@@ -9,6 +10,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*[variant=upper]{sorbian}{hsb}
+\setlanguagealias*[variant=lower]{sorbian}{dsb} 
 % Backwards compat. aliases
 \setlanguagealias[variant=lower]{sorbian}{lsorbian}
 \setlanguagealias[variant=upper]{sorbian}{usorbian}
@@ -22,7 +26,7 @@
    \ifcase\nr\relax
       % upper:
       \def\sorbian at variant{usorbian}%
-      \SetLanguageKeys{sorbian}{language=Upper Sorbian,langtag=USB,babelname=uppersorbian}%
+      \SetLanguageKeys{sorbian}{language=Upper Sorbian,langtag=USB,babelname=uppersorbian,bcp47=hsb}%
       \xpg at fontsetup@latin{sorbian}%
       % Check if \l at usorbian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -42,7 +46,7 @@
    \or
       % lower:
       \def\sorbian at variant{lsorbian}%
-      \SetLanguageKeys{sorbian}{language=Lower Sorbian,langtag=LSB,babelname=lowersorbian}%
+      \SetLanguageKeys{sorbian}{language=Lower Sorbian,langtag=LSB,babelname=lowersorbian,bcp47=dsb}%
       \xpg at fontsetup@latin{sorbian}%
       % Check if \l at lsorbian is defined. If not, try to set it to some variety
       % (specific order as in the csv list below), or null language if everything fails
@@ -66,7 +70,8 @@
 
 \define at boolkey{sorbian}[sorbian@]{olddate}[true]{}
 
-\setkeys{sorbian}{variant}
+% Register default options
+\xpg at initialize@gloss at options{sorbian}{variant=upper,olddate=false}
 
 
 \def\sorbian at language{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-spanish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,8 +1,10 @@
 \ProvidesFile{gloss-spanish.ldf}[polyglossia: module for spanish]
 
 \PolyglossiaSetup{spanish}{
+  bcp47=es-ES,
   hyphennames={spanish},
   hyphenmins={2,2},
+  totalhyphenmin=5,
   langtag=ESP,
   frenchspacing=true,
   indentfirst=true,
@@ -10,6 +12,11 @@
   babelname=spanish
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{spanish}{es}
+\setlanguagealias*[variant=mexican]{spanish}{es-MX}
+\setlanguagealias*[variant=spanish]{spanish}{es-ES}
+
 % Babel aliases
 \setlanguagealias[variant=mexican]{spanish}{spanishmx}
 
@@ -19,11 +26,11 @@
    \ifcase\nr\relax
       % spanish:
       \@spanish at mexicofalse%
-      \SetLanguageKeys{spanish}{babelname=spanish}%
+      \SetLanguageKeys{spanish}{babelname=spanish,bcp47=es-ES}%
    \or
       % mexican:
       \@spanish at mexicotrue%
-      \SetLanguageKeys{spanish}{babelname=spanishmx}%
+      \SetLanguageKeys{spanish}{babelname=spanishmx,bcp47=es-MX}%
    \fi
    \xpg at info{Option: spanish, variant=\val}%
 }{\xpg at warning{Unknown spanish variant `#1'}}
@@ -58,6 +65,10 @@
    \xpg at info{Option: Spanish, spanishoperators=\val}%
 }{\xpg at warning{Unknown spanishoperators value `#1'}}
 
+
+% Register default options
+\xpg at initialize@gloss at options{spanish}{variant=spanish,spanishoperators=none}
+
 \let\xpg at save@lim\lim
 \let\xpg at save@limsup\limsup
 \let\xpg at save@liminf\liminf

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-swedish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-swedish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-swedish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-swedish.ldf}[polyglossia: module for swedish]
 
 \PolyglossiaSetup{swedish}{
+  bcp47=sv,
   hyphennames={swedish},
   hyphenmins={2,2},
   langtag=SVE,
@@ -8,6 +9,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{swedish}{sv}
+
 \def\captionsswedish{%
   \def\refname{Referenser}%
   \def\abstractname{Sammanfattning}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-syriac.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-syriac.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-syriac.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -9,6 +9,7 @@
 \RequirePackage{arabicnumbers}
 
 \PolyglossiaSetup{syriac}{
+  bcp47=syr,
   script=Syriac,
   scripttag=syrc,
   langtag=SYR,
@@ -19,6 +20,9 @@
   %TODO localalph
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{syriac}{syr}
+
 \def\syriacnumber#1{\@syriacnumber{#1}}%
 
 \newif\if at eastern@numerals
@@ -36,7 +40,8 @@
  	  \fi
   \fi}
 
-\setkeys{syriac}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{syriac}{numerals=western}
 	
 %\define at key{polyglossia}{syriaclocale}[default]{%
 %	\def\@syriac at locale{#1}}
@@ -120,33 +125,22 @@
       %%% we test for the presence of one of ١٢٣٤٥٦٧٨٩٠ in the Syriac font, 
       %%% else we try \arabicfont if defined (and give a warning), 
       %%% else we fall back to the Western numerals.
-      \ifxetex
-         \ifnum\XeTeXcharglyph"0661 > 0%
-           %%\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-           \protect\arabicdigits{\number#1}%
-         \else%
+      \xpg at if@char at available{0661}%
+          {\protect\arabicdigits{\number#1}}%
+          {\arabicdigits{\number#1}
            \ifcsdef{arabicfont}%
 	     {\protect\arabicdigits{\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: I am using \string\arabicfont instead}}%
+	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
+                           I am using \string\arabicfont instead}}%
 	     {\number#1%%% <---changed from \RL{\protect\reset at font\protect\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: since \string\arabicfont is not defined, we'll use Western numerals instead}}%
-         \fi
-     \else% LuaTeX
-         \expandafter\ifnum\directlua{polyglossia.check_char(0x661)} > 0\relax
-           %%\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
-           \protect\arabicdigits{\number#1}%
-         \else%
-           \ifcsdef{arabicfont}%
-	     {\protect\arabicdigits{\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: I am using \string\arabicfont instead}}%
-	     {\number#1%%% <---changed from \RL{\protect\reset at font\protect\number#1}%
-	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs: since \string\arabicfont is not defined, we'll use Western numerals instead}}%
-         \fi
-     \fi
+	      \xpg at warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
+                           since \string\arabicfont is not defined, we'll use Western numerals instead}}%
+          }%
    \else
      %%\RL{\protect\reset at font\number#1}%
      \number#1%
-   \fi}
+   \fi%
+}
 
 \def\syriac at numbers{%
    \let\@alph\abjadsyriac%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tamil.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tamil.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tamil.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -8,6 +8,7 @@
 % Translations provided by Kevin & Siji, 01-11-2009
 
 \PolyglossiaSetup{tamil}{
+  bcp47=ta,
   script=Tamil,
   scripttag=taml,
   langtag=TAM,
@@ -16,6 +17,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{tamil}{ta}
+
 \def\captionstamil{%
      \def\abstractname{சாராம்சம்}%
      \def\appendixname{பிற்சேர்க்கை}%பின்னிணைப்பு

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-telugu.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-telugu.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-telugu.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -8,6 +8,7 @@
 % Translations provided by Anmol Sharma <unmole.in at gmail.com>
 
 \PolyglossiaSetup{telugu}{
+  bcp47=te,
   script=Telugu,
   scripttag=telu,
   langtag=TEL,
@@ -16,6 +17,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{telugu}{te}
+
 \def\captionstelugu{%
    \def\refname{ఆధారాలు}%
    \def\abstractname{సారాంశం}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-thai.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-thai.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-thai.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -15,6 +15,7 @@
 and may look very wrong.}
 \fi
 \PolyglossiaSetup{thai}{
+  bcp47=th,
   script=Thai,
   scripttag=thai,
   langtag=THA,
@@ -25,6 +26,9 @@
   %TODO localdigits=thainumber
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{thai}{th}
+
 \newif\if at thai@numerals
 \def\tmp at thai{thai}
 \define at key{thai}{numerals}[arabic]{%
@@ -33,7 +37,8 @@
 	  \@thai at numeralsfalse\fi
 }
 
-\setkeys{thai}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{thai}{numerals=arabic}
 
 \def\captionsthai{%
    \def\refname{หนังสืออ้างอิง}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-tibetan.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -6,6 +6,7 @@
 %%
 
 \PolyglossiaSetup{tibetan}{
+  bcp47=bo,
   script=Tibetan,
   scripttag=tibt,
   langtag=TIB,
@@ -15,6 +16,9 @@
   %TODO localalph={xxx at alph,xxx at Alph}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{tibetan}{bo}
+
 \newif\if at tibetan@numerals
 \def\tmp at tibetan{tibetan}
 \define at key{tibetan}{numerals}[tibetan]{%
@@ -48,7 +52,8 @@
   \fi %
 }
 
-\setkeys{tibetan}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{tibetan}{numerals=tibetan}
 
 % some are known, but very few
 % a few come from "Standardizing Tibetan Terms of Information Technology"

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkish.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkish.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkish.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-turkish.ldf}[polyglossia: module for turkish]
 \RequirePackage{hijrical}
 \PolyglossiaSetup{turkish}{
+  bcp47=tr,
   hyphennames={turkish},
   hyphenmins={2,2},
   langtag=TRK,
@@ -28,6 +29,9 @@
    \fi
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{turkish}{tr}
+
 \def\noturkish at punctuation{%
    \ifxetex
    \XeTeXcharclass `\! \z@

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkmen.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkmen.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-turkmen.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-turkmen.ldf}[polyglossia: module for turkmen]
 %% Translations provided by Nazar Annagurban <nazartm at gmail dot com>
 \PolyglossiaSetup{turkmen}{
+  bcp47=tk,
   hyphennames={turkmen},
   hyphenmins={2,2},
   langtag=TKM,
@@ -8,6 +9,9 @@
   fontsetup=true
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{turkmen}{tk}
+
 \def\captionsturkmen{%
   \def\prefacename{Sözbaşy}%
   \def\refname{Çeşmeler}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-ukrainian.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,7 +2,10 @@
 % Strings taken from Babel
 % and revised by Roman Kyrylych
 
-\PolyglossiaSetup{ukrainian}{
+\RequirePackage{xpg-cyrillicnumbers}
+
+\PolyglossiaSetup{ukrainian}{%
+  bcp47=uk,
   script=Cyrillic,
   scripttag=cyrl,
   langtag=UKR,
@@ -9,25 +12,47 @@
   hyphennames={ukrainian},
   hyphenmins={2,2},
   frenchspacing=true,
-  fontsetup=true
-  %TODO localalph
+  fontsetup=true,
+  localnumeral=ukrainiannumerals,
+  Localnumeral=Ukrainiannumerals
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{ukrainian}{uk}
+
 \newif\ifcyrillic at numerals
-\define at key{ukrainian}{numerals}[latin]{%
-\ifstrequal{#1}{cyrillic}%
-{\cyrillic at numeralstrue}
-{\cyrillic at numeralsfalse}%
-}
+\newif\ifcyrillic at asbuk@numerals
+\define at choicekey*+{ukrainian}{numerals}[\val\nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
+   \ifcase\nr\relax
+      % arabic:
+      \cyrillic at numeralsfalse%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-trad:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralsfalse%
+   \or
+      % cyrillic-alph:
+      \cyrillic at numeralstrue%
+      \cyrillic at asbuk@numeralstrue%
+   \fi
+   \xpg at info{Option: Ukrainian, numerals=\val}%
+}{\xpg at warning{Unknown Ukrainian numerals value `#1'}}
 
-\define at boolkey{ukrainian}[ukrainian@]{babelshorthands}[false]{}
 
-\setkeys{ukrainian}{numerals}
+% Register default options
+\xpg at initialize@gloss at options{ukrainian}{numerals=arabic}
 
+\define at boolkey{ukrainian}[ukrainian@]{babelshorthands}[true]{}
+
 \ifsystem at babelshorthands
-\setkeys{ukrainian}{babelshorthands=true}
+  \setkeys{ukrainian}{babelshorthands=true}
 \else
-\setkeys{ukrainian}{babelshorthands=false}
+  \setkeys{ukrainian}{babelshorthands=false}
 \fi
 
 \ifcsundef{initiate at active@char}{%
@@ -37,45 +62,47 @@
 }{}
 
 \def\ukrainian at shorthands{%
-\bbl at activate{"}%
-\def\language at group{ukrainian}%
+  \bbl at activate{"}%
+  \def\language at group{ukrainian}%
 %  \declare at shorthand{ukrainian}{"`}{„}%
 %  \declare at shorthand{ukrainian}{"'}{“}%
 %  \declare at shorthand{ukrainian}{"<}{«}%
 %  \declare at shorthand{ukrainian}{">}{»}%
-\declare at shorthand{ukrainian}{""}{\hskip\z at skip}%
-\declare at shorthand{ukrainian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
-\declare at shorthand{ukrainian}{"=}{\nobreak-\hskip\z at skip}%
-\declare at shorthand{ukrainian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
-\declare at shorthand{ukrainian}{"-}{%
-\def\ukrainian at sh@tmp{%
-\if\ukrainian at sh@next-\expandafter\ukrainian at sh@emdash
-\else\expandafter\ukrainian at sh@hyphen\fi
-}%
-\futurelet\ukrainian at sh@next\ukrainian at sh@tmp}%
-\def\ukrainian at sh@hyphen{%
-\nobreak\-\bbl at allowhyphens}%
-\def\ukrainian at sh@emdash##1##2{\cdash-##1##2}%
-\def\cdash##1##2##3{\def\tempx@{##3}%
-\def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
-\ifx\tempx@\tempa@\@Acdash\else
-\ifx\tempx@\tempb@\@Bcdash\else
-\ifx\tempx@\tempc@\@Ccdash\else
-\errmessage{Wrong usage of cdash}\fi\fi\fi}%
-\def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
-\cyrdash\hskip.2em\ignorespaces}%
-\def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
-\nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z at skip\ignorespaces}%
-\def\@Ccdash{\leavevmode
-\nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
-\ifx\cyrdash\undefined
-\def\cyrdash{\hbox to.8em{--\hss--}}
-\fi
-\declare at shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
+  \declare at shorthand{ukrainian}{""}{\hskip\z at skip}%
+  \declare at shorthand{ukrainian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
+  \declare at shorthand{ukrainian}{"=}{\nobreak-\hskip\z at skip}%
+  \declare at shorthand{ukrainian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
+  \declare at shorthand{ukrainian}{"-}{%
+  \def\ukrainian at sh@tmp{%
+    \if\ukrainian at sh@next-\expandafter\ukrainian at sh@emdash
+    \else\expandafter\ukrainian at sh@hyphen\fi
+  }%
+  \futurelet\ukrainian at sh@next\ukrainian at sh@tmp}%
+  \def\ukrainian at sh@hyphen{%
+  \nobreak\-\bbl at allowhyphens}%
+  \def\ukrainian at sh@emdash##1##2{\cdash-##1##2}%
+  \def\cdash##1##2##3{%
+    \def\tempx@{##3}%
+    \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
+    \ifx\tempx@\tempa@\@Acdash\else
+    \ifx\tempx@\tempb@\@Bcdash\else
+    \ifx\tempx@\tempc@\@Ccdash\else
+    \errmessage{Wrong usage of cdash}\fi\fi\fi%
+  }%
+  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
+  \cyrdash\hskip.2em\ignorespaces}%
+  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
+  \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z at skip\ignorespaces}%
+  \def\@Ccdash{\leavevmode
+  \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
+  \ifx\cyrdash\undefined
+    \def\cyrdash{\hbox to.8em{--\hss--}}
+  \fi
+  \declare at shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
 }
 
 \def\noukrainian at shorthands{%
-\@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
+  \@ifundefined{initiate at active@char}{}{\bbl at deactivate{"}}%
 }
 
 \def\captionsukrainian{%
@@ -102,7 +129,8 @@
    \def\headtoname{До}%
    \def\proofname{Доведення}%
    \def\glossaryname{Словник термінів}%
-   }
+}
+
 \def\dateukrainian{%
    \def\today{\number\day~\ifcase\month\or
     січня\or
@@ -117,39 +145,82 @@
     жовтня\or
     листопада\or
     грудня\fi%
-    \space\number\year~р.}}
+    \space\number\year~р.}%
+}
 
 % The following is based on some ideas from ruscor.sty
 \def\ukrainian at capsformat{%
-\def\@seccntformat##1{\csname pre##1\endcsname%
-\csname the##1\endcsname%
-\csname post##1\endcsname}%
-\def\@aftersepkern{\hspace{0.5em}}%
-\def\postchapter{.\@aftersepkern}%
-\def\postsection{.\@aftersepkern}%
-\def\postsubsection{.\@aftersepkern}%
-\def\postsubsubsection{.\@aftersepkern}%
-\def\postparagraph{.\@aftersepkern}%
-\def\postsubparagraph{.\@aftersepkern}%
-\def\prechapter{}%
-\def\presection{}%
-\def\presubsection{}%
-\def\presubsubsection{}%
-\def\preparagraph{}%
-\def\presubparagraph{}}
+  \def\@seccntformat##1{\csname pre##1\endcsname%
+  \csname the##1\endcsname%
+  \csname post##1\endcsname}%
+  \def\@aftersepkern{\hspace{0.5em}}%
+  \def\postchapter{.\@aftersepkern}%
+  \def\postsection{.\@aftersepkern}%
+  \def\postsubsection{.\@aftersepkern}%
+  \def\postsubsubsection{.\@aftersepkern}%
+  \def\postparagraph{.\@aftersepkern}%
+  \def\postsubparagraph{.\@aftersepkern}%
+  \def\prechapter{}%
+  \def\presection{}%
+  \def\presubsection{}%
+  \def\presubsubsection{}%
+  \def\preparagraph{}%
+  \def\presubparagraph{}%
+}
 
-\def\Asbuk#1{\expandafter\ukrainian at Alph\csname c@#1\endcsname}
-\def\ukrainian at Alph#1{\ifcase#1\or
-   А\or Б\or В\or Г\or Д\or Е\or Є\or Ж\or
-   З\or И\or І\or Ї\or Й\or К\or Л\or М\or Н\or О\or
+\newcommand{\ukrainiannumerals}[2]{\ukrainiannumber{#2}}
+\newcommand{\Ukrainiannumerals}[2]{\Ukrainiannumber{#2}}
+
+\def\ukrainiannumber#1{%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@alph{#1}%
+    \else
+      \cyr at alph{#1}%
+    \fi
+  \else
+    \number#1%
+  \fi%
+}
+
+\def\Ukrainiannumber#1{%
+  \ifcyrillic at numerals
+    \ifcyrillic at asbuk@numerals
+      \serbian at asbuk@Alph{#1}%
+    \else
+      \cyr at Alph{#1}%
+    \fi
+  \else
+    \number#1%
+  \fi%
+}
+
+\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\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.
+\def\ukranian 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 Я\else\xpg at ill@value{#1}{ukrainian at Alph}\fi}
-\def\asbuk#1{\expandafter\ukrainian at alph\csname c@#1\endcsname}
-\def\ukrainian at 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 Я%
+   \else\xpg at ill@value{#1}{ukranian at asbuk@Alph}\fi%
+}
+
+\def\ukranian 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 я\else\xpg at ill@value{#1}{ukrainian at alph}\fi}
+   ц\or ч\or ш\or щ\or э\or ю\or я%
+   \else\xpg at ill@value{#1}{ukranian at asbuk@alph}\fi%
+}
 
 \def\ukrainian at numbers{%
    \let\@Alph\ukrainian at Alph%
@@ -162,19 +233,19 @@
 }
 
 \def\noextras at ukrainian{%
-\def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
-\ifcyrillic at numerals\noukrainian at numbers\fi
-\noukrainian at shorthands%
+  \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
+  \ifcyrillic at numerals\noukrainian at numbers\fi
+  \noukrainian at shorthands%
 }
 
 \def\blockextras at ukrainian{%
-\ukrainian at capsformat%
-\ifcyrillic at numerals\ukrainian at numbers\fi
-\ifukrainian at babelshorthands\ukrainian at shorthands\fi
+  \ukrainian at capsformat%
+  \ifcyrillic at numerals\ukrainian at numbers\fi
+  \ifukrainian at babelshorthands\ukrainian at shorthands\fi
 }
 
 \def\inlineextras at ukrainian{%
-\ifukrainian at babelshorthands\ukrainian at shorthands\fi%
+  \ifukrainian at babelshorthands\ukrainian at shorthands\fi%
 }
 
 %%% stuff from Babel

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-urdu.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-urdu.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-urdu.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -11,6 +11,7 @@
 \RequirePackage{hijrical}
 
 \PolyglossiaSetup{urdu}{
+  bcp47=ur,
   script=Arabic,
   direction=RL,
   scripttag=arab,
@@ -21,6 +22,9 @@
   %TODO localalph={abjad,abjad}
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{urdu}{ur}
+
 \newif\if at western@numerals
 \def\tmp at western{western}
 \define at key{urdu}{numerals}[eastern]{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-vietnamese.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-vietnamese.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-vietnamese.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -2,6 +2,7 @@
 %% Strings contributed by Daniel Owens < dhowens . pmbx . net >
 
 \PolyglossiaSetup{vietnamese}{
+  bcp47=vi,
   hyphennames={nohyphenation},
   hyphenmins={2,2},
   langtag=VIT,
@@ -9,6 +10,9 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{vietnamese}{vi}
+
 \def\captionsvietnamese{%
   \def\refname{Tài liệu}%
   \def\abstractname{Tóm tắt nội dung}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-welsh.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-welsh.ldf	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/gloss-welsh.ldf	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,7 @@
 \ProvidesFile{gloss-welsh.ldf}[polyglossia: module for welsh]
 
 \PolyglossiaSetup{welsh}{
+  bcp47=cy,
   hyphennames={welsh},
   hyphenmins={2,3},
   langtag=WEL,
@@ -7,15 +8,25 @@
   fontsetup=true,
 }
 
+% BCP-47 compliant aliases
+\setlanguagealias*{welsh}{cy}
+
 \providebool{welsh at formaldate}
 
-% TODO (maybe) Interface to change that mid-document
-\define at key{welsh}{date}{%
-  \ifstrequal{#1}{long}{%
-    \welsh at formaldatetrue
-  }% Anything else gives \welsh at formaldatefalse
-}
+\define at choicekey*+{welsh}{date}[\val\nr]{long,short}[short]{%
+   \ifcase\nr\relax
+      % long:
+      \welsh at formaldatetrue
+   \or
+      % accented:
+      \welsh at formaldatefalse
+   \fi
+   \xpg at info{Option: Welsh, date=\val}%
+}{\xpg at warning{Unknown date value `#1'}}
 
+% Register default options
+\xpg at initialize@gloss at options{welsh}{date=short}
+
 \def\captionswelsh{%
   \def\refname{Cyfeiriadau}%
   \def\abstractname{Crynodeb}%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/hebrewcal.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/hebrewcal.sty	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/hebrewcal.sty	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,5 +1,5 @@
 \ProvidesPackage{hebrewcal}
-        [2015/04/17 v2.6 %
+        [2019/12/03 v2.7 %
          Hebrew calendar for polyglossia (adapted from hebcal.sty in Babel)]
 \RequirePackage{xkeyval}
 \ifluatex\RequirePackage{luabidi}\else\RequirePackage{bidi}\fi
@@ -20,8 +20,8 @@
 
 \@ifundefined{@Remainder}{\input{cal-util.def}}{}
 
-\define at boolkey{hebrew}[@hebrew@]{fullyear}[false]{}
-\setkeys{hebrew}{fullyear}
+\define at boolkey{hebrew}[@hebrew@]{fullyear}[true]{}
+\setkeys{hebrew}{fullyear=false}
 
 \newcount\hebrewday  \newcount\hebrewmonth \newcount\hebrewyear
 \def\hebrewdate#1#2#3{%

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-french.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-french.lua	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-french.lua	2020-01-29 22:37:53 UTC (rev 53592)
@@ -35,6 +35,7 @@
     set_left_space(lang, '⁇', 0.5)
     set_left_space(lang, '⁈', 0.5)
     set_left_space(lang, '⁉', 0.5)
+    set_left_space(lang, '‽', 0.5) -- U+203D (interrobang)
 
     if autospaceguillemets then
         set_left_space(lang, '»', 0.5)

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-korean.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-korean.lua	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-korean.lua	2020-01-29 22:37:53 UTC (rev 53592)
@@ -420,14 +420,19 @@
     local curr, tone = node.slide(head)
     while curr do
         if curr.id == glyph_id and node.has_attribute(curr, attr_korean) then
-            local c, wd = curr.char or 0, curr.width or 0
-            if (c == 0x302E or c == 0x302F) and wd > 0 then
-                tone = curr
-            elseif tone and not nobr_before[c] then
-                head = node.remove(head, tone)
-                tone.next, tone.prev = nil, nil
-                head, curr = node.insert_before(head, curr, tone)
+            local f = font.getfont(curr.font) or font.fonts[curr.font]
+            if f and f.hb then -- harfbuzz do the right thing
                 tone = nil
+            else
+                local c, wd = curr.char or 0, curr.width or 0
+                if (c == 0x302E or c == 0x302F) and wd > 0 then
+                    tone = curr
+                elseif tone and not nobr_before[c] then
+                    head = node.remove(head, tone)
+                    tone.next, tone.prev = nil, nil
+                    head, curr = node.insert_before(head, curr, tone)
+                    tone = nil
+                end
             end
         end
         curr = curr.prev

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-latin.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-latin.lua	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-latin.lua	2020-01-29 22:37:53 UTC (rev 53592)
@@ -6,21 +6,31 @@
 -- between 1/4 and 1/3 of a quad. We choose a half of a \thinspace here.
 local hairspace = 0.08333 -- 1/12
 
+local function space_left(char)
+    polyglossia.add_left_spaced_character('latin', char, hairspace, 'quad')
+end
+
+local function space_right(char)
+    polyglossia.add_right_spaced_character('latin', char, hairspace, 'quad')
+end
+
+polyglossia.clear_spaced_characters('latin')
+space_left('!')
+space_left('?')
+space_left('‼')
+space_left('⁇')
+space_left('⁈')
+space_left('⁉')
+space_left('‽') -- U+203D (interrobang)
+space_left(':')
+space_left(';')
+space_left('»')
+space_left('›')
+space_right('«')
+space_right('‹')
+
 local function activate_latin_punct()
     polyglossia.activate_punct('latin')
-    polyglossia.clear_spaced_characters('latin')
-    polyglossia.add_left_spaced_character('latin',':',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','!',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','?',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin',';',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','‼',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁇',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁈',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','⁉',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','»',hairspace,'quad')
-    polyglossia.add_left_spaced_character('latin','›',hairspace,'quad')
-    polyglossia.add_right_spaced_character('latin','«',hairspace,'quad')
-    polyglossia.add_right_spaced_character('latin','‹',hairspace,'quad')
 end
 
 local function deactivate_latin_punct()

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-punct.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-punct.lua	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-punct.lua	2020-01-29 22:37:53 UTC (rev 53592)
@@ -61,13 +61,55 @@
     return node_copy(penalty_node)
 end
 
--- we have here all possible space characters, referenced by their unicode slot
--- number, taken from char-def.lua
-local space_chars = {[32] = true, [160] = true, [5760] = true, [6158] = true,
-    [8192] = true, [8193] = true, [8194] = true, [8195] = true, [8196] = true,
-    [8197] = true, [8198] = true, [8199] = true, [8200] = true, [8201] = true,
-    [8202] = true, [8239] = true, [8287] = true, [12288] = true}
+-- all possible space characters according to section 6.2 of the Unicode Standard
+-- https://www.unicode.org/versions/Unicode12.0.0/ch06.pdf
+local space_chars = {
+    [0x20] = true, -- space
+    [0xA0] = true, -- no-break space
+    [0x1680] = true, -- ogham space mark
+    [0x2000] = true, -- en quad
+    [0x2001] = true, -- em quad
+    [0x2002] = true, -- en space
+    [0x2003] = true, -- em space
+    [0x2004] = true, -- three-per-em-space
+    [0x2005] = true, -- four-per-em space
+    [0x2006] = true, -- six-per-em space
+    [0x2007] = true, -- figure space
+    [0x2008] = true, -- punctuation space
+    [0x2009] = true, -- thin space
+    [0x200A] = true, -- hair space
+    [0x202F] = true, -- narrow no-break space
+    [0x205F] = true, -- medium mathematical space
+    [0x3000] = true -- ideographic space
+}
 
+-- all left bracket characters, referenced by their Unicode slot
+local left_bracket_chars = {
+    [0x28] = true, -- left parenthesis
+    [0x5B] = true, -- left square bracket
+    [0x7B] = true, -- left curly bracket
+    [0x27E8] = true -- mathematical left angle bracket
+}
+
+-- all right bracket characters, referenced by their Unicode slot
+local right_bracket_chars = {
+    [0x29] = true, -- right parenthesis
+    [0x5D] = true, -- right square bracket
+    [0x7D] = true, -- right curly bracket
+    [0x27E9] = true -- mathematical right angle bracket
+}
+
+-- question and exclamation marks, referenced by their Unicode slot
+local question_exclamation_chars = {
+    [0x21] = true, -- exclamation mark !
+    [0x3F] = true, -- question mark ?
+    [0x203C] = true, -- double exclamation mark ‼
+    [0x203D] = true, -- interrobang ‽
+    [0x2047] = true, -- double question mark ⁇
+    [0x2048] = true, -- question exclamation mark ⁈
+    [0x2049] = true, -- exclamation question mark ⁉
+}
+
 -- from nodes-tst.lua, adapted
 local function somespace(n)
     if n then
@@ -84,9 +126,6 @@
     end
 end
 
--- we have here all left bracket characters, referenced by their unicode slot
-local left_bracket_chars = {[40] = true, [123] = true, [91] = true, [10216] = true}
-
 local function someleftbracket(n)
     if n then
         local id = n.id
@@ -96,9 +135,6 @@
     end
 end
 
--- we have here all right bracket characters, referenced by their unicode slot
-local right_bracket_chars = {[41] = true, [125] = true, [93] = true, [10217] = true}
-
 local function somerightbracket(n)
     if n then
         local id = n.id
@@ -108,6 +144,16 @@
     end
 end
 
+local function question_exclamation_sequence(n1, n2)
+    if n1 and n2 then
+        local id1 = n1.id
+        local id2 = n2.id
+        if id1 == glyph_code and id2 == glyph_code then
+            return question_exclamation_chars[n1.char] and question_exclamation_chars[n2.char]
+        end
+    end
+end
+
 -- idem
 local function somepenalty(n, value)
     if n then
@@ -193,13 +239,13 @@
                 if leftspace or rightspace then
                     local fontparameters = fonts.hashes.parameters[current.font]
                     local unit, stretch, shrink, spacing_node
-                    if leftspace then
+                    if leftspace and fontparameters then
                         local prev = getprev(current)
                         local space_exception = false
                         if prev then
                             local prevprev = getprev(prev)
-                            -- do not add space after left (opening) bracket
-                            space_exception = someleftbracket(prev)
+                            -- do not add space after left (opening) bracket and between question/exclamation marks
+                            space_exception = someleftbracket(prev) or question_exclamation_sequence(prev, current)
                             if somespace(prev) then
                             -- TODO: there is a question here: do we override a preceding space or not?...
                                 if somepenalty(prevprev, 10000) then
@@ -226,7 +272,7 @@
                             head = insert_node_before(head, current, spacing_node)
                         end
                     end
-                    if rightspace then
+                    if rightspace and fontparameters then
                         local next = getnext(current)
                         local space_exception = false
                         if next then

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-sanskrit.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-sanskrit.lua	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia-sanskrit.lua	2020-01-29 22:37:53 UTC (rev 53592)
@@ -7,19 +7,25 @@
 -- value.
 local thinspace = 0.16667 -- 1/6
 
+local function space_left(char)
+    polyglossia.add_left_spaced_character('sanskrit', char, thinspace, 'quad')
+end
+
+polyglossia.clear_spaced_characters('sanskrit')
+space_left('!')
+space_left('?')
+space_left('‼')
+space_left('⁇')
+space_left('⁈')
+space_left('⁉')
+space_left('‽') -- U+203D (interrobang)
+space_left(':')
+space_left(';')
+space_left('।') -- danda, U+0964
+space_left('॥') -- double danda, U+0965
+
 local function activate_sanskrit_punct()
     polyglossia.activate_punct('sanskrit')
-    polyglossia.clear_spaced_characters('sanskrit')
-    polyglossia.add_left_spaced_character('sanskrit','!',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','?',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','‼',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁇',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁈',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','⁉',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit',':',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit',';',thinspace,'quad')
-    polyglossia.add_left_spaced_character('sanskrit','।',thinspace,'quad') -- danda, U+0964
-    polyglossia.add_left_spaced_character('sanskrit','॥',thinspace,'quad') -- double danda, U+0965
 end
 
 local function deactivate_sanskrit_punct()

Modified: trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty	2020-01-29 22:37:04 UTC (rev 53591)
+++ trunk/Master/texmf-dist/tex/latex/polyglossia/polyglossia.sty	2020-01-29 22:37:53 UTC (rev 53592)
@@ -1,6 +1,6 @@
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{polyglossia}[2019/11/15 v1.46
-  Alternative to Babel for XeLaTeX and LuaLaTeX]
+\ProvidesPackage{polyglossia}[2020/01/29 v1.47
+  Modern multilingual typesetting with XeLaTeX and LuaLaTeX]
 \RequirePackage{etoolbox}
 \RequirePackage{makecmds}
 \RequirePackage{xkeyval}[2008/08/13]
@@ -46,6 +46,7 @@
 \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)
 
 % counter in latin
 \def\latinalph#1{\expandafter\latin at alph\csname c@#1\endcsname}
@@ -68,14 +69,20 @@
   \xpg at initial@setup
   % apply \familydefault changes
   \xpg at set@familydefault
+}
+
+\AtBeginDocument{
+  \polyglossia at AtBeginDocument:
+}
+
+% The following needs to go after any \AtBeginDocument (also of packages
+% loaded after \set[main|other]language
+\AfterEndPreamble{
   % now we have the C locale definition: select the language
   \polyglossia at AtBeginDocument@selectlanguage:
   % If hyphenation disabling has been requested in preamble, do it now
   \polyglossia at AtBeginDocument@hyphenation:
 }
-\AtBeginDocument{
-  \polyglossia at AtBeginDocument:
-}
 
 %% custom message macros
 \providecommand*{\xpg at error}[1]{%
@@ -346,7 +353,7 @@
        .code:n = {
           \prop_gput:Nnn{\polyglossia at langsetup}{#1/script}{##1}
           \prop_gput:Nnx{\polyglossia at langsetup}{#1/lcscript}
-               {\tl_if_empty:nF{##1}{\str_lower_case:n##1}}
+               {\tl_if_empty:nF{##1}{\str_lowercase:n##1}}
     },
     #1 / script
        .value_required:n = true,
@@ -373,6 +380,13 @@
        .value_required:n = true,
     #1 / langtag
        .initial:n = {},
+    % the BCP-47 tag
+    #1 / bcp47
+       .code:n = {\prop_gput:Nnn{\polyglossia at langsetup}{#1/bcp47}{##1}},
+    #1 / bcp47
+       .value_required:n = true,
+    #1 / bcp47
+       .initial:n = {},
     % hyphennames
     #1 / hyphennames
     .code:n = {
@@ -410,6 +424,17 @@
       .value_required:n = true,
     #1 / hyphenmins
      .initial:n = {2,3},
+    % minimal length for hyphenation (LuaTeX only)
+    #1 / totalhyphenmin
+    .code:n = {
+      % check syntax
+      \int_compare:nNnF { \clist_count:n {##1} } = {1}
+        {\xpg at error{totalhyphenhypenmin~should~be~a~single~entry,~got~"##1"}}
+      % set prop
+      \prop_gput:Nnn \polyglossia at langsetup {#1/totalhyphenmin} {##1}
+    },
+    #1 / totalhyphenmin
+      .value_required:n = false,
     % frenchspacing
     #1 / frenchspacing
     .code:n = {
@@ -828,7 +853,7 @@
        {\addfontfeature{Script=#2}}
        {\xpg at error{
           The~ current~ latin ~ font~ \l_fontspec_family_tl\space does~ not~ contain~ the~"#2"~ script!\MessageBreak
-          Please~ define~\csname\tl_if_empty:nF{#2}{\str_lower_case:n#2}font\endcsname~
+          Please~ define~\csname\tl_if_empty:nF{#2}{\str_lowercase:n#2}font\endcsname~
           with~ \string\newfontfamily\space command
           }
         }
@@ -1013,6 +1038,10 @@
 % 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}%
+   }{}
    \csgdef{#1 at loaded}{}
    \global\edef\xpg at loaded{#1\ifx\xpg at loaded\@empty\else,\xpg at loaded\fi}%
 }
@@ -1040,40 +1069,36 @@
 % \setlanguagealias[<options>]{<language>}{<alias>}
 \DeclareDocumentCommand \setlanguagealias {s O{} m m}
 {
-  \ifcsundef{#4 at alias@lang}{%
-    \exp_args:Ne
-    \newenvironment {#4}
+  % The starred version does not define commands and environments
+  \IfBooleanF {#1}
     {
-      \begin{otherlanguage}[#2]{#3}
-    }%
-    {
-      \end{otherlanguage}
-    }%
-    % The starred version does not define \text<alias>
-    \IfBooleanF {#1}
-      {
-        \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}
-    }%
-    % The starred version does not (re)define \text<alias>
-    \IfBooleanF {#1}
-      {
-        \exp_args:Nc \renewcommand {text#4} [2][]
-        {%
-          \xpg at textlanguage[#2,##1]{#3}{##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}%
+       }%
+     }%
   }%
   \csgdef{#4 at alias@lang}{#3}%
   \tl_if_blank:nF {#2} {\csgdef{#4 at alias@opts}{#2}}%
@@ -1087,6 +1112,8 @@
       \global\edef\xpg at loaded{#2\ifx\xpg at loaded\@empty\else,\xpg at loaded\fi}%
       \global\edef\xpg at bloaded{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}%
           \ifx\xpg at bloaded\@empty\else,\xpg at bloaded\fi}%
+      \global\edef\xpg at bcp@loaded{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}%
+          \ifx\xpg at bcp@loaded\@empty\else,\xpg at bcp@loaded\fi}%
     }%
     \polyglossia_load_lang_definition:nn{#1}{#2}
     % define environment and command (except for internal latex language)
@@ -1119,16 +1146,15 @@
       \global\edef\xpg at loaded{#2\ifx\xpg at loaded\@empty\else,\xpg at loaded\fi}%
       \global\edef\xpg at bloaded{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}%
           \ifx\xpg at bloaded\@empty\else,\xpg at bloaded\fi}%
+      \global\edef\xpg at bcp@loaded{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}%
+          \ifx\xpg at bcp@loaded\@empty\else,\xpg at bcp@loaded\fi}%
     }%
     \csgdef{#2 at loaded}{}%
   }{}
   \gdef\xpg at main@language{#2}%
   \tl_if_blank:nTF {#1}{\gdef\mainlanguagevariant{}}{%
-     % If the optional argument sets a value for the key “variant”,
-     % store it in \xpg at main@langvariant
-     \clist_map_inline:nn { #1 } {%
-         \xpg at parsevariantkeyvalue##1=@xpg at main@langvariant\relax
-     }%
+     % Register the language options
+     \polyglossia at set@lang at options:nn {#2} {#1}%
   }%
   \csgdef{#2 at gvar}{\mainlanguagevariant}%
   %% The following settings are for the default language and script
@@ -1152,8 +1178,16 @@
   % 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}% 
-        \csgdef{#2 at gbabelname}{\babelname}%
+        \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 %
@@ -1161,6 +1195,36 @@
 
 \let\setmainlanguage=\setdefaultlanguage
 
+% Returns the language ID of the current language
+% Currently supported: bcp-47
+\DeclareDocumentCommand \languageid {m}
+{
+    \str_case:nnTF {#1}
+      {
+        {bcp-47}    { \csuse{bcp47id} }
+        {bcp47}     { \csuse{bcp47id} }
+      }
+      {}
+      {
+        \xpg at error{Invalid~ \string\languageid\space argument:~ #1}
+      }
+}
+
+% Returns the language ID of the main language
+% Currently supported: bcp-47
+\DeclareDocumentCommand \mainlanguageid {m}
+{
+    \str_case:nnTF {#1}
+      {
+        {bcp-47}    { \csuse{mainbcp47id} }
+        {bcp47}     { \csuse{mainbcp47id} }
+      }
+      {}
+      {
+        \xpg at error{Invalid~ \string\mainlanguageid\space argument:~ #1}
+      }
+}
+
 \def\mainbabelname{}%
 \def\mainlanguagevariant{}%
 % Store main language variant for external packages
@@ -1180,16 +1244,26 @@
   \tl_if_blank:nTF {#1}{%
      \ifcsundef{#2 at gvar}{\def\languagevariant{}}{\def\languagevariant{\csuse{#2 at gvar}}}
    }{%
-     % If the argument sets a value for the key “variant”,
-     % store it in \xpg at set@langvariant
-     \clist_map_inline:nn { #1 } {%
-         \xpg at parsevariantkeyvalue##1=@xpg at set@langvariant\relax
+     % Register the language options
+     \polyglossia at set@lang at options:nn {#2} {#1}%
+  }%
+}
+
+
+\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}%
   }%
 }
 
-
-\newcommand{\resetdefaultlanguage}[2][]{%
+\cs_new:Nn \polyglossia at reset@default at language:nn
+{
   \polyglossia at error@iflangnotloaded:n{#2}
   % disable globalnumbers of previously defined default language
   \csuse{no\xpg at main@language @globalnumbers}
@@ -1212,6 +1286,16 @@
   }{%
     \edef\babelname{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}}%
   }%
+  % Store BCP-47 id of current language
+  \tl_if_blank:nTF {#1}{%
+    \ifcsundef{#2 at gbcp47id}{%
+       \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+    }{%
+       \csedef{bcp47id}{\csuse{#2 at gbcp47id}}%
+    }%
+  }{%
+    \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+  }%
 }
 
 % This saves the normalfont for the latin script since we may change normalfont in other scripts
@@ -1235,6 +1319,14 @@
    \selectfont%
 }
 
+\def\xpg at patch@fontfamilies{%
+  % This robustifies the redefinitions of \<xx>family (suggestion by Enrico Gregorio)
+  % e.g. to prevent expansion of the \familytype redefinition in auxiliary files
+  \csgappto{rmfamily~}{\def\familytype{rm}}
+  \csgappto{sffamily~}{\def\familytype{sf}}
+  \csgappto{ttfamily~}{\def\familytype{tt}}
+}
+
 % These switches activate the default fonts
 % Note that a simple \let\rmfamilylatin=\rmfamily
 % does not work reliably (see #24)
@@ -1254,11 +1346,7 @@
       \ifcsequal{tempa}{tempb}%
          {\def\familytype{tt}}
          {\def\familytype{rm}}}
-  % This robustifies the redefinitions of \<xx>family (suggestion by Enrico Gregorio)
-  % e.g. to prevent expansion of the \familytype redefinition in auxiliary files
-  \csgappto{rmfamily~}{\def\familytype{rm}}
-  \csgappto{sffamily~}{\def\familytype{sf}}
-  \csgappto{ttfamily~}{\def\familytype{tt}}
+  \xpg at patch@fontfamilies%
   % This (re-)saves the normalfont for the latin script since we may
   % change normalfont in other scripts
   \let\normalfontlatin=\normalfont%
@@ -1269,10 +1357,12 @@
 }
 
 \def\resetfontlatin{%
-   \cs_gset_eq:cc{rmfamily}{xpg at defaultfont@rm}%
-   \cs_gset_eq:cc{sffamily}{xpg at defaultfont@sf}%
-   \cs_gset_eq:cc{ttfamily}{xpg at defaultfont@tt}%
-   \global\let\normalfont=\normalfontlatin}
+  \DeclareRobustCommand\rmfamily{\xpg at defaultfont@rm}%
+  \DeclareRobustCommand\sffamily{\xpg at defaultfont@sf}%
+  \DeclareRobustCommand\ttfamily{\xpg at defaultfont@tt}%
+  \xpg at patch@fontfamilies%
+  \global\let\normalfont=\normalfontlatin%
+}
 
 \def\selectfontfamilylatin{%
   \def\tmp at tt{tt}\def\tmp at sf{sf}%
@@ -1301,12 +1391,28 @@
 }
 
 \let\@@fterindentfalse\@afterindentfalse
-\def\french at indent{\let\@afterindentfalse\@afterindenttrue
-                        \@afterindenttrue}
-\def\nofrench at indent{\let\@afterindentfalse\@@fterindentfalse
-                          \@afterindentfalse}
-\newcommand{\selectbackgroundlanguage}[1]{%
-  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/lcscript}}{latin}{}{\xpg at set@normalfont{#1}}%
+\def\french at indent{%
+    \let\@afterindentfalse\@afterindenttrue
+    \@afterindenttrue%
+}
+\def\nofrench at indent{%
+    \let\@afterindentfalse\@@fterindentfalse
+    \@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:Nn \polyglossia at select@background at language:n
+{
+  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{#1/lcscript}}{latin}
+                   {}
+                   {\xpg at set@normalfont{#1}}%
   \csuse{#1 at globalnumbers}%
 }
 
@@ -1342,16 +1448,13 @@
   % If a variant is set, store it.
   \gdef\otherlanguagevariant{}
   \tl_if_blank:nTF {#1}{}{%
-    % If the optional argument sets a value for the key “variant”,
-    % store it in \xpg at other@langvariant
-    \clist_map_inline:nn { #1 } {%
-       \xpg at parsevariantkeyvalue##1=@xpg at other@langvariant\relax
-    }%
+    % Register the language options
+    \polyglossia at set@lang at options:nn {#2} {#1}%
   }%
   \csgdef{#2 at gvar}{\otherlanguagevariant}%
   \prop_get:NxNT \polyglossia at langsetup {#2/babelname} \l_tmpa_tl
     { \xdef\otherlanguagebabelname{\l_tmpa_tl} }
-  \csgdef{#2 at gbabelname}{\otherlanguagebabelname}%
+  \cs_gset_eq:cc{#2 at gbabelname}{otherlanguagebabelname}%
 }
 
 % Store main language variant for external packages
@@ -1384,7 +1487,7 @@
 \newcommand\textlang[3][]{%
   \ifcsdef{#2 at alias@lang}{%
      \ifcsdef{#2 at alias@opts}{%
-       \xpg at textlanguage[\csuse{#2 at alias@opts},#1]{\csuse{#2 at alias@lang}}{#3}%
+       \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}%
      }%
@@ -1393,6 +1496,16 @@
   }%
 }%
 
+% Alias to {<lang>}, but more suitable
+% for specific (esp. tag-based) aliases
+% where {<alias>} would cause clashes
+% (e.g., \fi)
+\newenvironment{lang}[2][]{%
+  \begin{otherlanguage}[#1]{#2}%
+}{%
+  \end{otherlanguage}
+}%
+
 \providecommand{\foreignlanguage}{}
 
 % wrapper for foreignlanguage and otherlanguage*
@@ -1408,6 +1521,16 @@
   }{%
     \edef\babelname{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}}%
   }%
+  % Store BCP-47 id of current language
+  \tl_if_blank:nTF {#1}{%
+    \ifcsundef{#2 at gbcp47id}{%
+       \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+    }{%
+       \csedef{bcp47id}{\csuse{#2 at gbcp47id}}%
+    }%
+  }{%
+    \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+  }%
 }
 
 % joint code of \foreignlanguage, otherlanguage*
@@ -1428,7 +1551,7 @@
 {%
   \ifcsdef{#2 at alias@lang}{%
      \ifcsdef{#2 at alias@opts}{%
-       \polyglossia at foreignlanguage:nnn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}} {#3}%
+       \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}%
      }%
@@ -1453,7 +1576,7 @@
 {%
   \ifcsdef{#2 at alias@lang}{%
      \ifcsdef{#2 at alias@opts}{%
-       \polyglossia at otherlanguage:nn {\csuse{#2 at alias@opts},#1} {\csuse{#2 at alias@lang}}%
+       \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}}%
      }%
@@ -1471,7 +1594,7 @@
 
 % use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
 % except that dates are localized.
-\newcommand*\xpg at textlanguage[3][]{%
+\newcommand\xpg at textlanguage[3][]{%
   \polyglossia at error@iflangnotloaded:n{#2}
    \bgroup
    \xpg at otherlanguage[#1]{#2}%
@@ -1510,7 +1633,7 @@
 {%
   \ifcsdef{#3 at alias@lang}{%
      \ifcsdef{#3 at alias@opts}{%
-       \polyglossia at select@language:nnn {#1} {\csuse{#3 at alias@opts},#2} {\csuse{#3 at alias@lang}}%
+       \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}}%
      }%
@@ -1528,11 +1651,8 @@
       \group_insert_after:N \xpg at pop@language
     }
   \tl_if_blank:nTF {#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\relax
-     }%
-     \exp_args:Nne \setkeys{#3}{#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{%
@@ -1554,14 +1674,100 @@
   }{}
 }
 
-% Helper to get and register "variant" keyval
-\def\xpg at parsevariantkeyvalue#1=#2@#3\relax{%
+
+\cs_new:Nn \polyglossia at set@lang at options:nn
+{  
+    % 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
+    }%
+    \exp_args:Nne \setkeys{#1}{#2}%
+}
+
+% Initialize default language options, so that
+% \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}%
+}
+
+% Record synonymous keyvals such as variant=us and variant=american
+% Syntax: \xpg at set@alias at values{<lang>}{<key>}{<val>}{<alias vals, comma-separated>}
+\newcommand*\xpg at set@alias at values[4]{%
+   \prop_if_exist:cF { xpg at alias@keyvals@#1@#3 }
+      { \prop_new:c {xpg at alias@keyvals@#1@#3} }
+   \prop_put:cnn { xpg at alias@keyvals@#1@#3 }
+      {#2}{#4}
+   \prop_put:cnn { xpg at alias@keyvals@#1@#4 }
+      {#2}{#3}
+}
+
+% Patch xkeyval to record default values of keys
+\pretocmd{\XKV at define@default}{%
+   \csgdef{xpg at default@opt@\XKV at header #1}{#2}%
+}{}{\xpg at warning{Patching xkeyval failed!}}
+
+% Helper to get and register option keyvals
+\def\xpg at parsevariantkeyvalue#1=#2@#3:#4\relax{%
    \def\@tmpa{#1}
    \def\@tmpb{variant}
+   % variant values are stored in specific macros
+   % (\xpg at main@langvariant, \xpg at other@langvariant
+   % and \xpg at set@langvariant)
    \ifx\@tmpa\@tmpb\setkeys{#3}{#1=#2}\fi
+   \tl_if_empty:nTF{#2}
+      {
+        \ifcsdef{xpg at default@opt at KV@#4@#1}%
+           {\xpg at store@opt at keyval#1:\csuse{xpg at default@opt at KV@#4@#1}=:#4\relax}%
+           {}%
+      }
+      { \xpg at store@opt at keyval#1:#2:#4\relax }
 }%
 
+% Store option keys and values
+% This strips trailing '=' from values.
+\def\xpg at store@opt at keyval#1:#2=:#3\relax{%
+   \prop_if_exist:cF { xpg at current@options@#3 }
+      { \prop_new:c {xpg at current@options@#3} }
+   \prop_put:cnn { xpg at current@options@#3 }
+      {#1}{#2}
+}
 
+
+\prg_set_conditional:Npnn \polyglossia at check@option at value:NNN #1#2#3 { p , T , F , TF }
+{
+  \prop_get:cnNTF {xpg at current@options@#1} {#2} \l_tmpa_tl
+     {
+        \exp_args:Nee \str_if_eq:NNTF{\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}
+                \providetoggle{xpgvalfound}
+                \togglefalse{xpgvalfound}
+                \clist_map_inline:Nn \l_tmpa_clist {
+                   \exp_args:Nee \str_if_eq:NNT{##1}{\l_tmpa_tl}
+                      { \toggletrue{xpgvalfound} }
+                }
+                \iftoggle{xpgvalfound}{\prg_return_true:}{\prg_return_false:}
+              }
+              {
+                \prg_return_false:
+              }
+         }
+     }
+     {
+       \prg_return_false:
+     }
+}
+
+% Test if option value is set
+\newcommand*\iflanguageoption[5]{%
+  \polyglossia at check@option at value:NNNTF{#1}{#2}{#3}{#4}{#5}%
+}
+
+
 % 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}%
@@ -1585,6 +1791,51 @@
   \polyglossia at check@if at lang@loaded:NTF{#1 at bbl@loaded}{#2}{#3}%
 }
 
+% Same for languageid
+\DeclareDocumentCommand \iflanguageidloaded {mmmm}
+{
+    \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} }
+      }
+      {}
+      {
+        \xpg at error{Invalid~ \string\iflanguageidloaded\space argument:~ #1}
+      }
+}
+
+% Check if the current font has a given glyph
+\prg_set_conditional:Npnn \polyglossia at check@if at char@available:N #1 { p , T , F , TF }
+{
+  \str_case_e:nnF{\c_sys_engine_str}{
+    {luatex}{
+             \int_compare:nNnTF { \directlua{polyglossia.check_char(0x#1)} } > { 0 }
+                {\prg_return_true:}
+                {\prg_return_false:}
+            }
+    {xetex}{
+             \int_compare:nNnTF { \the\XeTeXcharglyph"#1 } > { 0 }
+                {\prg_return_true:}
+                {\prg_return_false:}
+           }
+  }
+  {
+    \xpg at warning{You’re running a TeX engine that is not LuaTeX or XeTeX.\MessageBreak
+                 That is almost guaranteed to cause problems.}
+  }
+}
+
+% Test if a char (by char code) is available in the current font
+\newcommand*\xpg at if@char at available[3]{%
+  \polyglossia at check@if at char@available:NTF{#1}{#2}{#3}%
+}
+
+\newcommand*\charifavailable[2]{%
+   \xpg at if@char at available{#1}{\char"#1}{#2}%
+}
+
+
 \newcommand*{\xpg at set@language at nonaux}[2][]{%
    \@select at language[#1]{#2}%
 }
@@ -1601,6 +1852,24 @@
    }{%
      \edef\babelname{\prop_item:Nn{\polyglossia at langsetup}{#2/babelname}}%
    }%
+   % Store BCP-47 id of current language
+   \tl_if_blank:nTF {#1}{%
+     \ifcsundef{#2 at gbcp47id}{%
+        \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+     }{%
+        \csedef{bcp47id}{\csuse{#2 at gbcp47id}}%
+     }%
+   }{%
+     \csedef{bcp47id}{\prop_item:Nn{\polyglossia at langsetup}{#2/bcp47}}%
+   }%
+  % Store bcp47 in \xpg at bcp@loaded csv list
+  \def\xpg at tmp@bcpname{\csuse{bcp47id}}%
+  \ifcsundef{\csname xpg at tmp@bcpname\endcsname @bcp at loaded}
+  {
+    \global\edef\xpg at bcp@loaded{\xpg at tmp@bcpname%
+          \ifx\xpg at bcp@loaded\@empty\else,\xpg at bcp@loaded\fi}%
+    \csgdef{\csname xpg at tmp@bcpname\endcsname @bcp at loaded}{}%
+  }{}
    \@select at language[#1]{#2}%
     % Write to the aux
    \if at filesw%
@@ -1618,24 +1887,57 @@
    \fi
 }
 
+% The bidi package swaps the output stream within RTL tables
+% (to get the column order right). This also swaps group
+% delimiters inserted to the aux files via otherlanguage (see #354).
+% We therefore patch bidi and insert a bool that tells us
+% whether we are in such a table.
+\newbool{xpg at inbiditable}
+\AtBeginDocument{%
+  \@ifpackageloaded{bidi}{%
+     \patchcmd{\@tabular}%
+               {\if at RTLtab}%
+               {\if at RTLtab\booltrue{xpg at inbiditable}}%
+               {}% success
+               {\xpg at warning{Patching bidi table failed!}}%
+  }{}%
+}
+
 % Open a group in the aux file. This is to keep
-% nested language options local (see #320)
+% 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%
-      \protected at write\@auxout{}{\bgroup}%
-      \addtocontents{toc}{\bgroup}%
-      \addtocontents{lof}{\bgroup}%
-      \addtocontents{lot}{\bgroup}%
+      \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
+% 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%
-      \protected at write\@auxout{}{\egroup}%
-      \addtocontents{toc}{\egroup}%
-      \addtocontents{lof}{\egroup}%
-      \addtocontents{lot}{\egroup}%
+      \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
 }
 
@@ -1745,7 +2047,7 @@
      \noextrascurrent{\languagename}%
      \csuse{no\languagename @numbers}%
      \ifxetex
-        \str_if_eq:eeTF{\prop_item:Nn{\polyglossia at langsetup}{\languagename/direction}}{RL}%
+        \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
@@ -1772,12 +2074,24 @@
 
 \provideenvironment{otherlanguage}{}{}
 
+\newbool{xpg at noset@groups}
 \renewenvironment{otherlanguage}[2][]
 {%
-  \xpg at set@group at aux%
+  % 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}%
   \selectlanguage[#1]{#2}%
 }
-{\xpg at unset@group at aux}
+{\ifbool{xpg at noset@groups}{}{\xpg at unset@group at aux}}
 
 \newcommand{\setlocalhyphenmins}[3]{%
    \xpg at ifdefined{#1}{%
@@ -1792,7 +2106,17 @@
 
 \def\use at localhyphenmins#1{%
    \ifcsundef{#1hyphenmins}{}%
-   {\expandafter\expandafter\expandafter\set at hyphenmins\csname #1hyphenmins\endcsname\relax}}
+   {\expandafter\expandafter\expandafter\set at hyphenmins\csname #1hyphenmins\endcsname\relax}
+   \ifluatex
+     % Set \totalhyphenmin if specified
+     \prop_get:NxNTF \polyglossia at langsetup {#1/totalhyphenmin} \l_tmpa_tl
+     {
+        \xpg at warning{totalhyphenmin: '\l_tmpa_tl'}
+        \expandafter\hyphenationmin \l_tmpa_tl%
+     }%
+     {}%
+   \fi
+}
 
 \AtEndPreamble{%
    \@ifpackageloaded{bidi}{%



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