fingers10 / JqueryDataTablesServerSide

Asp.Net Core Server Side for Jquery DataTables Multiple Column Filtering and Sorting with Pagination and Excel Export
MIT License
227 stars 37 forks source link

Localization #52

Closed olegbonder closed 4 years ago

olegbonder commented 4 years ago

how can we use localization? Please show an example

fingers10 commented 4 years ago

Hi olegbonder,

Thanks for reaching out. Please refer issue #16

Thanks, Abdul Rahman

olegbonder commented 4 years ago

Hi fingers10, I refered to issue #16. But I dont't understand how to use constructor in class "JqueryDataTablesHtmlLocalizedTagHelper" using DI (dependecy injection) My steps:

  1. Startup.cs: services.AddLocalization(opt => opt.ResourcesPath = "Resources"); services.AddScoped<IDemoService, DefaultDemoService>(); services.Configure<RequestLocalizationOptions>(options => { var supportedCultures = new[] { new CultureInfo("en"), new CultureInfo("ru") }; options.DefaultRequestCulture = new RequestCulture("ru"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; }); services.AddControllersWithViews() .AddViewLocalization() .AddDataAnnotationsLocalization()

  2. Add Resource Files for my Model "Demo" (Demo.en.resx and [Demo.ru.resx): issueLocalizationDataTable Add Property "Name" in Resource Files

  3. In Demo-model add attribute: [Display(Name = "Name")] [SearchableString(EntityProperty = "FirstName,LastName")] [Sortable(EntityProperty = "FirstName,LastName", Default = true)] public string Name { get; set; }

  4. Add in _ViewImports.cshtml: @inject IHtmlLocalizer<JqueryDataTablesTagHelper> sl

  5. In View replace tag-helper "jquery-datatables" on "jquery-datatables-html-localized"

No effect How can i localize table columns using DataAnnotationsLocalization in view-model properties? Thanks

fingers10 commented 4 years ago

Did you try JqueryDataTablesHtmlLocalizedTagHelper.

Refer Table HTML section in Docs.

Please note: If you prefer HTML Localization then, Tag Helper is available with all the above properties.

olegbonder commented 4 years ago

Yes, I did, but no effect.

вс, 16 авг. 2020 г., 7:01 Abdul Rahman notifications@github.com:

Did you try JqueryDataTablesHtmlLocalizedTagHelper https://github.com/fingers10/JqueryDataTablesServerSide/blob/master/AspNetCoreWeb/TagHelpers/JqueryDataTablesHtmlLocalizedTagHelper.cs .

Refer Table HTML https://github.com/fingers10/JqueryDataTablesServerSide#table-html section in Docs.

Please note: If you prefer HTML Localization then, Tag Helper is available with all the above properties.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fingers10/JqueryDataTablesServerSide/issues/52#issuecomment-674475610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFO3HT4CJGDNWVHZBB2RTMDSA5KX7ANCNFSM4P3BRADQ .

olegbonder commented 4 years ago

Can you add test project where use localization in columns?

Thanks

fingers10 commented 4 years ago

Demo Project now supports localization.