Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

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

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

There is good tutorial with recent update on How to localize asp.net mvc application covering all aspects including DisplayName localization, Validation, using Routing (storing culture name in URL), issues with output cache and so on... Alex Adamyan Blog - While my keyboard gently weeps

We actually went a complete different with overriding the DataAnnotationsMetadaDataProvider. In there you can make sure that the DisplayNameAttribute values are resolved into the correct language. Actually you could even get rid of that attribute and resolve by field names only if that would be any help.

I wrote this article a while ago. It uses a custom view engine. http://blog.oimae.com/2011/02/20/cultured-view-engine-for-mvc/

And another tutorial for different solution

Tutorial: Create ASP.NET MVC localization with language detection

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top