Introduction
In today’s globalized digital ecosystem, web applications and APIs must cater to users across multiple countries, cultures, and languages. Whether you’re building a content management system, an e-commerce site, or a customer support portal, multi-language (or localization) support is no longer optional — it’s essential.
In this article, we’ll learn how to handle multi-language content in REST APIs using ASP.NET Core, with clear examples, architecture workflow, and best practices to maintain clean, scalable localization logic.
What is Multi-Language Content Handling?
Multi-language content handling means your API can serve the same data in different languages based on user preferences or system configuration.
For example
GET /api/products/101?lang=en
→ { "id": 101, "name": "Wireless Mouse" }
GET /api/products/101?lang=fr
→ { "id": 101, "name": "Souris sans fil" }
The key goal is to separate content from language, making the system easy to scale and maintain.
Technical Workflow (Flowchart)
flowchart TD
A[Client Request with 'lang' Parameter] --> B[API Middleware Detects Language]
B --> C[Load Language Resource (DB or JSON file)]
C --> D[Fetch Content in Preferred Language]
D --> E[Fallback to Default Language if Not Found]
E --> F[Return Localized JSON Response]
Approaches for Multi-Language Content
There are two common strategies to handle multi-language content in APIs:
1. Database Localization
You store content in multiple languages in the database.
Example Table
| ProductId | Language | Name | Description |
|---|---|---|---|
| 101 | en | Wireless Mouse | Ergonomic mouse design |
| 101 | fr | Souris sans fil | Souris ergonomique |
Pros
Centralized management
Easy to update via admin panel
Good for dynamic content
Cons
Slightly complex queries
Needs proper caching
2. File-Based Localization (Resource Files)
For static text (like labels, validation messages, etc.), use .resx or JSON resource files.
Example
/Resources
├── SharedResources.en.json
├── SharedResources.fr.json
SharedResources.en.json
{"Welcome": "Welcome to our application!","Logout": "Logout"}SharedResources.fr.json
{"Welcome": "Bienvenue dans notre application!","Logout": "Se déconnecter"}Step-by-Step Implementation in ASP.NET Core
Step 1: Add Localization Dependencies
Add this package to your project:
dotnet add package Microsoft.Extensions.Localization
Step 2: Configure Localization in Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddLocalization(options => options.ResourcesPath = "Resources");
builder.Services.Configure<RequestLocalizationOptions>(options =>
{
var supportedCultures = new[] { "en", "fr", "de", "hi" };
options.SetDefaultCulture("en");
options.AddSupportedCultures(supportedCultures);
options.AddSupportedUICultures(supportedCultures);
});
builder.Services.AddControllers();
var app = builder.Build();
var localizationOptions = app.Services.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(localizationOptions.Value);
app.MapControllers();
app.Run();
Step 3: Create a Resource File
Create a folder named Resources and add the following files:

Join the conversation! Your thoughts help the community grow.