问题描述
我从CultureInfo创建了一个CustomCulture类。
I created a CustomCulture class form CultureInfo.
这是我的代码:
public class CustomCulture : CultureInfo
{
私有字符串_parent ;
私有字符串_name;
私有字符串_description;
{
private string _parent;
private string _name;
private string _description;
public CustomCulture(string parentCulture, string myCultureName) : base(parentCulture)
{
_parent = parentCulture;
_name = myCultureName;
_description = String.Format("custom culture({0})", _name);
}
public override string Name
{
get
{
return _parent + "-" + _name;
}
}
public override CultureInfo Parent
{
get
{
return new CultureInfo(_parent);
}
}
public override string EnglishName
{
get
{
return _description;
}
}
public override string NativeName
{
get
{
return _description;
}
}
}
public partial class _Default : System.Web.UI.Page
{
private DefCulture.CustomCulture abc = new DefCulture.CustomCulture( en-AU, abc);
{ private DefCulture.CustomCulture abc = new DefCulture.CustomCulture("en-AU", "abc");
protected override void InitializeCulture()
{
Thread.CurrentThread.CurrentUICulture = abc;
}
....
例如,如果要创建自定义区域性en-AU-abc,
,我想实现的是当前页面可以使用本地资源文件Default.aspx.en-AU-abc.resx,
What I want to achieve is, for example, if I create a custom culture en-AU-abc,the current page can use local resource file Default.aspx.en-AU-abc.resx,
但我无法正常工作,当前页面始终加载Default.aspx.resx
but I couldn't get it work, the current page always loads Default.aspx.resx
推荐答案
尝试安装自定义区域性。请参见创建一个.msi并运行它以安装您的自定义语言环境(需要Vista或更高版本)。我能够通过App_GlobalResources在Vista上使用它。
Try installing the custom culture. See Microsoft Locale Builder to create an .msi and run it to install your custom locale (requires Vista or later). I was able to get it working on Vista with App_GlobalResources.
BTW,例如,带有私有扩展名的自定义语言环境需要 -x- ,
en-AU-x-abc 。参见
BTW, custom locales with private-use extensions require -x-, for example,en-AU-x-abc. See Constructing language tags
这篇关于ASP.NET中的自定义文化信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!