How to localize ASP.NET MVC application?

What would be best practice to localize your ASP.NET MVC application?

I would like to cover two situations:

  • one application deployment in IIS which would handle multiple languages
  • one language/application deployment.

In first situation should you go with some kind of view based thing like, ~/View/EN, ~/View/FI, ~/View/SWE or something different?

What about second case, just application based config via Web.config and point these different languages to different URLs?


Solution 1:

You can also take a look here ASP.NET MVC 2 Localization complete guide and ASP.NET MVC 2 Model Validation With Localization these entires will help you if you working with ASP.NET MVC 2.

Solution 2:

You would localize your ASP.NET MVC application very much in the same way you would a classic ASP.NET Web Form application.

You wouldn't use different pages/views for each language, but each page would support multiple languages using satellite assemblies.

You can look at Matt Hawley's blog entry for more explanation and examples.

Solution 3:

Unfortunately, Matt Hawley's original code doesn't work in the release version of ASP.NET MVC. Check out an updated post: http://blog.eworldui.net/post/2008/10/ASPNET-MVC-Localization-via-View-Engines.aspx

In general, the localization process isn't as smooth in the VS 2008 / ASP.NET MVC world as it is with traditional web forms. http://www.guysmithferrier.com/post/2009/05/Localizing-ASPNET-MVC.aspx

Solution 4:

Have a look at Rob Connery's MvcStore project. He does a screencast showing one way to solve the globalization problem.

http://wekeroad.com/2008/04/24/mvcstore-part-5

Solution 5:

I've never been convinced of handling localization within a form as Elijah suggests - the different lengths and directions can lead to very complex or vary naff looking forms.

I'm only just starting with MVC but taking the decoupling method you would wan to use the same controller regardless of the language (treating language just as a view) - this would then give you /Controller/Action/language/form