Mafesoft.Localization.Extensions
4.1.0
See the version list below for details.
dotnet add package Mafesoft.Localization.Extensions --version 4.1.0
NuGet\Install-Package Mafesoft.Localization.Extensions -Version 4.1.0
<PackageReference Include="Mafesoft.Localization.Extensions" Version="4.1.0" />
<PackageVersion Include="Mafesoft.Localization.Extensions" Version="4.1.0" />
<PackageReference Include="Mafesoft.Localization.Extensions" />
paket add Mafesoft.Localization.Extensions --version 4.1.0
#r "nuget: Mafesoft.Localization.Extensions, 4.1.0"
#:package Mafesoft.Localization.Extensions@4.1.0
#addin nuget:?package=Mafesoft.Localization.Extensions&version=4.1.0
#tool nuget:?package=Mafesoft.Localization.Extensions&version=4.1.0
Mafesoft.Localization.Extensions
Microsoft.Extensions integration of Mafesoft.Localization:
registers the LocalizationManager in the dependency injection and provides IStringLocalizer,
IStringLocalizer<T> and IStringLocalizerFactory backed by its vocabularies. Every consumer of
Microsoft.Extensions.Localization (DataAnnotations, IViewLocalizer, Blazor components, third-party UI libraries)
reads the same vocabularies.
Target frameworks: .NET 10, .NET 8, .NET Standard 2.0.
Quick start
dotnet add package Mafesoft.Localization.Extensions
using Mafesoft.Localization.Extensions;
builder.Services.AddLocalizationManager(options =>
{
options.ServiceProvider = new MyVocabularyServiceProvider();
options.Culture = new CultureInfo("it-IT");
})
.AddStringLocalizer();
public class HomeController(IStringLocalizer<HomeController> localizer) : Controller
{
public IActionResult Index() => View(model: localizer["Welcome"].Value);
}
- A missing key returns the key itself with
ResourceNotFound = true, and the provider is notified (AddOrUpdateTermAsync), exactly likeLocalizationManager.Instance[key]. localizer["Format", arg]formats the value with the current culture.GetAllStrings()returns the vocabulary of the current culture.- With
AddStringLocalizer(o => o.UseTypeNamePrefix = true)the keys are prefixed with the type name:IStringLocalizer<HomeController>["Title"]readsHomeController.Title. Off by default.
With ASP.NET Core MVC, AddDataAnnotationsLocalization() uses it to translate [Display(Name = "...")] and the
validation messages.
Differences from the resx localizer
Replacing AddLocalization() with AddLocalizationManager(...).AddStringLocalizer() keeps the code that uses
IStringLocalizer<T>, IViewLocalizer, IHtmlLocalizer<T> and DataAnnotations unchanged, but the behaviour is not
the same as the resx-based ResourceManagerStringLocalizer:
resx (AddLocalization()) |
Mafesoft.Localization | |
|---|---|---|
| Culture | CultureInfo.CurrentUICulture, per request with UseRequestLocalization() |
One culture for the whole application, changed with SetCulture. With FollowCurrentUICulture = true: CultureInfo.CurrentUICulture, per request like resx |
| Keys | One resource file per type or view (Controllers.HomeController.it.resx) |
One vocabulary per culture, shared by every localizer. With UseTypeNamePrefix the key is TypeName.Key (Type.Name, without namespace) or baseName.Key for the views |
| Parent cultures | it-IT falls back to it and then to the neutral resources |
No fallback, includeParentCultures is ignored |
| Missing key | Returns the key, ResourceNotFound = true |
Same, and the provider is notified (AddOrUpdateTermAsync) |
| Source of the strings | .resx files embedded in the assembly |
The IVocabularyServiceProvider (the resx strings must be moved there) |
One culture per application by default. Without
FollowCurrentUICulturethe localizer does not readCultureInfo.CurrentUICulture, soUseRequestLocalization(), the culture cookie andAccept-Languagehave no effect and every user sees the same language. On a server enable it (each culture is loaded once and cached):builder.Services.AddLocalizationManager(options => { options.ServiceProvider = new MyVocabularyServiceProvider(); options.FollowCurrentUICulture = true; }) .AddStringLocalizer(); app.UseRequestLocalization(o => o.AddSupportedCultures("it-IT", "en-US").AddSupportedUICultures("it-IT", "en-US"));Shared keys. Two resx files that translate the same key differently collide in the vocabulary: rename the keys or enable
UseTypeNamePrefix.The default validation messages of DataAnnotations (without
ErrorMessage) are not translated, as with resx.
Links
Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Mafesoft.Localization (>= 4.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Localization.Abstractions (>= 8.0.0)
-
net10.0
- Mafesoft.Localization (>= 4.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Localization.Abstractions (>= 10.0.0)
-
net8.0
- Mafesoft.Localization (>= 4.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Localization.Abstractions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.4.0 | 83 | 11/19/2026 |
| 4.3.0 | 97 | 11/14/2026 |
| 4.1.1 | 90 | 11/13/2026 |
| 4.1.0 | 269 | 11/11/2026 |
| 4.1.0-rc.1 | 59 | 11/10/2026 |