zoukankan      html  css  js  c++  java
  • MVC 读配置文件 多语言

    配置文件:

      <appSettings>
        <add key="Language" value="sv"/>
      </appSettings>

    在路由里面加入一下代码:

    protected void Application_AcquireRequestState(object sender, EventArgs e)
            {
                var langName = WebConfigurationManager.AppSettings["Language"];

                if (string.IsNullOrEmpty(langName))
                {
                    if (HttpContext.Current.Request.UserLanguages != null && HttpContext.Current.Request.UserLanguages.Length != 0)
                    {
                        langName = HttpContext.Current.Request.UserLanguages[0];
                    }
                }

                var cultureInfo = new CultureInfo(langName);

                System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;
                System.Threading.Thread.CurrentThread.CurrentUICulture = cultureInfo;
                System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(cultureInfo.Name);
                System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(cultureInfo.Name);
            }

  • 相关阅读:
    2019省赛训练组队赛4.9周二 2017浙江省赛
    #Leetcode# 49. Group Anagrams
    #Leetcode# 57. Insert Interval
    POJ 2195 Going Home
    HDU 2255 奔小康赚大钱
    HDU 1083 Courses
    HDU 2063 过山车
    POJ 3041 Asteroids
    指针的妙处
    jzoj 6273. 2019.8.4【NOIP提高组A】欠钱 (money)
  • 原文地址:https://www.cnblogs.com/wuwei928/p/2771127.html
Copyright © 2011-2022 走看看