Toolbelt.ComponentModel.Annotations.Resources.ja 1.0.0

dotnet add package Toolbelt.ComponentModel.Annotations.Resources.ja --version 1.0.0
NuGet\Install-Package Toolbelt.ComponentModel.Annotations.Resources.ja -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Toolbelt.ComponentModel.Annotations.Resources.ja" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Toolbelt.ComponentModel.Annotations.Resources.ja --version 1.0.0
#r "nuget: Toolbelt.ComponentModel.Annotations.Resources.ja, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Toolbelt.ComponentModel.Annotations.Resources.ja as a Cake Addin
#addin nuget:?package=Toolbelt.ComponentModel.Annotations.Resources.ja&version=1.0.0

// Install Toolbelt.ComponentModel.Annotations.Resources.ja as a Cake Tool
#tool nuget:?package=Toolbelt.ComponentModel.Annotations.Resources.ja&version=1.0.0

Toolbelt.ComponentModel.Annotations.Resources.ja NuGet Package

この NuGet パッケージをインストールすると、ASP.NET Core および Blazor アプリに組み込みの、[Required][StringLength] などの検証属性に対する検証エラーメッセージが、日本語化されて表示されるようになります。

Warning
⚠️ このライブラリは、リフレクションを使用して、文書化されていない、.NET ランタイムの非公開の実装に触れています。そのため、将来の .NET バージョンでは動作しない可能性があることをご承知おきください。

使い方

  1. この NuGet パッケージをプロジェクトに追加します。下記は dotnet コマンドを使ってこれを行なう例です。
dotnet add package Toolbelt.ComponentModel.Annotations.Resources.ja
  1. プログラムの開始時、サービスコレクションに対して AddSystemComponentModelAnnotationsLocalization() 拡張メソッドを呼び出します。
// Program.cs
...
using Toolbelt.Extensions.DependencyInjection;
...
builder.Services.AddSystemComponentModelAnnotationsLocalization();
...

以上の手順を済ませると、ASP.NET Core および Blazor アプリ上で、日本語化された標準の検証エラーメッセージが表示されます。

alternate text is missing from this package README image

注意点

アプリの現在のスレッドカルチャを望む方法で設定することを忘れないでください。例えば Blazor サーバーアプリの場合、次のようなスタートアップコードを実装する必要があるかもしれません。

// Program.cs
...
using Toolbelt.Extensions.DependencyInjection;
...
var builder = WebApplication.CreateBuilder(args);
...
// 👇 ローカライズ機能に関するサービス群を DI コンテナに登録します。
builder.Services.AddLocalization(); 
...
builder.Services.AddSystemComponentModelAnnotationsLocalization();
...
var app = builder.Build();
...
// 👇 要求毎のローカライズミドルウェアを構成します。
app.UseRequestLocalization(options =>
{
    var supportedCultures = new[] { "en", "ja" };
    options.AddSupportedCultures(supportedCultures);
    options.AddSupportedUICultures(supportedCultures);
});
...
app.Run();

参考: 🔗 "ASP.NET Core Blazor のグローバリゼーションおよびローカライズ" | Microsoft Docs

リリースノート

リリースノートはこちら

ライセンス

Mozilla Public License Version 2.0

検証エラーメッセージの日本語訳には、Bing Microsoft Translater を使用しました。

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 204 7/20/2022

v.1.0.0
- 初回リリース;

すべての変更履歴を見るには、以下の URL を参照ください。
- https://github.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources/blob/main/Languages/ja/RELEASE-NOTES.txt