From 3cc25365a2d90ee09fd4cafbe77b4ffb8f2861f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 9 Apr 2020 11:31:30 +0300 Subject: [PATCH] Localize timeago and auto handle .timeago class. --- .../UI/Packages/Timeago/TimeagoScriptContributor.cs | 12 ++++++++++++ .../bootstrap/dom-event-handlers.js | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Timeago/TimeagoScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Timeago/TimeagoScriptContributor.cs index df9ac55c42..a276849db6 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Timeago/TimeagoScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/Timeago/TimeagoScriptContributor.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Globalization; using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; using Volo.Abp.Modularity; @@ -12,5 +13,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Timeago { context.Files.AddIfNotContains("/libs/timeago/jquery.timeago.js"); } + + public override void ConfigureDynamicResources(BundleConfigurationContext context) + { + var cultureName = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName; + var cultureFileName = $"/libs/timeago/locales/jquery.timeago.{cultureName}.js"; + + if (context.FileProvider.GetFileInfo(cultureFileName).Exists) + { + context.Files.Add(cultureFileName); + } + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js index db56e86c98..6b8ed10120 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js @@ -60,6 +60,8 @@ container: 'body' }); + args.$el.findWithSelf('.timeago').timeago(); + enableFormFeatures(args.$el.findWithSelf('form'), true); initializeScript(args.$el); @@ -82,6 +84,8 @@ container: 'body' }); + $('.timeago').timeago(); + $('[data-auto-focus="true"]').first().findWithSelf('input,select').focus(); });