findSupportedLocale = function(sLocale, aSupportedLocales) {

		// if supportedLocales array is empty or undefined or if it contains the given locale,
		// return that locale (with a legacy ISO639 language code)
		if (!aSupportedLocales || aSupportedLocales.length === 0 || aSupportedLocales.includes(sLocale)) {
			return sLocale;
		}

		// determine an alternative locale, using a modern ISO639 language code
		// (converts "iw_IL" to "he-IL")
		sLocale = convertLocaleToBCP47(sLocale, true);
		if (sLocale) {
			// normalize it to JDK syntax for easier comparison
			// (converts "he-IL" to "he_IL" - using an underscore ("_") between the segments)
			sLocale = normalize(sLocale, true);
		}
		if (aSupportedLocales.includes(sLocale)) {
			// return the alternative locale (with a modern ISO639 language code)
			return sLocale;
		}
		return undefined;
	}
Check if the given locale is contained in the given list of supported locales.

If no list is given or if it is empty, any locale is assumed to be supported and
the given locale is returned without modification.

When the list contains the given locale, the locale is also returned without modification.

If an alternative code for the language code part of the locale exists (e.g a modern code
if the language is a legacy code, or a legacy code if the language is a modern code), then
the language code is replaced by the alternative code. If the resulting alternative locale
is contained in the list, the alternative locale is returned.

If there is no match, <code>undefined</code> is returned.
@param {string} sLocale Locale, using legacy ISO639 language code, e.g. iw_IL
@param {string[]} aSupportedLocales List of supported locales, e.g. ["he_IL"]
@returns {string} The match in the supportedLocales (using either modern or legacy ISO639 language codes),
  e.g. "he_IL"; <code>undefined</code> if not matched