Setup a multilingual site using ASP.NET MVC5

A multilingual site should translate the following:

  • Date and time formatting
  • Currency
  • Text resources: lables, buttons, validation messages, tooltips

It must be easy to switch languages.
It should be relatively easy to add more languages.

An example ASP.NET MVC 5 project can be downloaded here



1. Routing

Add lang parameter to routes in RegisterRoutes method of RouteConfig class. Set constraints to enabled languages. Set default language in default route.

2. Activate culture

Culture can be activated by two different ways: in controller’s Initialize method or by using filter attribute.

2.1 Initialize method

Every controller that needs language data must Initialize culture in it’s Initialize method. Let’s create a base controller class and override Initialize method in it:

All the other language-dependent controllers must be inherited from this base controller class.

2.2 Language localization filter attribute

Create a LocalizationAttribute class inherited from ActionFilterAttribute:


Add FilterConfig class to App_Start folder and add created LocalizationAttribute in it.


Use [Localization] attribute on every controller that needs language information.

3. Create translation resources

3.1 Add App_LocalResources folder

Add Asp_Net folder App_LocalResources to project. Resource files will be placed in it.


3.2 Add resource files

Add language resource files GlobalRes.resx for the default language (English in my case) and files for other languages like to App_LocalResources folder. Two letters in the file name must be region info ISO (country code) as defined in RegionInfo.TwoLetterISORegionName Property. The complete list of region codes can be found at the Wikipedia page ISO 3166-1 alpha-2.


3.3 Set resource files properties

  • Resource type: String
  • Build Action: Embedded Resource
  • Custom Tool: PublicResXFileCodeGenerator
  • Access Modifier: Public


3.4 Add translations for all string resources

3.5 Add reference to resource namespace to Razor in web.config

Make sure you have added this namespace to the ~/Views/web.config file and not to the standard ~/Web.config file:

3.6 Use translated resources in code

DisplayAttribute to define translation for a model’s class name:
[Display(Name = "Name", ResourceType = typeof(GlobalRes))]

Use ErrorMessageResourceType and ErrorMessageResourceName for validation messages:
ErrorMessageResourceType = typeof(GlobalRes), ErrorMessageResourceName = "This_field_is_required")

Use GlobalRes.resname references in Razor files:


4. Switch between languages

Use the following helper class that produces language links based on routing. It creates UrlHelper extension method.

Use language links in for instance _Layout.cshtml

5. Format some numbers as another currency then current culture

System.Globalization.NumberFormatInfo class provides culture-specific information for formatting and parsing numeric values. It’s quite easy to use :

6. Format all numbers as another currency then current culture

7. Add new language

  • Add new language code in routing map
  • Add new resource file and translate all strings in it
  • Add new language switch-link to views


  • Sandeep Pawar

    Wow, fantastic article to implement multilingual in MVC 5.
    Hats off to you boss.

    I followed each step as it is and it work as expected.
    No flaws, no errors….

    Thanks for sharing such nice article

  • Catherine

    Today my app that was using this method for switching languages could no longer detect the namespace App_LocalResources. After looking around for a solution I uninstalled VS 2015, installed VS 2017 and remade my project fresh. This fixed the issue but the language switching links no longer work! I think this has to do with VS 2017 updates. If anyone else has this problem or knows the solution it would be appreciated.

  • Language switching links from this blogpost are just normal anchor tags. They can’t stop working because of updates in VS. May be you have got problems with routing. Anchor adds a /{lang}/ language route to URL.
    You do not have to put resource files into App_LocalResources. This is just default location. But recourse files can be placed in any other folder/namespace and even in a separate project or library. Namespace detection is not a VS feature it is a nature of .NET. It can not stop working because of VS updates.

  • Kevin

    This tutorial provided great assistance to my project.. thanks a lot.
    Is it possible to translate the URL links on the browser

  • Raja

    Thank you.I followed your steps as it is and it works great. Thanks once again .
    But not able to refer on external .js file. Can you have any ideas ?

  • mikhailt

    Not sure I understand your question. But you can include any external JavaScript files in to MVC. Just in any view inside script tag as in normal HTML.

  • mikhailt

    Translate URL means redirect to another URL. Yes. It is possible with MVC routing.

  • Raja

    My Need is :
    $(“#mdlbtnSubmit”).click(function (event) {
    alert(“Event Rised”);
    //instead of above alert() ,i need alert(‘@GlobalRes.keyEventRised’);
    //specially in external “something.js” file not in any view inside script.
    Thanks Again

  • As far as I understand you need a translated text from server side shown in a JavaScript on client side. And JavaScript script is external. Well it is possible when external “something.js” refers to a some string variable. And this variable is redefined in your view on server side.

    In something.js:

    and in view define variable

    var StringVar= @GlobalRes.keyEventRised;

  • Abz

    Thank you.I followed your steps as it is and it works there any way to add Cookies ,if its yes where and how ?!

  • Hussain Rauf

    Good Job. This article is very helpful I must say. Just one thing, how could we use different CSS based on culture?

  • Paul Binder Jr

    Good tutorial, but I would think Language and Culture do not go hand-in-hand. You could be a Spanish speaking person in Canada or an English speaking person in Japan. It seems like a mistake to change culture based on language.

  • karimla131

    great job, i have a question how can i force the default culture appear in the URL