{"id":28625355,"url":"https://github.com/forevolve/forevolve.aspnetcore.localization","last_synced_at":"2025-10-06T21:58:36.811Z","repository":{"id":82873500,"uuid":"108175574","full_name":"ForEvolve/ForEvolve.AspNetCore.Localization","owner":"ForEvolve","description":"Easy Asp.Net Core MVC validation data attributes localization.","archived":false,"fork":false,"pushed_at":"2020-07-21T18:45:52.000Z","size":823,"stargazers_count":19,"open_issues_count":2,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-08T07:49:01.906Z","etag":null,"topics":["asp-net-core","localization","net-core-2"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ForEvolve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Carl-Hugo","patreon":null,"open_collective":null,"ko_fi":"carlhugo","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-10-24T19:47:32.000Z","updated_at":"2023-10-18T04:36:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"202d302f-fb6f-440b-9c04-6b631e54db45","html_url":"https://github.com/ForEvolve/ForEvolve.AspNetCore.Localization","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ForEvolve/ForEvolve.AspNetCore.Localization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2FForEvolve.AspNetCore.Localization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2FForEvolve.AspNetCore.Localization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2FForEvolve.AspNetCore.Localization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2FForEvolve.AspNetCore.Localization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForEvolve","download_url":"https://codeload.github.com/ForEvolve/ForEvolve.AspNetCore.Localization/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForEvolve%2FForEvolve.AspNetCore.Localization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278686633,"owners_count":26028326,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["asp-net-core","localization","net-core-2"],"created_at":"2025-06-12T08:10:23.826Z","updated_at":"2025-10-06T21:58:36.784Z","avatar_url":"https://github.com/ForEvolve.png","language":"C#","funding_links":["https://github.com/sponsors/Carl-Hugo","https://ko-fi.com/carlhugo","https://github.com/sponsors/Carl-hugo","https://paypal.me/CarlHugo?locale.x=en_US"],"categories":[],"sub_categories":[],"readme":"# ForEvolve.AspNetCore.Localization\n\n![Build, Test, and Deploy](https://github.com/ForEvolve/ForEvolve.AspNetCore.Localization/workflows/Build,%20Test,%20and%20Deploy/badge.svg)\n[![feedz.io](https://img.shields.io/badge/endpoint.svg?url=https%3A%2F%2Ff.feedz.io%2Fforevolve%2Flocalization%2Fshield%2FForEvolve.AspNetCore.Localization%2Flatest\u0026label=ForEvolve.AspNetCore.Localization)](https://f.feedz.io/forevolve/localization/packages/ForEvolve.AspNetCore.Localization/latest/download)\n[![NuGet.org](https://img.shields.io/nuget/vpre/ForEvolve.AspNetCore.Localization)](https://www.nuget.org/packages/ForEvolve.AspNetCore.Localization/)\n\nThe [ForEvolve.AspNetCore.Localization](https://github.com/ForEvolve/ForEvolve.AspNetCore.Localization) package allows you to enable localization of Asp.Net Core 2.1+ applications in one line of code. Moreover, it translates `System.ComponentModel.DataAnnotations.ValidationAttribute`s automagically, without the need to specify any string or error message (like the `[Required]` attribute).\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/CarlHugoM?style=for-the-badge\u0026logo=twitter)](https://twitter.com/intent/follow?screen_name=CarlHugoM)\n[![GitHub Sponsor](https://img.shields.io/static/v1?style=for-the-badge\u0026label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color\u0026link=%3curl%3e)](https://github.com/sponsors/Carl-hugo)\n[![PayPal Me](https://img.shields.io/static/v1?style=for-the-badge\u0026label=Donate\u0026message=%E2%9D%A4\u0026logo=Paypal\u0026color\u0026link=%3curl%3e)](https://paypal.me/CarlHugo?locale.x=en_US)\n\n## Supported languages:\n\n-   `English (en)` original error messages modified by [Carl-Hugo Marcotte](https://github.com/Carl-Hugo)\n-   `French (fr)` original translation by [Carl-Hugo Marcotte](https://github.com/Carl-Hugo)\n-   `Hebrew (he)` thanks to [aboyaniv](https://github.com/aboyaniv)\n-   `Portuguese (pt)` thanks to [Matheus Avi](https://github.com/spyker0) (Same as `pt-BR`, needs to be checked)\n-   `Brazilian portuguese (pt-BR)` thanks to [Matheus Avi](https://github.com/spyker0)\n-   `Spanish (es)` thanks to [Oswaldo Diaz](https://github.com/OswaldoDG)\n-   `Norwegian (bokmål) (nb)` thanks to [Petter Hoel](https://github.com/petterhoel) (If you are using `nb-NO` it should default to `nb`)\n-   `Norwegian (bokmål) (no)` thanks to [Petter Hoel](https://github.com/petterhoel) (Same as `nb`)\n-   `Chinese (zh)` thanks to [Jay Skyworker](https://github.com/jayskyworker) (Same as `zh-TW`, needs to be checked)\n-   `Chinese Traditional (zh-Hant)` thanks to [Jay Skyworker](https://github.com/jayskyworker) (Same as `zh-TW`, needs to be checked)\n-   `Chinese Traditional, Taiwan (zh-TW)` thanks to [Jay Skyworker](https://github.com/jayskyworker)\n-   `Polish (pl)` thanks to [Denis Pujdak](https://github.com/fairking)\n\n## Supported attributes\n\n-   CompareAttribute\n-   EmailAddressAttribute\n-   RequiredAttribute\n-   CreditCardAttribute\n-   FileExtensionsAttribute\n-   MaxLengthAttribute\n-   MinLengthAttribute\n-   PhoneAttribute\n-   RangeAttribute\n-   RegularExpressionAttribute\n-   UrlAttribute\n-   StringLengthAttribute (see [StringLengthLocalizationValidationAttributeAdapter.cs](https://github.com/ForEvolve/ForEvolve.AspNetCore.Localization/blob/master/src/ForEvolve.AspNetCore.Localization/Adapters/StringLengthLocalizationValidationAttributeAdapter.cs))\n\nYou can also create and register your own adapters and attributes like normal.\n\n## Versioning\n\nThe packages follows _semantic versioning_ and uses [Nerdbank.GitVersioning](https://github.com/dotnet/Nerdbank.GitVersioning) to automatically version packages based on git commits/hashes.\n\n## NuGet (Release)\n\nYou can:\n\n```cmd\nInstall-Package ForEvolve.AspNetCore.Localization\n```\n\nor\n\n```cmd\ndotnet add package ForEvolve.AspNetCore.Localization\n```\n\nor take a look at [https://www.nuget.org/packages/ForEvolve.AspNetCore.Localization/](https://www.nuget.org/packages/ForEvolve.AspNetCore.Localization/).\n\n## CI builds\n\nPR builds are pushed to [feedz.io](feedz.io) before getting released to NuGet, thanks to their Open Source subscription.\n\nThe NuGet v3 URL is: https://f.feedz.io/forevolve/localization/nuget/index.json\n\n## How to use\n\nTo enable localization for everything, including data annotation, you need to:\n\n1. Add the `ForEvolve.AspNetCore.Localization` NuGet package to your project.\n1. In `Startup.cs`, `AddForEvolveLocalization()` and optionally `UseRequestLocalization()` (see below).\n1. Run your application\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    // MVC (2.1)\n    services\n        .AddMvc()\n        .AddForEvolveLocalization()\n    ;\n\n    // MVC (3+)\n    services\n        .AddRazorPages() // or other part of MVC that returns an IMvcBuilder\n        .AddForEvolveLocalization()\n    ;\n}\n\npublic void Configure(IApplicationBuilder app)\n{\n    // (optional)\n    // Adds the Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware to automatically\n    // set culture information for requests based on information provided by the client.\n    app.UseRequestLocalization();\n\n    //...\n}\n```\n\nAs you can see, it took only one line of code to enable localization, and another line to automatically set the culture information for requests using `RequestLocalizationMiddleware`.\n\n`IMvcBuilder.AddForEvolveLocalization();` adds all necessary services to the DI container. It calls `IServiceCollection.AddLocalization(...)`, set the default `ResourcesPath` to `\"Resources\"`, registers the `ILocalizationValidationMetadataProvider` (which does the validation attributes localization magic), and calls both `IMvcBuilder.AddViewLocalization()` and `IMvcBuilder.AddDataAnnotationsLocalization()`.\n\nIf you don't want `IMvcBuilder.AddViewLocalization()` or `IMvcBuilder.AddDataAnnotationsLocalization()` to be called, you can opt-out by using an overload of `IMvcBuilderAddForEvolveLocalization()`, like that:\n\n```csharp\nservices\n    .AddRazorPages() // or other part of MVC that returns an IMvcBuilder\n    .AddForEvolveLocalization(\n        enableViewLocalization: false,\n        enableDataAnnotationsLocalization: false\n    )\n;\n```\n\n### Migrating to 3.0\n\nIf you want to change any Asp.Net-related options, you can Configure them or implements `IConfigureOptions\u003cTOptions\u003e` classes as you would normally do.\nIn 3.0 all options has been removed, so no need to learn how the library work, you must use Asp.Net options directly. See the [Change log](#change-log) for more info.\n\nIf you built custom `ILocalizationValidationAttributeAdapter`, just register them with the DI container, like:\n\n```csharp\nservices.AddSingleton\u003cILocalizationValidationAttributeAdapter, MyAdapter\u003e()\n```\n\nFor any other use-case that I may have forgotten, please open an issue.\n\n## How to contribute a translation\n\nSince I only know French and English, I can't translate messages into more languages, so contributions are very welcome.\n\nI built a small tool to help find the culture-neutral and culture-specifics `CultureInfo` about a language; **please make sure that your translation covers the culture-neutral `CultureInfo` before creating a culture-specific one**.\n\n-   [CultureInfo Browser](https://cultureinfobrowser.azurewebsites.net).\n\n**How to submit a new translation:**\n\n1. Fork the repo\n1. Create a resource file for the language you want to translate error messages into.\n1. Translate it (obviously)\n1. Add the new language to the `_supportedCultures` array in `SupportedCulturesCollection.cs`.\n1. Add the new language to the `Supported languages` section of the `README.md` file with a \"thanks to you\" attribution and a link.\n1. Open a pull request\n\nSince I don't speak all languages, I cannot validate those that I don't know (except maybe by using Google Translate), so it's up to you to makes things right! (or PR corrections)\n\nI will do my best to integrates PR as fast as possible.\n\n### Where are the error messages located?\n\nIf you look under `src/ForEvolve.AspNetCore.Localization/Resources/`, you will find `DataAnnotationSharedResource.resx` and `DataAnnotationSharedResource.{lang}.resx` files.\nYou can copy any one of those and translate the values.\n\nIf you want to create a culture-specific translation, example: `fr-CA`, please make sure that there is an `fr` translation (neutral culture) first which will be the default for that language.\n\n**Example:**\n\n-   First we need a `DataAnnotationSharedResource.fr.resx` file (already there).\n-   Then we could add `DataAnnotationSharedResource.fr-CA.resx`, `DataAnnotationSharedResource.fr-FR.resx`, etc.\n\n## Error messages\n\nI modified default error messages a little to make them more linear. Sometimes it was written `The field {0} ...` and sometimes it was `The {0} field ...`. I decided to normalize messages to `The {0} field ...`.\n\n_I am open to suggestion if you think this makes no sense. English is only my secondary language._\n\nError messages source (if you want the original error messages): [corefx/src/System.ComponentModel.Annotations/src/Resources/Strings.resx](https://github.com/dotnet/corefx/blob/1a76f612ffa3e459aa11add147e71206e4005555/src/System.ComponentModel.Annotations/src/Resources/Strings.resx)\n\n## The history of the project\n\nI created this project because I did not want to code something similar to this every single time I start a new Asp.Net Core application. I did not want to write an error message on every `ValidationAttribute` either (which seems to be the official solution).\n\nTo be honest, I was a little disappointed to see how hard it is to localize Asp.Net Core validation attributes. This should be trivial.\n\n_Don't get me wrong here; I don't want to criticize the design made by the team that built that system. I can only assume that there are some good reasons behind these design choices (technical or not)._\n\nThat said, the other parts of the localization pipeline of Asp.Net Core are pretty neat with `IStringLocalizer`, `IHtmlLocalizer` and `IViewLocalizer`.\n\n## How to contribute?\n\nIf you have ideas, requests or find bugs, please open an issue.\nIf you want to contributes some code, other than translating error messages, please open an issue first so you don't waste your time.\n\nFor more information, please read [Contributing to ForEvolve open source projects](https://github.com/ForEvolve/ForEvolve.DependencyInjection/tree/master/CONTRIBUTING.md).\n\n## Contributor Covenant Code of Conduct\n\nAlso, please read the [Contributor Covenant Code of Conduct](https://github.com/ForEvolve/ForEvolve.DependencyInjection/tree/master/CODE_OF_CONDUCT.md) that applies to all ForEvolve repositories.\n\n# Change log\n\n## 3.0.0\n\n-   Remove the need to call `IServiceCollection.AddForEvolveLocalization()` (see #27)\n-   Rename `IMvcBuilder.AddForEvolveMvcLocalization()` to `IMvcBuilder.AddForEvolveLocalization()`\n-   Leverage the options patterns to configure Asp.Net instead of custom options. Due to that, `ForEvolveLocalizationOptions` and `ForEvolveMvcDefaultLocalizationAdapterOptions` has been deleted.\n-   Internally leveraging DI more to simplify the initialization process (no more `new`ing volatile dependencies).\n-   `IApplicationBuilder.UseForEvolveRequestLocalization()` is now obsolete, use `IApplicationBuilder.UseRequestLocalization()` instead.\n-   Use `Nerdbank.GitVersioning` to manage versions automagically.\n-   Move builds from Azure DevOps to GitHub Actions so PR can be made to the CI/CD pipeline.\n-   You can now use `ISupportedCulturesCollection` to access the list of supported `CultureInfo`.\n\n## 2.2.0\n\n-   Add `Polish (pl)`\n\n## 2.1.0\n\n-   Add `Chinese (zh)`\n-   Add `Chinese (Traditional) (zh-Hant)`\n-   Add `Chinese (Traditional, Taiwan) (zh-TW)`\n\n## 2.0.0\n\n-   Update `MetadataProvider` so `DataTypeAttribute` gets the translation; Fix #21\n-   Add functional tests that are covering most scenarios, related to error messages; closing #1\n-   Add functional tests that are covering French translation; related to #5. This should ensure that further breaking changes in the Asp.Net Core repo would be detected automatically by the CI pipeline.\n\n### Possible/Known issues\n\n-   User-specified `ErrorMessage` on `DataTypeAttribute` might (will most likely) get overridden by `ForEvolve.AspNetCore.Localization`.\n\n## 1.3.0\n\n-   Add `Norwegian (bokmål) (nb)` and `Norwegian (bokmål) (no)`\n\n## 1.2.0\n\n-   Add `Spanish (es)`\n\n## 1.1.0\n\n-   Add `Portuguese (pt)` and `Brazilian portuguese (pt-BR)`\n\n## 1.0.0\n\n-   Initial `French (fr)` and `English (en)`\n-   Contributed `Hebrew (he)`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforevolve%2Fforevolve.aspnetcore.localization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforevolve%2Fforevolve.aspnetcore.localization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforevolve%2Fforevolve.aspnetcore.localization/lists"}