{"id":20258458,"url":"https://github.com/amastaneh/persiandataannotations","last_synced_at":"2025-04-11T01:02:12.794Z","repository":{"id":31591435,"uuid":"35156249","full_name":"amastaneh/PersianDataAnnotations","owner":"amastaneh","description":"PersianDataAnnotations is ASP.NET Core MVC \u0026 ASP.NET MVC Custom Localization DataAnnotations (Localized MVC Errors) for Persian(Farsi) language - فارسی سازی خطاهای اعتبارسنجی توکار ام.وی.سی. و کور.ام.وی.سی. برای نمایش اعتبار سنجی سمت کلاینت","archived":false,"fork":false,"pushed_at":"2020-12-21T01:56:02.000Z","size":217,"stargazers_count":44,"open_issues_count":6,"forks_count":12,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T18:08:39.892Z","etag":null,"topics":["asp-net","asp-net-core","asp-net-core-mvc","asp-net-mvc","aspnetcore","csharp","data-annotation","data-annotations","dataannotations","farsi","iran","localization","localization-dataannotations","localized-dataannotations","mvc","mvc5","mvc6","net-mvc","nuget","persian"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amastaneh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"custom":"https://webdesigniran.com"}},"created_at":"2015-05-06T12:09:29.000Z","updated_at":"2024-12-25T05:05:13.000Z","dependencies_parsed_at":"2022-09-02T16:58:32.889Z","dependency_job_id":null,"html_url":"https://github.com/amastaneh/PersianDataAnnotations","commit_stats":null,"previous_names":["webdesigniran/persiandataannotations"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amastaneh%2FPersianDataAnnotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amastaneh%2FPersianDataAnnotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amastaneh%2FPersianDataAnnotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amastaneh%2FPersianDataAnnotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amastaneh","download_url":"https://codeload.github.com/amastaneh/PersianDataAnnotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322599,"owners_count":21084336,"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":["asp-net","asp-net-core","asp-net-core-mvc","asp-net-mvc","aspnetcore","csharp","data-annotation","data-annotations","dataannotations","farsi","iran","localization","localization-dataannotations","localized-dataannotations","mvc","mvc5","mvc6","net-mvc","nuget","persian"],"created_at":"2024-11-14T11:09:09.943Z","updated_at":"2025-04-11T01:02:12.746Z","avatar_url":"https://github.com/amastaneh.png","language":"C#","funding_links":["https://webdesigniran.com"],"categories":[],"sub_categories":[],"readme":"## Persian DataAnnotations\n[![Gitter](https://badges.gitter.im/webdesigniran/PersianDataAnnotations.svg)](https://gitter.im/PersianDataAnnotations/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\nPersian DataAnnotations as DataAnnotations localizer library, is a localization of System.ComponentModel.DataAnnotations for Persian (Farsi) language. It's useful for Persian ASP.NET Core MVC \u0026 ASP.NET MVC based applications. The localization of built-in resource of DataAnnotations is a bit hard to work (specialy in ASP.NET MVC) and this library helps your project for localization error messages just with single call a method. `Fork` and `Translate` RESX resources for your language ;-)\n\n\n🌟 If you ❤️ library, please star it! 🌟\n\n\n## \u0026#x202b;اعتبار سنجی کنترل ها در .NET با Data Annotation ها\n\u0026#x202b;استفاده از `DataAnnotation` ها و افزودن `[Required]` یا `[DataType(DataType.Password)]` یا دیگر `Attribute` ها، کار اعتبارسنجی سمت کلاینت را بسیار ساده کرده است. برای فارسی سازی مقادیر پیش فرض کافی است این کتابخانه را با استفاده [نیوگت / NuGet](https://nuget.org/packages/PersianDataAnnotations) یا به صورت دستی به پروژه اضافه کنید. \n\n\n\n## \u0026#x202b; شیوه استفاده در ASP.NET Core MVC\n\n  1- \u0026#x202b; با استفاده از [نیوگت / NuGet](https://nuget.org/packages/PersianDataAnnotationsCore) به سادگی می توانید این کتابخانه را به پروژه خود اضافه کنید\n  \n```\n  PM\u003e Install-Package PersianDataAnnotationsCore\n```\n  2- \u0026#x202b; فقط همین یک خط را اضافه کنید و کار تمام میشود\n\n```c#\npublic void ConfigureServices(IServiceCollection services)\n{\n    services.AddMvc(options =\u003e options.ModelMetadataDetailsProviders.Add(new PersianDataAnnotationsCore.PersianValidationMetadataProvider()));\n}\n```\n\n\n\n## \u0026#x202b; شیوه استفاده در ASP.NET MVC\n\n  1- \u0026#x202b; با استفاده از [نیوگت / NuGet](https://nuget.org/packages/PersianDataAnnotations) به سادگی می توانید این کتابخانه را به پروژه خود اضافه کنید\n  \n```\n  PM\u003e Install-Package PersianDataAnnotations -Version\n```\n\n  2- \u0026#x202b; یعنی فقط همین یک خط را اضافه کنید و کار تمام میشود\n```c#\nprotected void Application_Start()\n{\n    PersianDataAnnotations.PersianDataAnnotations.Register();\n}\n```\n\n  3- \u0026#x202b; فارسی سازی خطاهای مربوط به رمز عبور و قسمت ثبت نام\n\n```c#\npublic static ApplicationUserManager Create(IdentityFactoryOptions\u003cApplicationUserManager\u003e options, IOwinContext context) \n{\n    ...\n    manager.PasswordValidator = new PasswordValidator \n    /// جایگزین شود با خط زیر\n  \tmanager.PasswordValidator = new PersianPasswordValidator\n    ...\n}\n```\n\n\n\n## دمو\nبرای مشاهده دمو می توانید به فرم عضویت یا ورود کاربران در [طراحی وب ایران](http://webdesigniran.com) مراجعه کنید\n\n\u003cimg alt=\"screencapture-webdesigniran\" src=\"https://cloud.githubusercontent.com/assets/6195199/7538227/bfcb8226-f5b3-11e4-9bcc-b13baef6a4b7.png\" width=\"320\"\u003e\n\nنمونه فارسی سازی خطاهای مربوط به رمز عبور\n\n\u003cimg alt=\"screencapture-webdesigniran\" src=\"https://cloud.githubusercontent.com/assets/6195199/7716477/dd77299a-fea7-11e4-8b85-695e9f919f00.png\" width=\"320\"\u003e\n\n\n\n## ترجمه\n\u0026#x202b;‫هنوز احتمال دارد که خطاهایی فارسی نشده باشند. در نسخه های مربوط به پروژه های ASP.NET MVC یک متد استاتیک ترجمه نظیر به نظیر خطا هم اضافه شده که خطاها را می تواند قبل از نمایش تا حد امکان ترجمه کند.\n\n```c#\nprivate void AddErrors(IdentityResult result)\n{\n  foreach (var error in result.Errors)\n\t{\n\t  ModelState.AddModelError(\"\", PersianDataAnnotations.TranslateError.Translate(error));\n\t}\n}\n```\n\u0026#x202b; متد بالا در کلاس های پیش فرض AccountController یا مشابه آن وجود دارد فقط به آن ترجمه متن خطا اضافه شده است\n\n\u0026#x202b;‫البته مشابه این متد استاتیک برای نسخه های ASP.NET Core MVC هم ارائه شده است\n```c#\nvar result = PersianDataAnnotationsCore.PersianValidationMetadataProvider.ToPersian(value)\n```\n\n\n\n## نکات\n*\t\u0026#x202b;امکان تغییر `Resource` برای جلوگیری از تکرار `ErrorMessageResourceType` در هنگام `RegisterAdapters` دیده شده است\n*\t\u0026#x202b;با جستجوی عنوان پروژه در `NuGet` می توانید از ابزار `NuGet` در ویژوال استودیو استفاده کنید و کتابخانه را به سادگی به پروژه اضافه کنید\n*\tسعی شده نقطه از آخر پیام ها حذف شود برای انطباق بیشتر با برنامه های چپ به راست\n*\tسعی شده پیام ها با فارسی روان نه پارسی بسیار ادبی و دور از ادبیات عامه بیان شود\n*\tسعی شده از بیشتر از است به جای مصدر نادرست باشیدن استفاده شود\n\n\n\n## پشتیبانی\nلطفا اگر ترجمه بهتری برای یک عبارت یافته اید\nلطفا اگر مشکلی مشاهده کردید\nلطفا اگر پیشنهادی دارید\n- \u0026#x202b;یا Fork \u0026 Pull کنید\n- \u0026#x202b;یا Share Issue کنید\n- \u0026#x202b;یا لااقل یه تلفن یا موبایل بزنید به [طراحی وب ایران](http://webdesigniran.com)\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003e License\n\nThe project is dedicated to public and is free for all uses, commercial or otherwise.\nSupported by [Web Design Iran](http://webdesigniran.com)\n\nاین پروژه تحت حمایت \n[طراحی وب ایران](http://webdesigniran.com)\n بوده و برای استفاده تجاری یا غیر تجاری، رایگان است\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famastaneh%2Fpersiandataannotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famastaneh%2Fpersiandataannotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famastaneh%2Fpersiandataannotations/lists"}