简体   繁体   English

如何从客户端机器获取CultureInfo?

[英]How to get CultureInfo from client machine?

so this is question for 1mln$. 所以这是1mln $的问题。

First of all, I'm developing web application in Visual WebGui. 首先,我正在开发Visual WebGui中的Web应用程序。 This is basically Winforms, but than application is converted to HTML5 and vualá.. web application. 这基本上是Winforms,但是应用程序转换为HTML5和vualá.. web应用程序。 Anyway, I have a problem with DateTime formats. 无论如何,我有DateTime格式的问题。 By default it is CultureInfo from server machine. 默认情况下,它是来自服务器计算机的CultureInfo。

I can override this in web.config like that: 我可以在web.config中覆盖它,如下所示:

<globalization requestEncoding="utf-8" responseEncoding="utf-8"  culture="de-DE" uiCulture="de-DE"/>

Every dateformat will be german on every client machine. 每个日期格式都将在每台客户端计算机上都是德语。 What I want is to make a web application, which will display Datetime format like on client machine in control panel. 我想要的是制作一个Web应用程序,它将在控制面板中的客户端机器上显示日期时间格式。

Is it possible? 可能吗? I just can't find the solution. 我只是找不到解决方案。

Thanks for help, 感谢帮助,

Try this: 试试这个:

Thread.CurrentThread.CurrentCulture = new CultureInfo(Request.UserLanguages[1]);

Check this link for example Multilingual Application 检查此链接,例如多语言应用程序

You can set the uiculture and culture attributes of the globalization tag to auto. 您可以将全球化标记的uiculture和culture属性设置为auto。 This will enable you to let the server decide the user's language according to his browser's settings and everything will happen automatically if you use localized resources. 这将使您能够让服务器根据其浏览器的设置决定用户的语言,如果您使用本地化资源,一切都会自动发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM