【问题标题】:what event(place) should i use for change culture and calendar in mulilanguage web site?我应该使用什么事件(地点)来改变多语言网站中的文化和日历?
【发布时间】:2011-10-23 10:51:01
【问题描述】:

我有一个多语言网站...
我在 Visual Studio 中为语言(en + 我的语言)制作了两个文件夹,并为每个文件夹制作了我的网站!
对于一个语言网站,我有一个课程可以改变文化和日历以适应我的文化,并在 Global.asax 中调用该课程,如下所示:

protected void Application_BeginRequest(object sender, EventArgs e)
{
    myLanCultureAndCalendar.SetCultureAndCalendar();
}

但是对于多语言网站,我可以对该课程做些什么呢?
意思是我应该在哪里为每种语言调用该类?
my pages are base on master and content pages

如你所知global.asax Application_BeginRequest runs First -> after that we have content page_Load -> and at last Master page_Load

【问题讨论】:

    标签: c# asp.net culture global.asa


    【解决方案1】:

    我认为您必须在 Application_BeginRequest 事件中实现该类......就像这样......

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        String language = Request.UserLanguages[0];
        if (language.Length > 1) language = language.Substring(0, 2);
        .......
        ........
    
    }
    

    我建议您通过此链接查看more info

    希望对你有帮助..

    【讨论】:

    • 感谢您的回答/但是否有其他方法不使用 UserLanguages?
    • 还有其他想法吗?在这个问题上使用用户的机器语言似乎不好/我们可以使用会话或类似的东西吗?
    猜你喜欢
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 2021-07-12
    • 1970-01-01
    • 2013-12-18
    • 2018-02-14
    • 2011-07-26
    相关资源
    最近更新 更多