我在 Properties/String/ (cs-CZ.resx;default.resx) 中有两个资源
我是这样设置的:
internal static System.Resources.ResourceManager strings;
public static void SetLanguage(string culture)
{
if (culture == "cs-CZ")
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("cs-CZ");
strings = Properties.Strings.cs_CZ.ResourceManager;
}
else
{
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
strings = Properties.Strings._default.ResourceManager;
}
}
在表单构造函数中:
SetLanguage("cs-CZ");
接着
public static string Translate(string name)
{
return strings.GetString(name);
}
mainStrip.Text = Translate("mainStrip");
但我得到了 TypeInitializationException。怎么了?