Avoid fontspec warning with babel

This bugged me for a long time too. This is what is going on:

These are the scripts and languages supported by Amiri:

DFLT        Default
arab        Arabic
arab.ARA    Arabic/Arabic
arab.KSH    Arabic/Kashmiri
arab.SND    Arabic/Sindhi
arab.URD    Arabic/Urdu
latn        Latin
latn.TRK    Latin/Turkish

When you load Arabic with \babelprovide[import=ar-DZ, main]{arabic} then babel reads in babel-ar-DZ.ini.

In this file you will find (among other things):

tag.opentype = ARA
script.tag.opentype = arab

So when Algerian Arabic is the language in use, babel will load Amiri with arab.ARA script and language. This exists in the font, so all is good.

But babel-en.ini contains this:

tag.opentype = ENG
script.tag.opentype = latn

So when English is in use, babel will try and load Amiri with latn.ENG script and language. Except this combination does not exist in the font, so a warning is issued by babel:

Language 'English' not available for font 'Amiri' with script 'Latin'.

Now all we need to do is tell babel to use Language=Default with Script=Latin for English while continuing to use Language=Arabic with Script=Arabic for Algerian Arabic.

To do this, remove english from the main babel options and instead load it like this:

\babelprovide[import,language=Default]{english}

Note: babel uses language with a lowercase l as opposed to fontspec which uses Language!

babel will now load Amiri with supported options for English text and no warning is issued.

MWE

\documentclass[hyperref=unicode]{beamer}

\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelprovide[import, language=Default]{english}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}    

\begin{document}

\begin{frame}{}
\today
\end{frame}

\begin{frame}{}
\selectlanguage{english}
\today
\end{frame}

\end{document}

You can set the language to default:

\documentclass[hyperref=unicode]{beamer}

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\babelfont{rm}[Language=Default]{Amiri}
\babelfont{sf}[Language=Default]{Amiri}


\begin{document}

\begin{frame}{}
\today
\end{frame}

\begin{frame}{}
\selectlanguage{english}
\today
\end{frame}

\end{document}

Nothing wrong, on the contrary. These warnings are shown by fontspec, not by babel. They could be irrelevant for English, but not for many other languages, including Arabic. To remove them altogether (they are only really useful when the document format is being set up), you may pass the silent option to fontspec:

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\PassOptionsToPackage{silent}{fontspec}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}

Or also:

\usepackage[english,nil,bidi=basic-r]{babel}
\babelprovide[import=ar-DZ, main]{arabic}
\usepackage[silent]{fontspec}
\babelfont{rm}{Amiri}
\babelfont{sf}{Amiri}

Edit. A 3rd option is to pass silent as a class option.