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);
            }

  • 相关阅读:
    宠物小精灵之收服(dp)
    装箱问题(dp)
    背包问题(采药)
    导弹防御系统(dfs+贪心)
    2018091-2 博客作业
    第一周例行报告
    洛谷 P6378 [PA2010]Riddle
    洛谷 P5782 [POI2001]和平委员会
    洛谷 P3825 [NOI2017]游戏
    POJ 3683 Priest John's Busiest Day
  • 原文地址:https://www.cnblogs.com/wuwei928/p/2771127.html
Copyright © 2011-2022 走看看