ASP.NET Web應用程式中的Web.config配置檔案中修改伺服器的語言設定
阿新 • • 發佈:2020-11-14
在專案中的Web.config配置檔案中,可以對服務端的語言進行設定。
具體操作為:將<globalization culture="語言型別" uiCulture="語言型別"/>新增到Web.config的<system.Web>節點處即可。
1、如果伺服器端的語言設定為en-US,那麼(1002.3).Tostring("c")將返回$1,002.3
2、如果伺服器端的語言設定為en-GB,那麼(1002.3).Tostring("c")將返回£1,002.3
3、如果伺服器端的語言設定為fr-FR,那麼(1002.3).Tostring("c")將返回1,002.3
ToString("c")方法中的"c"表示的是:將數字值渲染成貨幣形式。
程式碼如下:
<system.web> <compilation debug="true" targetFramework="4.8" /> <httpRuntime targetFramework="4.8" /> <!--修改伺服器的語言設定--> <globalization culture="fr-FR" uiCulture="fr-FR"/> <!--<globalization culture="en-GB" uiCulture="en-GB"/>--> <!--<globalization culture="en-US" uiCulture="en-US"/>--> </system.web>