If you want to offer your users the ability to change the UI language , this helper makes all the work for you.

Just add this line to the RegisterGlobalFilters method in global.asax.cs
filters.Add(new LocalizationAttribute()); 

//to change only the UICulture 
filters.Add(new LocalizationAttribute(){ OnlyUI=true}); 

//use "locale" as the query parameter and set the default language to French
filters.Add(new LocalizationAttribute(){ ParamName="locale",Default="fr-FR"}); 

To generate the links which allow the users to change the language
@Html.RouteLink("English", new { lang="en"}) 
@Html.RouteLink("Francais", new { lang="fr"})

Users can change the language simply by adding lang="culture_name" to the query url.

Last edited Feb 14, 2011 at 11:09 AM by mike_sapiens, version 3


No comments yet.