Localization not functioning correctly after deploying Blazor application on Azure

47 Views Asked by At

I have implemented localization in my Blazor application using Visual Studio 2022. On my local machine, everything works perfectly, but when I deploy the application on Azure, the localization functionality doesn't seem to work anymore.

Here's how I'm handling localization in my application:

Program.cs

using System.Globalization;

// ...

CultureInfo culture = new CultureInfo("ja-JP");
CultureInfo.DefaultThreadCurrentCulture = culture;
CultureInfo.DefaultThreadCurrentUICulture = culture;

In my Razor component, I have the following code:

FetchData.razor

@page "/fetchdata"
@using BlazorApp1.Data
@inject WeatherForecastService ForecastService

@using System.Globalization

<p>DateString</p>
<span>@date.ToString("MMM d", CultureInfo.CurrentCulture), @date.ToString("dddd", CultureInfo.CurrentCulture)</span>

@code {
    DateTime date = DateTime.Now.Date;
}

Output of Local sample

Output of Azure hosted sample

I suspect that there might be something specific to the Azure deployment that is causing the localization issue. I've checked the Azure settings, but I couldn't find any obvious reasons for the problem.

Could anyone help me identify why the localization is not working on Azure deployment while it works flawlessly on my local machine? Any insights or troubleshooting tips would be greatly appreciated. Thank you!

0

There are 0 best solutions below