区域设置en-GB CultureInfo.CurrentCulture.Name = en-US [英] Regional Settings en-GB CultureInfo.CurrentCulture.Name = en-US

查看:67
本文介绍了区域设置en-GB CultureInfo.CurrentCulture.Name = en-US的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我知道我可以将文化设置为我想要的,但不应该从区域中获取当前的

文化网络服务器上的设置

控制面板!!!


我的设置为联合王国


但是在我的asp.net页面中我做了


string cl = CultureInfo.CurrentUICulture.Name;

string cn = CultureInfo.CurrentCulture.Name ;


两个字符串返回en-US


我需要这个是en-GB所以我的comparevalidator会对
a textbox ....


其他人有这个经验吗?

解决方案

什么

服务器端代码正在执行的用户上下文的Windows区域设置?我猜这是不是同一个帐户

,你正在查看区域设置,因为后者是

可能是管理员帐户。

" magister" <宇*** @ yahoo.co.uk>在消息中写道

news:98 ************************** @ posting.google.c om ...

您好,

我知道我可以将文化设置为我想要的,但不应该从当地的区域设置中获取当前的文化网络服务器的
控制面板!!!
我的设置为联合王国

但是在我的asp.net页面中我做了/>
string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

两个字符串返回en-US

我需要这个en-GB所以我的comparevalidator会对文本框进行日期检查....

其他人有这个经验吗?



2004年7月8日04:12:18 -0700, yu***@yahoo.co.uk (magister)写道:

我知道我可以将文化设置为我想要的,但不应该从该地区获取当前的文化在web服务器的
控制面板上的设置!!!




我不确定你想要什么,但我们做什么(在Page_Load())中我们的ASP.Net应用程序 - 我相信它会给你带来
想要的效果 - 这是对我们专门编写的例程的调用,以便于实现

多语言/多日期格式/等:


UIUtilities.setCulture(请求);


这就是所谓的:


///< summary>

///将当前线程的显示文化设置为最多

来自用户的传入Http请求的适当文化对象。

///< / summary>

///< param name =" request">< / param>

internal static void setCulture(HttpRequest request)

{

if(request!= null)

{

if(request.UserLanguages!= null)

{

if(request.UserLanguages.Length> -1)

{< br $>
string cultureName =

request.UserLanguages [0];

UIUtilities.setCulture(cultureName);

}

}

// TODO:设置为(系统范围,或可能是

用户指定的)默认文化,如果浏览器没有''给我们任何

线索。

}

}


///< summary> ;

///将当前线程的显示文化设置为特定的

命名文化。

///< / summary>

///< param name =" cultureName">要设置的文化名称

线程< / param>

priva te static void setCulture(string cultureName)

{

Thread.CurrentThread.CurrentCulture =

CultureInfo.CreateSpecificCulture(cultureName);

Thread.CurrentThread.CurrentUICulture = new

CultureInfo(cultureName);

}

这样做的是处理的线程页面的该用户的输出(和

输入)将自动设置为该用户的适当文化(例如,用于日期输入/输出)。它使用

a标题,由浏览器自动发送(4.0及更高版本 -

也适用于Firefox / Mozilla),因此ASP.Net的用户

应用程序无需在应用程序中单独选择语言/文化

首选项。


注意:你可以改变这个设置测试(例如在IE中)通过

转到工具/ Internet选项/语言,然后添加要测试的语言

并将其移动到第一个/顶一个。


因为它是每个用户,而不是基于服务器设置,

它是更灵活的全球就绪。


FWIW我们使用相同的浏览器标头来处理

ResourceManager机制,以在输出中提供其他语言文本

网页,只需在调用后执行以下操作即可为用户设置

线程文化:


Res ourceManager resourceManager = new

ResourceManager(" AppName.strings",typeof(SampleForm).Assembly);


(然后使用ctrl.Text = resourceManager。 GetString(" NameOfItem")as

normal)


所有这一切的净效果是想要约会的用户正确

way"输出和输入验证的周围(我是澳大利亚人)

让页面按照这种方式工作,而喜欢MM / DD / YYYY的人将依次获得
为你的输入/输出工作没有你必须做的事情

你的代码中硬连线的任何东西,或强迫用户为他们的应用选择一个

语言/文化偏好登录详情。


ted.h.

-

Ted Harper(澳大利亚悉尼)


我在哪里可以检查和更改我的用户帐户的区域设置?

" Nicole Calinoiu" < NI ***** @ somewhere.net>在消息新闻中写道:< O7 ************** @ TK2MSFTNGP09.phx.gbl> ...

用户上下文的Windows区域设置是什么
服务器端代码正在执行?我猜你正在查看区域设置不是同一个帐户,因为后者可能是管理员帐户。

