多语言网站优先语言

Priority language in multi language website

我正在按照本指南创建多语言页面:http://www.codeproject.com/Articles/334820/Using-Globalization-and-Localization-in-ASP-NET 但问题是: 我希望我的网站默认语言是印地语。 但是浏览器经常设置英文为默认语言。那是因为当我加载我的网站时,它的语言是英语,而不是印地语(我将印地语的 resx 文件更改为 default.aspx.resx 并将英语的 resx 文件更改为 default.aspx.en-US.resx 但浏览器仍显示英文)。 我如何设置默认我的网站默认语言是印地语?

代码:

default.aspx :

<form id="form1" runat="server">
<div>
    <asp:Label ID="lblWelcome" runat="server" meta:resourcekey="lblWelcomeResource1"
        Text="Welcome to Learning"></asp:Label>
    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
        <asp:ListItem Value="hi-in">हिंदी</asp:ListItem>
        <asp:ListItem Value="en-us">English</asp:ListItem>
    </asp:DropDownList><br />
    <br />
    <asp:Label ID="lblNotice" runat="server" meta:resourcekey="lblNoticeResource1" Text="Today is:"></asp:Label>&nbsp;
    <asp:Label ID="lblTime" runat="server" meta:resourcekey="lblTimeResource1"></asp:Label></div>
</form>

Default.aspx.cs :

protected void Page_Load(object sender, EventArgs e)
{
    lblTime.Text = DateTime.Now.ToShortDateString();
}

protected override void InitializeCulture()
{
    if (Request.Form["DropDownList1"] != null)
    {
        UICulture = Request.Form["DropDownList1"];
        Culture = Request.Form["DropDownList1"];
    }
    base.InitializeCulture();
}

印地语的 Resx 文件是:Default.aspx.resx,英语的 Resx 文件是 Default.aspx.en-US.resx

谢谢,对不起我的英语

覆盖默认行为的一种方法是以编程方式设置区域性,就像在 Global.asax 中的 Application_OnStart 中一样,此函数将为每个新的唯一会话 运行 一次。

Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("hi-IN");
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;