2014-08-27 61 views
4

假設我有一個帶有2個語言文件(法語和德語)的ASP.NET MVC Web應用程序。 對於這個項目,我有2個發佈配置文件(一個是xxx.fr,另一個是xxx.de)。是否可以綁定資源文件X來發布配置文件Y?

是否可以告訴發佈配置文件要部署哪個語言文件? 如果可能的話,怎麼樣?

回答

1

您可以根據發佈配置文件創建Web.config變換。例如,如果您有名爲Foo.pubxml的配置文件,則可以創建名爲Web.Foo.config的轉換。

您可以設置區域性和UI區域性在Web.config中是這樣的:

<configuration> 
    <system.web> 
     <globalization culture="nl" uiCulture="nl"/> 
    </system.web> 
</configuration> 

所以變換是這樣的:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <system.web> 
     <globalization culture="fr" uiCulture="fr" xdt:Transform="Replace"/> 
    </system.web> 
</configuration> 

通過設置文化,正確的資源文件將自動使用,假設您按照Foo.resx作爲默認(未指定的文化)和Foo.fr.resx文化的命名約定爲fr文化。

相關問題