internal static string LangToNameInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper)
{
string cultName = InvariantCultureName;
if (lang != null)
{
// The value of the 'lang' attribute must be a non-empty nmtoken
if (lang.Length == 0)
{
if (!forwardCompatibility)
{
if (errorHelper != null)
{
errorHelper.ReportError(/*[XT_032]*/SR.Xslt_InvalidAttrValue, nameof(lang), lang);
}
else
{
throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang);
}
}
}
else
{
// Check if lang is a supported culture name
try
{
cultName = new CultureInfo(lang).Name;
}
catch (System.ArgumentException)
{
if (!forwardCompatibility)
{
if (errorHelper != null)
{
errorHelper.ReportError(/*[XT_033]*/SR.Xslt_InvalidLanguage, lang);
}
else
{
throw new XslTransformException(SR.Xslt_InvalidLanguage, lang);
}
}
}
}
}
return cultName;
}