|
|
|
@ -50,6 +50,8 @@ namespace ICSharpCode.Core |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static readonly object loadLock = new object(); |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>English strings (list of resource managers)</summary>
|
|
|
|
/// <summary>English strings (list of resource managers)</summary>
|
|
|
|
static List<ResourceManager> strings = new List<ResourceManager>(); |
|
|
|
static List<ResourceManager> strings = new List<ResourceManager>(); |
|
|
|
/// <summary>Neutral/English images (list of resource managers)</summary>
|
|
|
|
/// <summary>Neutral/English images (list of resource managers)</summary>
|
|
|
|
@ -178,33 +180,34 @@ namespace ICSharpCode.Core |
|
|
|
|
|
|
|
|
|
|
|
static void LoadLanguageResources(string language) |
|
|
|
static void LoadLanguageResources(string language) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ClearCaches != null) |
|
|
|
lock (loadLock) { |
|
|
|
ClearCaches(null, EventArgs.Empty); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language); |
|
|
|
|
|
|
|
} catch (Exception) { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language.Split('-')[0]); |
|
|
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language); |
|
|
|
} catch (Exception) {} |
|
|
|
} catch (Exception) { |
|
|
|
} |
|
|
|
try { |
|
|
|
|
|
|
|
Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language.Split('-')[0]); |
|
|
|
localStrings = Load(stringResources, language); |
|
|
|
} catch (Exception) {} |
|
|
|
if (localStrings == null && language.IndexOf('-') > 0) { |
|
|
|
} |
|
|
|
localStrings = Load(stringResources, language.Split('-')[0]); |
|
|
|
|
|
|
|
} |
|
|
|
localStrings = Load(stringResources, language); |
|
|
|
|
|
|
|
if (localStrings == null && language.IndexOf('-') > 0) { |
|
|
|
localIcons = Load(imageResources, language); |
|
|
|
localStrings = Load(stringResources, language.Split('-')[0]); |
|
|
|
if (localIcons == null && language.IndexOf('-') > 0) { |
|
|
|
} |
|
|
|
localIcons = Load(imageResources, language.Split('-')[0]); |
|
|
|
|
|
|
|
} |
|
|
|
localIcons = Load(imageResources, language); |
|
|
|
|
|
|
|
if (localIcons == null && language.IndexOf('-') > 0) { |
|
|
|
localStringsResMgrs.Clear(); |
|
|
|
localIcons = Load(imageResources, language.Split('-')[0]); |
|
|
|
localIconsResMgrs.Clear(); |
|
|
|
} |
|
|
|
currentLanguage = language; |
|
|
|
|
|
|
|
foreach (ResourceAssembly ra in resourceAssemblies) { |
|
|
|
localStringsResMgrs.Clear(); |
|
|
|
ra.Load(); |
|
|
|
localIconsResMgrs.Clear(); |
|
|
|
|
|
|
|
currentLanguage = language; |
|
|
|
|
|
|
|
foreach (ResourceAssembly ra in resourceAssemblies) { |
|
|
|
|
|
|
|
ra.Load(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (ClearCaches != null) |
|
|
|
|
|
|
|
ClearCaches(null, EventArgs.Empty); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Hashtable Load(string fileName) |
|
|
|
static Hashtable Load(string fileName) |
|
|
|
@ -241,68 +244,72 @@ namespace ICSharpCode.Core |
|
|
|
/// </exception>
|
|
|
|
/// </exception>
|
|
|
|
public static string GetString(string name) |
|
|
|
public static string GetString(string name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (localStrings != null && localStrings[name] != null) { |
|
|
|
lock (loadLock) { |
|
|
|
return localStrings[name].ToString(); |
|
|
|
if (localStrings != null && localStrings[name] != null) { |
|
|
|
} |
|
|
|
return localStrings[name].ToString(); |
|
|
|
|
|
|
|
|
|
|
|
string s = null; |
|
|
|
|
|
|
|
foreach (ResourceManager resourceManger in localStringsResMgrs) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
s = resourceManger.GetString(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s != null) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
string s = null; |
|
|
|
if (s == null) { |
|
|
|
foreach (ResourceManager resourceManger in localStringsResMgrs) { |
|
|
|
foreach (ResourceManager resourceManger in strings) { |
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
s = resourceManger.GetString(name); |
|
|
|
s = resourceManger.GetString(name); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception) { } |
|
|
|
catch (Exception) { } |
|
|
|
|
|
|
|
|
|
|
|
if (s != null) { |
|
|
|
if (s != null) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s == null) { |
|
|
|
|
|
|
|
foreach (ResourceManager resourceManger in strings) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
s = resourceManger.GetString(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (s != null) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (s == null) { |
|
|
|
|
|
|
|
throw new ResourceNotFoundException("string >" + name + "<"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
} |
|
|
|
} |
|
|
|
if (s == null) { |
|
|
|
|
|
|
|
throw new ResourceNotFoundException("string >" + name + "<"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static object GetImageResource(string name) |
|
|
|
public static object GetImageResource(string name) |
|
|
|
{ |
|
|
|
{ |
|
|
|
object iconobj = null; |
|
|
|
lock (loadLock) { |
|
|
|
if (localIcons != null && localIcons[name] != null) { |
|
|
|
object iconobj = null; |
|
|
|
iconobj = localIcons[name]; |
|
|
|
if (localIcons != null && localIcons[name] != null) { |
|
|
|
} else { |
|
|
|
iconobj = localIcons[name]; |
|
|
|
foreach (ResourceManager resourceManger in localIconsResMgrs) { |
|
|
|
} else { |
|
|
|
iconobj = resourceManger.GetObject(name); |
|
|
|
foreach (ResourceManager resourceManger in localIconsResMgrs) { |
|
|
|
if (iconobj != null) { |
|
|
|
iconobj = resourceManger.GetObject(name); |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iconobj == null) { |
|
|
|
|
|
|
|
foreach (ResourceManager resourceManger in icons) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
iconobj = resourceManger.GetObject(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iconobj != null) { |
|
|
|
if (iconobj != null) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iconobj == null) { |
|
|
|
|
|
|
|
foreach (ResourceManager resourceManger in icons) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
iconobj = resourceManger.GetObject(name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) { } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (iconobj != null) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return iconobj; |
|
|
|
} |
|
|
|
} |
|
|
|
return iconobj; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|