function convertLocaleToBCP47(sLocale, bConvertToModern) {
		var m;
		if ( typeof sLocale === 'string' && (m = rLocale.exec(sLocale.replace(/_/g, '-'))) ) {
			var sLanguage = m[1].toLowerCase();
			var sScript = m[2] ? m[2].toLowerCase() : undefined;
			// special case for "sr_Latn" language: "sh" should then be used
			if (bConvertToModern && sLanguage === "sh" && !sScript) {
				sLanguage = "sr_Latn";
			} else if (!bConvertToModern && sLanguage === "sr" && sScript === "latn") {
				sLanguage = "sh";
			}
			sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
			return sLanguage + (m[3] ? "-" + m[3].toUpperCase() + (m[4] ? "-" + m[4].slice(1).replace("_","-") : "") : "");
		}
	}
/**
	 * Helper to normalize the given locale (java.util.Locale format) to the BCP-47 syntax.
	 *
	 * @param {string} sLocale locale to convert
	 * @param {boolean} bConvertToModern whether to convert to modern language
	 * @returns {string} Normalized locale or undefined if the locale can't be normalized
	 */
Helper to normalize the given locale (java.util.Locale format) to the BCP-47 syntax.
@param {string} sLocale locale to convert
@param {boolean} bConvertToModern whether to convert to modern language
@returns {string} Normalized locale or undefined if the locale can't be normalized
Helper to normalize the given locale ( java . util . Locale format ) to the BCP - 47 syntax . @param { string } sLocale locale to convert @param { boolean } bConvertToModern whether to convert to modern language @returns { string } Normalized locale or undefined if the locale can ' t be normalized
function convertLocaleToBCP47(sLocale, bConvertToModern) {
		var m;
		if ( typeof sLocale === 'string' && (m = rLocale.exec(sLocale.replace(/_/g, '-'))) ) {
			var sLanguage = m[1].toLowerCase();
			var sScript = m[2] ? m[2].toLowerCase() : undefined;
			if (bConvertToModern && sLanguage === "sh" && !sScript) {
				sLanguage = "sr_Latn";
			} else if (!bConvertToModern && sLanguage === "sr" && sScript === "latn") {
				sLanguage = "sh";
			}
			sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
			return sLanguage + (m[3] ? "-" + m[3].toUpperCase() + (m[4] ? "-" + m[4].slice(1).replace("_","-") : "") : "");
		}
	}
function convertLocaleToBCP47 ( sLocale , bConvertToModern ) { var m ; if ( typeof sLocale === 'string' && ( m = rLocale . exec ( sLocale . replace ( / _ / g , '-' ) ) ) ) { var sLanguage = m [ 1 ] . toLowerCase ( ) ; var sScript = m [ 2 ] ? m [ 2 ] . toLowerCase ( ) : undefined ; if ( bConvertToModern && sLanguage === "sh" && ! sScript ) { sLanguage = "sr_Latn" ; } else if ( ! bConvertToModern && sLanguage === "sr" && sScript === "latn" ) { sLanguage = "sh" ; } sLanguage = M_ISO639_OLD_TO_NEW [ sLanguage ] || sLanguage ; return sLanguage + ( m [ 3 ] ? "-" + m [ 3 ] . toUpperCase ( ) + ( m [ 4 ] ? "-" + m [ 4 ] . slice ( 1 ) . replace ( "_" , "-" ) : "" ) : "" ) ; } }
Helper to normalize the given locale (java.util.Locale format) to the BCP-47 syntax.
Helper to normalize the given locale ( java . util . Locale format ) to the BCP - 47 syntax .
// special case for "sr_Latn" language: "sh" should then be used