gpt4 book ai didi

ASP.net不使用其他区域设置资源文件

转载 作者:行者123 更新时间:2023-12-04 13:14:40 25 4
gpt4 key购买 nike

我有一个Default.aspx文件,我在其中获取本地化的值:

Default.aspx :

<asp:Localize meta:resourcekey="lblTitle" runat="server">Welcome</asp:Localize>

然后,我创建一个匹配的后备资源文件:

Default.aspx.resx :
lblTitle.Text    Welcome to Stackoverflow Localized

那行得通:

现在,我想创建一个法国本地化版本:

Default.aspx.fr.resx :
lblTitle.Text    Bienvenue Stackoverflow

然后我将浏览器更改为发送法语语言环境:

(它的作用):
GET http://stackoverflow.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*
Accept-Language: fr-CH,qps-ploc;q=0.5
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: stackoverflow.com

只是它不起作用:

我正在关注 Microsoft says:

For example, if you have a page named Default.aspx in the App_LocalResources folder, you might create the following files:

  • Default.aspx.resx. This is the default local resource file (the fallback resource file) if no language match is found.

  • Default.aspx.es.resx. This is the resource file for Spanish, without culture information.

  • Default.aspx.es-mx.resx. This is the resource file for Spanish (Mexico) specifically.

  • Default.aspx.fr.resx. This is the resource file for French, without culture information.



.NET为什么不执行.NET应该做什么?

更新:

从MSDN:

Selecting Resource Files for Different Languages

ASP.NET can set the UICulture and Culture properties for the page to the language and culture values that are passed by the browser. ... For detailed information, see How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization.



我如何获得ASP.NET将页面的 UICultureCulture属性设置为浏览器传递的语言和区域性值?

来自 How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization:

Users can set the UI culture and culture in their browsers. For example, in Microsoft Internet Explorer, on the Tools menu, users can click Internet Options, on the General tab, click Language, and then set their language preference. If the enableClientBasedCulture attribute of the globalization element in the Web.config file is set to true, ASP.NET can set the UI culture and culture for a Web page automatically, based on the values that are sent by a browser.

To set the culture and UI culture for an ASP.NET Web page declaratively

  • To have ASP.NET set the UI culture and culture to the first language that is specified in the current browser settings, set UICulture and Culture to auto. Alternatively, you can set this value to auto:culture_info_name, where culture_info_name is a culture name. For a list of culture names, see CultureInfo. You can make this setting either in the @ Page directive or Web.config file.

最佳答案

尝试在.aspx文件的UICulture="auto"伪指令中设置Culture="auto"@ Page

How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization

或者,您可以在web.config中完成相同的操作,除了它适用于每个页面:

<system.web>
<globalization uiCulture="auto" culture="auto" />
</system.web>

关于ASP.net不使用其他区域设置资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7520287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com