Skip to content

Commit f1e8bfe

Browse files
committed
chore: Migrate to local_time for NPM support
jQuery.timeago has no NPM package. local_time is used as a replacement to support the migration to Webpack. Related to #3021
1 parent bc52f12 commit f1e8bfe

File tree

11 files changed

+164
-11
lines changed

11 files changed

+164
-11
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ gem 'js-routes'
2525
gem 'jwt'
2626
gem 'kramdown'
2727
gem 'kramdown-parser-gfm'
28+
gem 'local_time'
2829
gem 'mimemagic'
2930
gem 'net-http-persistent'
3031
gem 'net-imap', require: false
@@ -39,7 +40,6 @@ gem 'pundit'
3940
gem 'rails', '~> 8.0.2'
4041
gem 'rails_admin'
4142
gem 'rails-i18n'
42-
gem 'rails-timeago'
4343
gem 'ransack'
4444
gem 'rubytree'
4545
gem 'rubyzip'

Gemfile.lock

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ GEM
269269
listen (3.9.0)
270270
rb-fsevent (~> 0.10, >= 0.10.3)
271271
rb-inotify (~> 0.9, >= 0.9.10)
272+
local_time (3.0.3)
272273
logger (1.7.0)
273274
loofah (2.24.1)
274275
crass (~> 1.0.2)
@@ -420,9 +421,6 @@ GEM
420421
rails-i18n (8.0.1)
421422
i18n (>= 0.7, < 2)
422423
railties (>= 8.0.0, < 9)
423-
rails-timeago (2.20.0)
424-
actionpack (>= 5.2)
425-
activesupport (>= 5.2)
426424
rails_admin (3.3.0)
427425
activemodel-serializers-xml (>= 1.0)
428426
csv
@@ -704,6 +702,7 @@ DEPENDENCIES
704702
kramdown-parser-gfm
705703
letter_opener
706704
listen
705+
local_time
707706
mimemagic
708707
mnemosyne-ruby
709708
net-http-persistent
@@ -720,7 +719,6 @@ DEPENDENCIES
720719
rails (~> 8.0.2)
721720
rails-controller-testing
722721
rails-i18n
723-
rails-timeago
724722
rails_admin
725723
ransack
726724
rspec-collection_matchers
@@ -861,6 +859,7 @@ CHECKSUMS
861859
letter_opener (1.10.0) sha256=2ff33f2e3b5c3c26d1959be54b395c086ca6d44826e8bf41a14ff96fdf1bdbb2
862860
lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
863861
listen (3.9.0) sha256=db9e4424e0e5834480385197c139cb6b0ae0ef28cc13310cfd1ca78377d59c67
862+
local_time (3.0.3) sha256=c69a8974d993fdf6e60db02977ed23c070f203dcb3a1ff0de52ad3d2393f8303
864863
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
865864
loofah (2.24.1) sha256=655a30842b70ec476410b347ab1cd2a5b92da46a19044357bbd9f401b009a337
866865
mail (2.8.1) sha256=ec3b9fadcf2b3755c78785cb17bc9a0ca9ee9857108a64b6f5cfc9c0b5bfc9ad
@@ -929,7 +928,6 @@ CHECKSUMS
929928
rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d
930929
rails-html-sanitizer (1.6.2) sha256=35fce2ca8242da8775c83b6ba9c1bcaad6751d9eb73c1abaa8403475ab89a560
931930
rails-i18n (8.0.1) sha256=15303195450bdac9a80636cf14c7e5ada2f43907cc60fcd19bbb3f81ab45be0d
932-
rails-timeago (2.20.0) sha256=f9b284fa758e4ad89f74cec88bd1b04c378597f1eb6bafecdba9186ba0109f38
933931
rails_admin (3.3.0) sha256=666c40a0931ee4f6e29e6db1df69df72417218d553af25b2fb56cdc94e2cfbf9
934932
railties (8.0.2) sha256=0d7c3f40c49ba74980f1bac1d4bb153a9331c5ee8a9631d89c7bf79db82e5cf9
935933
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a

app/assets/javascripts/application.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
1111
// about supported directives.
1212
//
13-
//= require rails-timeago
14-
//= require locales/jquery.timeago.de.js
15-
//
1613
// app/assets
1714
// --> Include some assets first, as they are used by other assets.
1815
// --> Hence, the order specified here is important.

