Globalization in ASP.Net MVC 3

前端 未结 4 1049
旧时难觅i
旧时难觅i 2020-12-12 16:51

I am trying to achieve globalization/localization in my MVC 3 application. I don\'t want different Views for each language. Please suggest how I can proceed. Any supported l

4条回答
  •  一个人的身影
    2020-12-12 17:23

    To add some details to Martin Booth's great answer (in case his MediaFire link might disappear), here is how I idid it:

    I've used two files, since I only need English and German ("de") for now:

    enter image description here

    For the properties of each file, I had to manually enter the Custom Tool as well as the Custom Tool Namespace values, for each file:

    enter image description here

    enter image description here

    And finally, I entered the following inside the root Web.Config file, below the section:

    
    

    Of course I've also added the namespace directive in the Web.Config file below the Views folder (i.e. not the root one), as Martin describes:

    
    

    And then I could finally access the resources strongly-typed in my (partial) Razor view:

    @ViewResources.Test1

    BTW: this worked with MVC 4, too, not only MVC 3.

提交回复
热议问题