function findSupportedLocale(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.indexOf(sLocale) >= 0) {
			return sLocale;
		}

		// determine an alternative locale, using a modern ISO639 language code
		// (converts "sh_RS" to "sr-RS")
		sLocale = convertLocaleToBCP47(sLocale, true);
		if (sLocale) {
			// normalize it to JDK syntax for easier comparison
			// (converts "sr-RS" to "sr_RS" - using an underscore ("_") between the segments)
			sLocale = normalize(sLocale, true);
		}
		if (aSupportedLocales.indexOf(sLocale) >= 0) {
			// 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. sh_RS
	 * @param {string[]} aSupportedLocales List of supported locales, e.g. ["sr_RS"]
	 * @returns {string} The match in the supportedLocales (using either modern or legacy ISO639 language codes),
	 *   e.g. "sr_RS"; <code>undefined</code> if not matched
	 */
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 , 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, undefined is returned.
@param {string} sLocale Locale, using legacy ISO639 language code, e.g. sh_RS
@param {string[]} aSupportedLocales List of supported locales, e.g. ["sr_RS"]
@returns {string} The match in the supportedLocales (using either modern or legacy ISO639 language codes),
e.g. "sr_RS"; undefined if not matched
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 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 undefined is returned . @param { string } sLocale Locale using legacy ISO639 language code e . g . sh_RS @param { string [] } aSupportedLocales List of supported locales e . g . [ " sr_RS " ] @returns { string } The match in the supportedLocales ( using either modern or legacy ISO639 language codes ) e . g . " sr_RS " ; undefined if not matched
function findSupportedLocale(sLocale, aSupportedLocales) {
		if (!aSupportedLocales || aSupportedLocales.length === 0 || aSupportedLocales.indexOf(sLocale) >= 0) {
			return sLocale;
		}
		sLocale = convertLocaleToBCP47(sLocale, true);
		if (sLocale) {
			sLocale = normalize(sLocale, true);
		}
		if (aSupportedLocales.indexOf(sLocale) >= 0) {
			return sLocale;
		}
		return undefined;
	}
function findSupportedLocale ( sLocale , aSupportedLocales ) { if ( ! aSupportedLocales || aSupportedLocales . length === 0 || aSupportedLocales . indexOf ( sLocale ) >= 0 ) { return sLocale ; } sLocale = convertLocaleToBCP47 ( sLocale , true ) ; if ( sLocale ) { sLocale = normalize ( sLocale , true ) ; } if ( aSupportedLocales . indexOf ( sLocale ) >= 0 ) { return sLocale ; } return undefined ; }
Check if the given locale is contained in the given list of supported locales.
Check if the given locale is contained in the given list of supported locales .
// if supportedLocales array is empty or undefined or if it contains the given locale, // return that locale (with a legacy ISO639 language code) // determine an alternative locale, using a modern ISO639 language code // (converts "sh_RS" to "sr-RS") // normalize it to JDK syntax for easier comparison // (converts "sr-RS" to "sr_RS" - using an underscore ("_") between the segments) // return the alternative locale (with a modern ISO639 language code)