BlazorServerUrlRequestCultureProvider 1.0.0

Install-Package BlazorServerUrlRequestCultureProvider -Version 1.0.0
dotnet add package BlazorServerUrlRequestCultureProvider --version 1.0.0
<PackageReference Include="BlazorServerUrlRequestCultureProvider" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorServerUrlRequestCultureProvider --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BlazorServerUrlRequestCultureProvider, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorServerUrlRequestCultureProvider as a Cake Addin
#addin nuget:?package=BlazorServerUrlRequestCultureProvider&version=1.0.0

// Install BlazorServerUrlRequestCultureProvider as a Cake Tool
#tool nuget:?package=BlazorServerUrlRequestCultureProvider&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Startup.cs

    public class Startup
    {
        // ...

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStaticFiles();

            var supportedCultures = new[]
            {
                new CultureInfo("en"),
                new CultureInfo("fr"),
            };

            var options = new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("en"),
                // Formatting numbers, dates, etc.
                SupportedCultures = supportedCultures,
                // UI strings that we have localized.
                SupportedUICultures = supportedCultures
            };

            app.UseUrlRequestLocalization(options);

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapBlazorHub();
                endpoints.MapFallbackToPage("/_Host");
            });
        }
    }

Index.razor

@page "/"
@page "/fr"
@page "/en"
@inject IStringLocalizer<App> Localizer


<h1>@Localizer["Hello, world!"]</h1>

@Localizer["Welcome to your new app."]

Counter.razor

@page "/en/counter"
@page "/fr/compteur"

@inject IStringLocalizer<App> Localizer

<h1>@Localizer["Counter"]</h1>

<p>@Localizer["Current count:"] @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">@Localizer["Click me"]</button>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }
}
  • .NETCoreApp 3.1

    • No dependencies.

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
1.0.0 713 10/1/2020