private static string GetNeutralResModuleName(string resourceName, CultureInfo cultureInfo)
{
if (cultureInfo.Equals(CultureInfo.InvariantCulture))
{
return resourceName;
}
else
{
// if it is an satellite assembly, we need to strip out the culture name
string normalizedName = resourceName.ToLower(CultureInfo.InvariantCulture);
int end = normalizedName.LastIndexOf(".resources");
if (end < 0)
{
return resourceName;
}
int start = normalizedName.LastIndexOf('.', end - 1);
if (start > 0 && end - start > 0)
{
string cultureStr = resourceName.Substring( start + 1, end - start - 1);
if (string.Compare(cultureStr, cultureInfo.Name, true) == 0)
{
// it has the correct culture name, so we can take it out
return resourceName.Remove(start, end - start);
}
}
return resourceName;
}
}