" ;&魔导师QUOT; <宇*** @ yahoo.co.uk>在消息中写道
新闻:98 ************************** @ posting.google.c om ...

您好,

我知道我可以将文化设置为我想要的,但不应该从网络服务器上的区域设置中获取当前的文化。 s
控制面板!!!
我的设置为联合王国

但是在我的asp.net页面中我做了

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

两个字符串返回en-US

我需要这个是en-GB所以我的comparevalidator会对文本框进行日期检查....

其他人有这个经验吗?



Hello,

I know I can set the Culture to what I want, but shouldn''t the current
culture be taken from the regional settings on the web server''s
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?

解决方案

What is the Windows regional setting for the user context in which the
server-side code is executing? I''m guessing that it''s not the same account
under which you''re viewing the regional settings since the latter is
probably the administrator account.
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...

Hello,

I know I can set the Culture to what I want, but shouldn''t the current
culture be taken from the regional settings on the web server''s
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?



On 8 Jul 2004 04:12:18 -0700, yu***@yahoo.co.uk (magister) wrote:

I know I can set the Culture to what I want, but shouldn''t the current
culture be taken from the regional settings on the web server''s
control panel!!!



I''m not sure exactly what you want, but what we do (in Page_Load()) in
our ASP.Net applications - which I believe will give the effect you
want - is this call to a routine we wrote specifically to enable easy
multi-language/multi-date-format/etc:

UIUtilities.setCulture(Request);

Where this is what gets called:

/// <summary>
/// Set the display culture for the current thread to the most
appropriate culture from the user''s incoming Http "request" object.
/// </summary>
/// <param name="request"></param>
internal static void setCulture(HttpRequest request)
{
if (request != null)
{
if (request.UserLanguages != null)
{
if (request.UserLanguages.Length > -1)
{
string cultureName =
request.UserLanguages[0];
UIUtilities.setCulture(cultureName);
}
}
// TODO: Set to a (system-wide, or possibly
user-specified) default culture if the browser didn''t give us any
clues.
}
}

/// <summary>
/// Set the display culture for the current thread to a particular
named culture.
/// </summary>
/// <param name="cultureName">The name of the culture to be set for
the thread</param>
private static void setCulture(string cultureName)
{
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(cultureName);
Thread.CurrentThread.CurrentUICulture = new
CultureInfo(cultureName);
}
What this does is that the thread that processes the output (and
input) for that user for the page is AUTOMATICALLY set for the
appropriate culture (eg for date input/output) for that user. It uses
a header which is sent automatically by the browser (4.0 and later -
works fine with Firefox/Mozilla too), so the user of your ASP.Net
application doesn''t have to separately select a language/culture
preference in the application.

NB: You can change this setting for testing (in IE for example) by
going to Tools/Internet Options/Languages, then adding the language
you want to test and moving it to be the first/top one.

Because it is per-user, rather than being based on a server setting,
it is a lot more flexible as far as being "world-ready".

FWIW we use the same browser header to work in with the
ResourceManager mechanism to provide other-language text in the output
web pages too, simply by doing the following after the call to set the
thread culture to the right one for the user:

ResourceManager resourceManager = new
ResourceManager("AppName.strings", typeof(SampleForm).Assembly);

(then using ctrl.Text = resourceManager.GetString("NameOfItem") as
normal)

The net effect of all this is that a user who wants dates the "right
way" around (I''m an Australian) for output and input validation will
have the page work that way, and someone who prefers MM/DD/YYYY will
in turn have that work for their input/output WITHOUT you having to do
anything hardwired in your code, or forcing users to select a
language/culture preference for your app in their logon details.

ted.h.
--
Ted Harper (Sydney, Australia)


Where can I check&change the regional settings of my user account?
"Nicole Calinoiu" <ni*****@somewhere.net> wrote in message news:<O7**************@TK2MSFTNGP09.phx.gbl>...

What is the Windows regional setting for the user context in which the
server-side code is executing? I''m guessing that it''s not the same account
under which you''re viewing the regional settings since the latter is
probably the administrator account.
"magister" <yu***@yahoo.co.uk> wrote in message
news:98**************************@posting.google.c om...

Hello,

I know I can set the Culture to what I want, but shouldn''t the current
culture be taken from the regional settings on the web server''s
control panel!!!

Mine is set to "united kingdom"

but in my asp.net page I do

string cl = CultureInfo.CurrentUICulture.Name;
string cn = CultureInfo.CurrentCulture.Name;

both string return en-US

I need this to be en-GB so my comparevalidator will do a date check on
a textbox....

Anyone else experience this?



这篇关于区域设置en-GB CultureInfo.CurrentCulture.Name = en-US的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