MASA Framework’s I18n building block gives your services first-class internationalization support without coupling your business logic to resource management details. Culture detection, resource loading, and string formatting are handled by the framework — you callDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/masastack/MASA.Framework/llms.txt
Use this file to discover all available pages before exploring further.
I18n.T("key") and the right translation is returned for the active request culture.
Installation
Resource File Structure
By convention, locale resources are JSON files named by IETF culture code and placed inside a resources directory. AsupportedCultures.json file (or the name you configure) declares which cultures your application supports:
{0}, {1}, …) are supported for parameterized messages:
Registration
File-Based Resources
Point the framework at your resources directory during startup:Embedded Resources
For library authors or scenarios where you want to ship translations inside the assembly:.csproj:
DCC Remote Configuration
When your translations are managed centrally in the MASA DCC (Distributed Configuration Center), pull them at runtime instead of baking them into the deployment artifact:DccI18nResourceContributor fetches locale strings from DCC and keeps them synchronized with configuration-change notifications — no restart required to deploy translation updates.
ASP.NET Core Middleware
AddUseMasaLocalization() to your middleware pipeline to automatically detect the request’s preferred culture and set CultureInfo.CurrentCulture / CultureInfo.CurrentUICulture:
Accept-Language header, a culture query parameter, and a culture cookie — in that order of precedence.
Translating Strings
Static I18n Class
The I18n static class provides ambient access to translations without requiring dependency injection:
Typed Resource Access with I18n<TResource>
For larger applications, group related translations under a strongly typed resource class to avoid magic-string keys:
Configuration Reference
CultureSettings controls the I18n engine’s behaviour:
| Property | Default | Description |
|---|---|---|
ResourcesDirectory | "Resources" | Relative or absolute path to locale JSON files |
SupportCultureFileName | "supportedCultures.json" | File that lists accepted culture codes |
Internal Architecture
I18nResource
I18nResource
Represents a single loaded resource file. Holds the culture code and a key-value dictionary of translations.
I18nResourceDictionary
I18nResourceDictionary
The in-memory store that aggregates all loaded
I18nResource instances and services key lookups. It is populated at startup and updated on remote-config push events when using DCC.DccI18nResourceContributor
DccI18nResourceContributor
Implements the resource contributor contract for DCC. Subscribes to DCC change events and refreshes the dictionary when a locale file is updated centrally.