Tag Archives: Multilingualism in ASP.NET MVC 4

Multilingualism in ASP.NET MVC 4

Multilingualism is the use of two or more languages, either by an individual speaker or by a community of speakers. Multilingual speakers outnumber monolingual speakers in the world’s population. Multilingualism is becoming a social phenomenon governed by the needs of globalization and cultural openness.Hosting Tutorial :: Multilingualism in ASP.NET MVC 4

Multilingualism in computing can be considered part of a continuum between internationalization and localization. Due to the status of English in computing, software development nearly always uses it (but see also Non-English-based programming languages), so almost all commercial software is initially available in an English version, and multilingual versions, if any, may be produced as alternative options based on the English original.

ASP.NET MVC 4 Multilingual Website

Hosting Tutorial :: Multilingualism in ASP.NET MVC 4 | In this post, I explain how to create a multilingual website in asp.net mvc4. In today’s competitive web world, not having a multilingual website implies you are ignoring the needs of a major part of the world population. So, This is most important to have multilingual website to  reach  more customer and thus increase revenue. Here I am going to explain how we can do our website multilingual in asp.net  mvc application easily.

Create New Project.

Go to File > New > Project > Select asp.net MVC4 web application > Entry Application Name > Click OK > Select Basic > Select view engine Razor > OK

Add Resource File for different languages

Here I have added 3 resource file for 3 languages

  1. Resource.resx – This is the default resource file associated with the English language.
  2. Resource.es.resx – This resource file is associated with the Spanish language.
  3. Resource.bn.resx – This resource file is associated with the Bengali language.

Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > Add New > Select Resource File under General > Enter File name > Add.

[N.B: Don’t forget to change all the resource files Access Modifier to Public ]

Hosting Tutorial :: Multilingualism in ASP.NET MVC 4

Create a Class (Module)

Go to Solution Explorer > Right Click on Modules folder > Add > Class > Enter Class name > Add.

Add an another class for Manage Languages property & function.

Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > Class > Enter Class Name > Add.

Add an another class (inherit Controller) Where we will override BeginExecuteCore.

Go to Solution Explorer > Right Click on Project name form Solution Explorer > Add > Class > Enter Class Name > Add.
Here I have added this for check & set language each time any request execute.

Add a new Controller.

Go to Solution Explorer > Right Click on Controllers folder form Solution Explorer > Add > Controller > Enter Controller name > Select Templete “empty MVC Controller”> Add.

Add new action into your controller for Get Action method.

Here I have added “Index” Action into “Home” Controller. Please write this following code.

Add view for the Action & design.

Right Click on Action Method (here right click on form action) > Add View… > Enter View Name > Select View Engine (Razor) > Check “Create a strong-typed view” > Select your model class > Add.
[N:B:Please Rebuild solution before add view.]

Add another action into your controller for POST Method

Here I have added “Index” Action into “HomeController” Controller for POST Action. Please write this following code.

Add another action into your controller for Change Language

Here I have added “ChangeLanguage” Action into “HomeController” Controller for Change Language. Please write this following code

Modify Layout Page for Show Available Languages (Language Switcher).

Aagni Yashu