Toolbelt.Blazor.LocalizedDataAnnotationsValidator 1.0.0

The Data Annotations Validator Component for Blazor to localize validation error messages, based on "Microsoft.Extensions.Localization".

There is a newer version of this package available.
See the version list below for details.
Install-Package Toolbelt.Blazor.LocalizedDataAnnotationsValidator -Version 1.0.0
dotnet add package Toolbelt.Blazor.LocalizedDataAnnotationsValidator --version 1.0.0
<PackageReference Include="Toolbelt.Blazor.LocalizedDataAnnotationsValidator" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Toolbelt.Blazor.LocalizedDataAnnotationsValidator --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Toolbelt.Blazor.LocalizedDataAnnotationsValidator, 1.0.0"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

Localized Data Annotations Validator Component for Blazor

Summary

This is the Data Annotations Validator Component for Blazor to localize the validation error messages, based on Microsoft.Extensions.Localization.

Live Demo - https://demo-blazor-localized-data-annotations-validator.azurewebsites.net/

fig1

[NOTICE]

This component will works fine on "Server-side Blazor", not "Client-side Blazor" at this time.

The supporting of Microsoft.Extensions.Localization based localization on Client-side Blazor is weak, therefore it will need some hacks. (see also: https://dev.to/5argon/comment/gdch)

Another way, "Blazor I18n Text" service will work fine on both Server-side Blazor and Client-side Blazor. However, it is not integrated Microsoft.Extensions.Localization based localization at this time.

How to use?

Step 1. Setup "IStringLocalizer" infrastructure on your Blazor app

See also:

Of course, you should create resource files (.resx) for data annotation validation error messages, too.

Step 2. Install this package

Like this:

> dotnet add package Toolbelt.Blazor.LocalizedDataAnnotationsValidator

Step3. Replace the data annotations validator component

Rewrite the implementation of the validation on your app.

At first, open the "Toolbelt.Blazor.Forms" namespace, in the _Imports.razor.

...
@using Toolbelt.Blazor.Forms

Next, replace the DataAnnotationsValidator to LocalizedDataAnnotationsValidator.

For example, in your .razor file, rewrite it from:

<EditForm Model="..." ...>
  <DataAnnotationsValidator />
  ...

to:

<EditForm Model="..." ...>
  <!-- ↓ Replace this component! -->
  <LocalizedDataAnnotationsValidator />
  ...

That's all!

Sample Source Code

You can get the source code of Live Demo site from this repository.

License

Mozilla Public License Version 2.0

Localized Data Annotations Validator Component for Blazor

Summary

This is the Data Annotations Validator Component for Blazor to localize the validation error messages, based on Microsoft.Extensions.Localization.

Live Demo - https://demo-blazor-localized-data-annotations-validator.azurewebsites.net/

fig1

[NOTICE]

This component will works fine on "Server-side Blazor", not "Client-side Blazor" at this time.

The supporting of Microsoft.Extensions.Localization based localization on Client-side Blazor is weak, therefore it will need some hacks. (see also: https://dev.to/5argon/comment/gdch)

Another way, "Blazor I18n Text" service will work fine on both Server-side Blazor and Client-side Blazor. However, it is not integrated Microsoft.Extensions.Localization based localization at this time.

How to use?

Step 1. Setup "IStringLocalizer" infrastructure on your Blazor app

See also:

Of course, you should create resource files (.resx) for data annotation validation error messages, too.

Step 2. Install this package

Like this:

> dotnet add package Toolbelt.Blazor.LocalizedDataAnnotationsValidator

Step3. Replace the data annotations validator component

Rewrite the implementation of the validation on your app.

At first, open the "Toolbelt.Blazor.Forms" namespace, in the _Imports.razor.

...
@using Toolbelt.Blazor.Forms

Next, replace the DataAnnotationsValidator to LocalizedDataAnnotationsValidator.

For example, in your .razor file, rewrite it from:

<EditForm Model="..." ...>
  <DataAnnotationsValidator />
  ...

to:

<EditForm Model="..." ...>
  <!-- ↓ Replace this component! -->
  <LocalizedDataAnnotationsValidator />
  ...

That's all!

Sample Source Code

You can get the source code of Live Demo site from this repository.

License

Mozilla Public License Version 2.0

Release Notes

v.1.0.0
- Initial release.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Toolbelt.Blazor.LocalizedDataAnnotationsValidator:

Package Downloads
NETopes.Blazor.UI
NETopes ASP.NET Core framework Blazor UI package

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.1.1 433 11/15/2019
1.0.0 148 11/14/2019