Skip to content

Blazor Localization Roadmap? #22178

Closed
Closed
@mysteryx93

Description

@mysteryx93

According to this article,

A limited set of ASP.NET Core's localization scenarios are currently supported: IStringLocalizer<> is supported in Blazor apps.

IStringLocalizer is supported, and that's about it. The problem with IStringLocalizer is that

  1. It requires a separate resource file for each class -- which can grow exponentially in large projects
  2. Changing a value in the default language requires editing all other languages, very messy and prone to errors
  3. Some localized strings are shared between classes

I tried adding localization to validation attributes.

First with a custom DisplayNameAttribute with built-in localization. DataAnnotations Validation doesn't read this attribute though.

Then with Display(Name="FirstName", Type=typeof(Resources)), but it made the application crash (at least when the resource is in a different project).

So it seems there's really not much localization support at all for now... better leave out localization altogether.

I don't really need localization anyway, but wanted to structure my code in clean way that would make allowing localization easy. What are the plans for Blazer localization support in .NET 5? I'd be better to structure the code in a way that would be compatible for that.

IStringLocalizer really doesn't seem like a good solution... does it even work to localize DisplayAttribute for validation messages?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions