public static bool CompareLocales(int localeId, string locale, bool ignoreRegion)
{
// parse locale.
CultureInfo culture = null;
try
{
culture = new CultureInfo(locale);
}
catch (Exception)
{
return false;
}
// only match the language portion of the locale id.
if (ignoreRegion)
{
if ((localeId & culture.LCID & 0x3FF) == (localeId & 0x3FF))
{
return true;
}
}
// check for exact match.
else
{
if (localeId == culture.LCID)
{
return true;
}
}
return false;
}