{"id":20409355,"url":"https://github.com/jsakamoto/toolbelt.componentmodel.annotations.resources","last_synced_at":"2025-04-12T15:44:30.286Z","repository":{"id":47263467,"uuid":"515086378","full_name":"jsakamoto/Toolbelt.ComponentModel.Annotations.Resources","owner":"jsakamoto","description":"Built-in validation error messages for validation attributes such as [Required], [StringLength], etc., on your ASP.NET Core and Blazor apps will be shown localized after installing this NuGet package.","archived":false,"fork":false,"pushed_at":"2022-07-20T13:46:54.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T10:11:33.310Z","etag":null,"topics":["blazor","blazor-server","blazor-server-app","blazor-wasm","blazor-webassembly","data-annotation","data-annotations","localization"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsakamoto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-18T07:54:40.000Z","updated_at":"2023-08-05T15:39:11.000Z","dependencies_parsed_at":"2022-08-30T01:31:09.453Z","dependency_job_id":null,"html_url":"https://github.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsakamoto%2FToolbelt.ComponentModel.Annotations.Resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsakamoto%2FToolbelt.ComponentModel.Annotations.Resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsakamoto%2FToolbelt.ComponentModel.Annotations.Resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsakamoto%2FToolbelt.ComponentModel.Annotations.Resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsakamoto","download_url":"https://codeload.github.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248591019,"owners_count":21129936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor","blazor-server","blazor-server-app","blazor-wasm","blazor-webassembly","data-annotation","data-annotations","localization"],"created_at":"2024-11-15T05:41:08.732Z","updated_at":"2025-04-12T15:44:30.251Z","avatar_url":"https://github.com/jsakamoto.png","language":"HTML","readme":"# Toolbelt.ComponentModel.Annotations.Resources [![NuGet Package](https://img.shields.io/nuget/v/Toolbelt.ComponentModel.Annotations.Resources.svg)](https://www.nuget.org/packages/Toolbelt.ComponentModel.Annotations.Resources/)\n\nBuilt-in validation error messages for validation attributes such as `[Required]`, `[StringLength]`, etc., on your ASP.NET Core and Blazor apps will be shown localized after installing this NuGet package.\n\n\u003e **Warning**  \n\u003e ⚠️ This library touches undocumented areas and private implementations of the .NET runtime, using the \"Reflection\" technology. So please remember that **it might not be working on future .NET versions.**\n\n## Usage\n\n1. Install the NuGet package for the language you want to localize. The following command example shows the case for localizing standard validation error messages to Japanese.\n\n```shell\ndotnet add package Toolbelt.ComponentModel.Annotations.Resources.ja\n```\n\n2. Call the `AddSystemComponentModelAnnotationsLocalization()` extension method for a service collection at the startup of your apps.\n\n```csharp\n// Program.cs\n...\nusing Toolbelt.Extensions.DependencyInjection;\n...\nbuilder.Services.AddSystemComponentModelAnnotationsLocalization();\n...\n```\n\nAfter doing the above steps, you will see localized validation error messages on your ASP.NET Core and Blazor apps.\n\n![](https://raw.githubusercontent.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources/main/.assets/fig.001.png)\n\n## Notice\n\nPlease remember to set the current thread culture on your apps the way you want. On a Blazor server app case, for example, you may have to implement your startup code like this:\n\n```csharp\n// Program.cs\n...\nusing Toolbelt.Extensions.DependencyInjection;\n...\nvar builder = WebApplication.CreateBuilder(args);\n...\n// 👇 Register services to the DI container involved with the localization feature.\nbuilder.Services.AddLocalization(); \n...\nbuilder.Services.AddSystemComponentModelAnnotationsLocalization();\n...\nvar app = builder.Build();\n...\n// 👇 Configure the Request Localization middleware.\napp.UseRequestLocalization(options =\u003e\n{\n    var supportedCultures = new[] { \"en\", \"ja\" };\n    options.AddSupportedCultures(supportedCultures);\n    options.AddSupportedUICultures(supportedCultures);\n});\n...\napp.Run();\n```\n\n**See also:** [🔗 _\"ASP.NET Core Blazor globalization and localization\" | Microsoft Docs_](https://docs.microsoft.com/aspnet/core/blazor/globalization-localization)\n\n## Release Note\n\n[Release notes](https://github.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources/blob/main/RELEASE-NOTES.txt)\n\n## License\n\n[Mozilla Public License Version 2.0](https://github.com/jsakamoto/Toolbelt.ComponentModel.Annotations.Resources/blob/main/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsakamoto%2Ftoolbelt.componentmodel.annotations.resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsakamoto%2Ftoolbelt.componentmodel.annotations.resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsakamoto%2Ftoolbelt.componentmodel.annotations.resources/lists"}