4

我正在努力使用 C# 全球化项目

我尝试使用 UICulture 属性将某些项目格式(如数字格式、货币格式...)转换为使用下面的代码的不同文化。实际上工作正常,但现在,我需要添加电话掩码、邮政编码。任何帮助将不胜感激。

//this is the index.cshtml file 

@using System.Globalization
@using System.Threading

 @{
      Layout = null;
      if (!Request.QueryString["lang"].IsEmpty())
   {
    Culture = UICulture = Request.QueryString["lang"];
   }
 }

   <!DOCTYPE html>

   <html>
   <head>
   <meta name="viewport" content="width=device-width" />
   <title>Index</title>
 </head>
  <body>

          <a href="@Url.Action("Change" , "Demo" , new { lang = 
            "en"})">English</a>
          <a href="@Url.Action("Change" , "Demo" , new { lang = 
            "fr"})">French</a>
          <a href="@Url.Action("Change" , "Demo" , new { lang = 
            "de"})">Germany</a>
          <a href="@Url.Action("Change" , "Demo" , new { lang = 
            "ja"})">Japan</a>
          <a href="@Url.Action("Change" , "Demo" , new { lang = "pt- 
             BR"})">Brasil</a><br />

      @{ int number = 123456;}
      @{ double percent = 12.34;}

              Number format : @number.ToString("N")
              <br />
              Currency format : @number.ToString("C")
              <br />
              Percent format : @percent.ToString("P")
              <br />
              Date format : @DateTime.Now.ToString("D")
              <br />



  </body>
  </html>
4

0 回答 0