app/assets/javascripts/base.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ $(document).on('turbo-migration:load', function(event) {
3636
const htmlTag = $('html')
3737
I18n.defaultLocale = htmlTag.data('default-locale');
3838
I18n.locale = htmlTag.attr('lang');
39-
jQuery.timeago.settings.lang = I18n.locale;
4039

4140
// Initialize Sentry
4241
const sentrySettings = $('meta[name="sentry"]')

app/javascript/application.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ import "ace-builds/src-noconflict/ext-modelist"; // Enable language mode detecti
8585
ace.config.set("useStrictCSP", true); // Enable strict CSP mode
8686
window.ace = ace; // Publish ace in global namespace
8787

88+
import LocalTime from "local-time"
89+
LocalTime.config.locale = 'default';
90+
LocalTime.config.i18n['default'] = i18n.t('local_time');
91+
LocalTime.start()
92+
8893
// Turbo
8994
import '@hotwired/turbo-rails';
9095
import './turbo-migration';

app/views/request_for_comments/_list_entry.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ tr.table-row-clickable data-id=request_for_comment.id data-href=request_for_comm
1212
- else
1313
td.text-black-50.font-italic = t('request_for_comments.no_question')
1414
td = request_for_comment.user
15-
td = timeago_tag request_for_comment.created_at
15+
td = local_time_ago request_for_comment.created_at

config/i18n-tasks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ ignore_unused:
134134
- 'activerecord.{attributes,errors,models}.*'
135135
- 'linter.*'
136136
- 'will_paginate.*'
137+
- 'local_time.*'
137138

138139
## Exclude these keys from the `i18n_tasks eq-base' report:
139140
# ignore_eq_base:

config/locales/de/local_time.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
de:
3+
local_time:
4+
date:
5+
abbrDayNames:
6+
- So
7+
- Mo
8+
- Di
9+
- Mi
10+
- Do
11+
- Fr
12+
- Sa
13+
abbrMonthNames:
14+
- Jan
15+
- Feb
16+
- Mär
17+
- Apr
18+
- Mai
19+
- Jun
20+
- Jul
21+
- Aug
22+
- Sep
23+
- Okt
24+
- Nov
25+
- Dez
26+
dayNames:
27+
- Sonntag
28+
- Montag
29+
- Dienstag
30+
- Mittwoch
31+
- Donnerstag
32+
- Freitag
33+
- Samstag
34+
formats:
35+
default: "%e. %b %Y"
36+
thisYear: "%e. %b"
37+
monthNames:
38+
- Januar
39+
- Februar
40+
- März
41+
- April
42+
- Mai
43+
- Juni
44+
- Juli
45+
- August
46+
- September
47+
- Oktober
48+
- November
49+
- Dezember
50+
today: heute
51+
tomorrow: morgen
52+
'true': am {date}
53+
yesterday: gestern
54+
datetime:
55+
at: "{date} um {time}"
56+
formats:
57+
default: "%e. %B %Y um %H:%M %Z"
58+
default_24h: "%e. %B %Y um %H:%M %Z"
59+
time:
60+
elapsed: vor {time}
61+
formats:
62+
default: "%H:%M"
63+
default_24h: "%H:%M"
64+
hour: Stunde
65+
hours: Stunden
66+
minute: Minute
67+
minutes: Minuten
68+
second: Sekunde
69+
seconds: Sekunden
70+
singular: vor einer {time}
71+
singularAn: vor einer {time}

config/locales/en/local_time.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
en:
3+
local_time:
4+
date:
5+
abbrDayNames:
6+
- Sun
7+
- Mon
8+
- Tue
9+
- Wed
10+
- Thu
11+
- Fri
12+
- Sat
13+
abbrMonthNames:
14+
- Jan
15+
- Feb
16+
- Mar
17+
- Apr
18+
- May
19+
- Jun
20+
- Jul
21+
- Aug
22+
- Sep
23+
- Oct
24+
- Nov
25+
- Dec
26+
dayNames:
27+
- Sunday
28+
- Monday
29+
- Tuesday
30+
- Wednesday
31+
- Thursday
32+
- Friday
33+
- Saturday
34+
formats:
35+
default: "%b %e, %Y"
36+
thisYear: "%b %e"
37+
monthNames:
38+
- January
39+
- February
40+
- March
41+
- April
42+
- May
43+
- June
44+
- July
45+
- August
46+
- September
47+
- October
48+
- November
49+
- December
50+
today: today
51+
tomorrow: tomorrow
52+
'true': on {date}
53+
yesterday: yesterday
54+
datetime:
55+
at: "{date} at {time}"
56+
formats:
57+
default: "%B %e, %Y at %l:%M%P %Z"
58+
default_24h: "%B %e, %Y at %H:%M %Z"
59+
time:
60+
am: am
61+
elapsed: "{time} ago"
62+
formats:
63+
default: "%l:%M%P"
64+
default_24h: "%H:%M"
65+
hour: hour
66+
hours: hours
67+
minute: minute
68+
minutes: minutes
69+
pm: pm
70+
second: second
71+
seconds: seconds
72+
singular: a {time}
73+
singularAn: an {time}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"jquery-ujs": "^1.2.3",
3434
"jstree": "^3.3.17",
3535
"keycharm": "^0.4.0",
36+
"local-time": "^3.0.3",
3637
"mini-css-extract-plugin": "^2.9.2",
3738
"moment": "^2.30.1",
3839
"opensans-webkit": "^1.1.0",

0 commit comments

Comments
 (0)