diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs b/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
index b922beeef..690eca689 100644
--- a/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
+++ b/ICSharpCode.Decompiler/Documentation/XmlDocLoader.cs
@@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
+using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
@@ -104,26 +105,37 @@ namespace ICSharpCode.Decompiler.Documentation
return fileName;
}
- static string LookupLocalizedXmlDoc(string fileName)
+ ///
+ /// Given the assembly file name, looks up the XML documentation file name.
+ /// Returns null if no XML documentation file is found.
+ ///
+ internal static string LookupLocalizedXmlDoc(string fileName)
{
if (string.IsNullOrEmpty(fileName))
return null;
string xmlFileName = Path.ChangeExtension(fileName, ".xml");
- string currentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
- string localizedXmlDocFile = GetLocalizedName(xmlFileName, currentCulture);
+
+ CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture;
+ string localizedXmlDocFile = GetLocalizedName(xmlFileName, currentCulture.Name);
+ string localizedXmlDocFallbackFile = GetLocalizedName(xmlFileName, currentCulture.TwoLetterISOLanguageName);
Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFile);
if (File.Exists(localizedXmlDocFile))
{
return localizedXmlDocFile;
}
+ Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFallbackFile);
+ if (File.Exists(localizedXmlDocFallbackFile))
+ {
+ return localizedXmlDocFallbackFile;
+ }
Debug.WriteLine("Try find XMLDoc @" + xmlFileName);
if (File.Exists(xmlFileName))
{
return xmlFileName;
}
- if (currentCulture != "en")
+ if (currentCulture.TwoLetterISOLanguageName != "en")
{
string englishXmlDocFile = GetLocalizedName(xmlFileName, "en");
Debug.WriteLine("Try find XMLDoc @" + englishXmlDocFile);
@@ -135,12 +147,9 @@ namespace ICSharpCode.Decompiler.Documentation
return null;
}
- static string GetLocalizedName(string fileName, string language)
+ private static string GetLocalizedName(string fileName, string language)
{
- string localizedXmlDocFile = Path.GetDirectoryName(fileName);
- localizedXmlDocFile = Path.Combine(localizedXmlDocFile, language);
- localizedXmlDocFile = Path.Combine(localizedXmlDocFile, Path.GetFileName(fileName));
- return localizedXmlDocFile;
+ return Path.Combine(Path.GetDirectoryName(fileName), language, Path.GetFileName(fileName));
}
}
}
diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
index 1f0b2da72..cae69da09 100644
--- a/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
+++ b/ICSharpCode.Decompiler/Documentation/XmlDocumentationProvider.cs
@@ -185,7 +185,7 @@ namespace ICSharpCode.Decompiler.Documentation
.Replace("%CORSYSDIR%", corSysDir);
if (!Path.IsPathRooted(fileName))
fileName = Path.Combine(Path.GetDirectoryName(xmlFileName), fileName);
- return LookupLocalizedXmlDoc(fileName);
+ return XmlDocLoader.LookupLocalizedXmlDoc(fileName);
}
static string AppendDirectorySeparator(string dir)
@@ -196,45 +196,6 @@ namespace ICSharpCode.Decompiler.Documentation
return dir + Path.DirectorySeparatorChar;
}
- ///
- /// Given the assembly file name, looks up the XML documentation file name.
- /// Returns null if no XML documentation file is found.
- ///
- public static string LookupLocalizedXmlDoc(string fileName)
- {
- string xmlFileName = Path.ChangeExtension(fileName, ".xml");
- string currentCulture = System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName;
- string localizedXmlDocFile = GetLocalizedName(xmlFileName, currentCulture);
-
- Debug.WriteLine("Try find XMLDoc @" + localizedXmlDocFile);
- if (File.Exists(localizedXmlDocFile))
- {
- return localizedXmlDocFile;
- }
- Debug.WriteLine("Try find XMLDoc @" + xmlFileName);
- if (File.Exists(xmlFileName))
- {
- return xmlFileName;
- }
- if (currentCulture != "en")
- {
- string englishXmlDocFile = GetLocalizedName(xmlFileName, "en");
- Debug.WriteLine("Try find XMLDoc @" + englishXmlDocFile);
- if (File.Exists(englishXmlDocFile))
- {
- return englishXmlDocFile;
- }
- }
- return null;
- }
-
- static string GetLocalizedName(string fileName, string language)
- {
- string localizedXmlDocFile = Path.GetDirectoryName(fileName);
- localizedXmlDocFile = Path.Combine(localizedXmlDocFile, language);
- localizedXmlDocFile = Path.Combine(localizedXmlDocFile, Path.GetFileName(fileName));
- return localizedXmlDocFile;
- }
#endregion
#region Load / Create Index