Skip to content

culture parameter being ignored in razor component (Blazor WebAssembly) #1089

@cyl1d3

Description

@cyl1d3

I'm currently having the following issue:

I'm using Humanizer in a razor component running in a WebAssembly Blazor project. My component has a class Localizer which provides a CultureInfo. When passing a DateTime through the Humanizer, I always get the English result. Here's the code snippet:

<small class="pr-2">
    <abbr title="@item.Date.ToString(Localizer.GetCulture())">
        @item.Date.Humanize(culture: Localizer.GetCulture())
    </abbr>
</small>

The Localizer is not the problem, as the Date format in the tooltip is correctly changed when I change the culture:

Culture en-US:
image

Culture de-DE:
image

Some additional information:
The same issue happens with TimeSpan, but non time related functions seem unaffected e.g. 5.ToWords(culture: Localizer.GetCulture()) works just as expected.

Upon further analysis, the problem seems to occur while loading the resource string:
image

The culture has been correctly passed down, but loading the resource always returns the english string.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions