Description
Describe the bug
In a Blazor Server application, I am updating page data from a background service. This update from the service ultimately ends up calling InvokeAsync(StateHasChanged)
in the page. The page is also using IStringLocalizer<T>
to provide translations for table headers. When the application runs, the user can select the current culture (e.g. German (de-DE)), and the table is displayed with translated headers. As soon as the background updates begin, the German culture is ignored, and the page is rendered using English (en-US) resources.
My expectation is that calling StateHasChanged
will use the proper resources for rendering the page.
To Reproduce
I have created a small application that reproduces this scenario:
https://github.com/DaveNay/Service_Localization_Debugging
In the sample application, you can switch to the FetchData page, and then change the culture to German. You will see that the page is rendered with the de-DE resources. 10 seconds after the application starts, the background updates will begin. As soon as the updates begin, the page is rendered using en-US resources.
Exceptions (if any)
None
Further technical details
- .Net 5.0 (also .Net Core 3.1)
- Visual Studio Pro 16.8.2
- Windows 10 Enterprise 1809
- dotnet_info.txt