Mafesoft.Localization.Blazor
4.1.0
See the version list below for details.
dotnet add package Mafesoft.Localization.Blazor --version 4.1.0
NuGet\Install-Package Mafesoft.Localization.Blazor -Version 4.1.0
<PackageReference Include="Mafesoft.Localization.Blazor" Version="4.1.0" />
<PackageVersion Include="Mafesoft.Localization.Blazor" Version="4.1.0" />
<PackageReference Include="Mafesoft.Localization.Blazor" />
paket add Mafesoft.Localization.Blazor --version 4.1.0
#r "nuget: Mafesoft.Localization.Blazor, 4.1.0"
#:package Mafesoft.Localization.Blazor@4.1.0
#addin nuget:?package=Mafesoft.Localization.Blazor&version=4.1.0
#tool nuget:?package=Mafesoft.Localization.Blazor&version=4.1.0
Mafesoft.Localization.Blazor
Blazor extension of Mafesoft.Localization: translate the
components with Binding.Translate. Works with Blazor Server and Blazor WebAssembly.
Target frameworks: .NET 10, .NET 8.
Quick start
dotnet add package Mafesoft.Localization.Blazor
Blazor Server: register the manager.
builder.Services.AddBlazorLocalizationManager(options =>
{
options.ServiceProvider = new MyVocabularyServiceProvider();
options.Culture = new CultureInfo("it-IT");
options.FollowCurrentUICulture = true; // since 4.1.0: one language per circuit
});
app.UseRequestLocalization(o => o.AddSupportedCultures("it-IT", "en-US").AddSupportedUICultures("it-IT", "en-US"));
With FollowCurrentUICulture each circuit uses the culture of the request that opened it (query string, culture
cookie or Accept-Language); to switch language write the culture cookie and reload the page. Without it the
culture is shared by all users and changed with SetCulture.
Blazor WebAssembly: initialize the manager asynchronously in Program.cs.
await LocalizationManager.InitAsync(new MyVocabularyServiceProvider(), new CultureInfo("it-IT"));
builder.Services.AddSingleton(LocalizationManager.Instance);
Translate in a component:
@using Mafesoft.Localization.Blazor.Bindings
<h1>@Binding.Translate("Title", "#Title")</h1>
To refresh a component when the culture changes, subscribe LocalizationManager.Instance.CultureChanged and call
InvokeAsync(StateHasChanged).
Links
Licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Mafesoft.Localization (>= 4.1.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
-
net8.0
- Mafesoft.Localization (>= 4.1.0)
- Microsoft.Extensions.DependencyInjection.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.