ASP.NET Core - Globalization and Localization

Опубликовано: 29 Апрель 2026
на канале: Sarrawy Dev
5,519
like

In this video , we are going to learn how to implement Globalization and Localization in simple steps.

Steps:
Adding Model and Setting Display Properties
Adding Folder to Keep Resource Files
We are going to add a folder with Name “Resource” to stored resources in it.
Adding Resource Files in Folder
We are going to add a resource file in the resources folder. We are going to create 5 resources file
with for storing 5 different culture string in it.
en (English) , hi (Hindi) , ar (Arabic) , de (German) , zh (Chinese)
Adding Dummy Class
Dummy class to group resources files. We are going to add Class with the name
“ApplicationResource”.
Configure Localization in ConfigureServices Method
We are going to Configure localization “Startup.ConfigureServices” Method.
Adds services required for application localization. In ResourcesPath option we are going set
resource folder named “Resources”.
We are going add Cultures which we are going to use in application and set default culture.
Configure Localization middleware in Configure Method.
Adding UseRequestLocalization middleware to the HTTP pipeline (Configure Method).
It should be added below UseRouting Middleware.
Adding Culture Controller
We are going to add Controller which we are going to call from UI to set Culture and store in Cookie
such that it is available for the entire application.
Adding Partial View (“_SetLanguagePartial.cshtml”)
We are going to add Partial View (“_SetLanguagePartial.cshtml”) in Views – Shared folder.
Partial View will have a Dropdown list with culture names for selection of Culture. After selecting
Culture,
We are going to POST Values to Culture Controller Set Language Action Method and set culture
value to Cookie and reload the page.
Calling SetLanguagePartial View in Layout
Adding Customer Controller
Adding Customer View
Output
Accessing Resources in Controller and View
For accessing the value from the resource file, we are going to create a class with Name
LocalizationService in Resources Folder.
LocalizationService class constructor receives an IStringLocalizerFactory type parameter which
will
inject at runtime.
IStringLocalizerFactory Interface: – Represents a factory that creates IStringLocalizer instances.
IStringLocalizer Interface: – Represents a service that provides localized strings.
Register service in ConfigureServices Method in Startup class
Output
Accessing LocalizationService on View
Output
View localization
The IViewLocalizer service provides localized strings for a view. The ViewLocalizer class
implements this Interface and finds the resource location from the view file path.
Values to Access on View Using ViewLocalizer
Output

asp.net core globalization and localization
globalization in asp.net
asp.net core localization
asp.net core localization shared resource
asp.net mvc localization
asp.net core mvc localization
localization in asp.net core 3.1
asp.net localization example
asp.net localization database
asp.net localization best practices
asp net localization and globalization
asp.net localization change language
asp.net localization cultures
asp net core localization and globalization
asp.net access resource file from code behind
asp net add resource file
asp.net add resource file for page
asp.net access resource file
asp.net core localization best practices
asp.net mvc localization best practices
asp.net mvc 5 localization best practices
asp.net localize control
asp.net core localization
asp.net core localization database
asp.net core localization example
asp.net core localization in class library
asp net core localization dataannotations
asp.net mvc localization database
asp.net mvc localize data annotations
asp.net culture setting
asp.net cultureinfo
asp.net culture list
mvc localization best practices
mvc localization resource file
mvc localization example
localization mvc core
localization mvc 5
spring mvc localization
asp mvc localization
mvc application localization
mvc globalization and localization
mvc display attribute localization
mvc data annotation localization
asp mvc localization best practices
mvc core data annotation localization
mvc 5 localization best practices
mvc core localization
localization mvc c#
spring mvc localization in controller
localization dataannotations mvc
asp.net mvc date localization