Modern applications are used by people from different countries, cultures, and languages.
ASP.NET Core provides built-in support for making your application culture- and language-aware.
What is Globalization?
Globalization is the process of designing an application to support multiple cultures.
It deals with:
Date & time formats
Number formats
Currency
Culture-specific rules
Example:
US Date → 12/31/2026
India Date → 31/12/2026
Currency → $100 vs ₹100
What is Localization?
Localization means adapting the application to a specific language or region.
It focuses on:
Example:
English → “Welcome”
French → “Bienvenue”
Spanish → “Bienvenido”
Difference Between Globalization and Localization
| Feature | Globalization | Localization |
|---|
| Purpose | Culture support | Language support |
| Scope | Formats & rules | Text & UI |
| Example | Date, currency | Messages, labels |
Real-World Scenario
An e-commerce website supports:
English (US)
French (France)
Arabic (Saudi Arabia)
Users see:
Culture and Language in ASP.NET Core
ASP.NET Core uses:
Example culture codes:
Enable Localization in ASP.NET Core
Step 1: Add Localization Services
builder.Services.AddLocalization(options =>
{
options.ResourcesPath = "Resources";
});
Step 2: Configure Supported Cultures
using Microsoft.AspNetCore.Localization;
using System.Globalization;
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("fr-FR"),
new CultureInfo("ar-SA")
};
var localizationOptions = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};
app.UseRequestLocalization(localizationOptions);
How Culture is Selected
ASP.NET Core determines culture from:
Query string
Cookies
Request headers (Accept-Language)
Example Header
Accept-Language: fr-FR
Localization Using Resource Files (.resx)
Step 1: Create Resources Folder
Resources/
└── Controllers.HomeController.en-US.resx
└── Controllers.HomeController.fr-FR.resx
Step 2: Add Resource Keys
English (en-US)
| Key | Value |
|---|
| WelcomeMessage | Welcome to our store |
French (fr-FR)
| Key | Value |
|---|
| WelcomeMessage | Bienvenue dans notre magasin |
Using Localized Text in Controller
using Microsoft.Extensions.Localization;
[ApiController]
[Route("api/home")]
public class HomeController : ControllerBase
{
private readonly IStringLocalizer<HomeController> _localizer;
public HomeController(IStringLocalizer<HomeController> localizer)
{
_localizer = localizer;
}
[HttpGet]
public IActionResult Get()
{
return Ok(_localizer["WelcomeMessage"]);
}
}
Request Example (Real-Time)
English Request
GET /api/home
Accept-Language: en-US
Response
"Welcome to our store"
French Request
GET /api/home
Accept-Language: fr-FR
Response
"Bienvenue dans notre magasin"
Globalization Example (Date & Currency)
[HttpGet("date")]
public IActionResult GetDate()
{
return Ok(new
{
Date = DateTime.Now.ToString("D"),
Price = (1234.50).ToString("C")
});
}
Output by Culture
| Culture | Date | Currency |
|---|
| en-US | January 1, 2026 | $1,234.50 |
| fr-FR | 1 janvier 2026 | 1 234,50 € |
| ar-SA | ١ يناير ٢٠٢٦ | ر.س 1,234.50 |
Using Query String for Culture
GET /api/home?culture=ar-SA
Interview-Ready Questions & Answers
Q1: What is globalization?
Globalization prepares an application to support multiple cultures and formats.
Q2: What is localization?
Localization adapts the application content to a specific language or region.
Q3: How does ASP.NET Core select culture?
Through query string, cookies, and request headers.
Q4: What are .resx files?
Resource files that store translated strings for different languages.
Summary
| Concept | Purpose |
|---|
| Globalization | Culture formatting |
| Localization | Language translation |
| Resource files | Store translations |
| Request headers | Select language |
| ASP.NET Core | Built-in support |