Skip to content

Commit 2023b49

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 2023b49

File tree

11 files changed

+164
-175
lines changed

11 files changed

+164
-175
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 & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,2 @@
1-
<% require './lib/i18n_tasks/js_erb_locale_matcher.rb' %>
2-
<% require './lib/i18n_tasks/slim_row_locale_matcher.rb' %>
3-
4-
# i18n_tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
5-
6-
# The "main" locale.
7-
base_locale: en
8-
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
9-
# locales: [es, fr]
10-
## Reporting locale, default: en. Available: en, ru.
11-
# internal_locale: en
12-
13-
# Read and write translations.
14-
data:
15-
## Translations are read from the file system. Supported format: YAML, JSON.
16-
## Provide a custom adapter:
17-
# adapter: I18n::Tasks::Data::FileSystem
18-
19-
# Locale files or `Find.find` patterns where translations are read from:
20-
read:
21-
## Default:
22-
# - config/locales/%{locale}.yml
23-
## More files:
24-
# - config/locales/**/*.%{locale}.yml
25-
- config/locales/%{locale}/*.yml
26-
- config/locales/%{locale}/**/*.yml
27-
28-
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
29-
# `i18n_tasks normalize -p` will force move the keys according to these rules
30-
write:
31-
- ['{application,breadcrumbs,locales,navigation,shared,will_paginate,activerecord.errors}.*', 'config/locales/%{locale}/meta/\1.yml']
32-
- ['activerecord.:.{admin,code_ocean}.{:}.*', 'config/locales/%{locale}/\1/\2.yml']
33-
- ['*.{*:}/:.*', 'config/locales/%{locale}/\1.yml']
34-
- ['activerecord.:.{*:}s?.*', 'config/locales/%{locale}/\1.yml']
35-
- ['{admin,code_ocean,linter,mailers}.{:}.*', 'config/locales/%{locale}/\1/\2.yml']
36-
- ['{*:}s?.*', 'config/locales/%{locale}/\1.yml']
37-
## Catch-all default:
38-
# - config/locales/%{locale}/unsorted.yml
39-
40-
# External locale data (e.g. gems).
41-
# This data is not considered unused and is never written to.
42-
external:
43-
## Example (replace %#= with %=):
44-
# - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
45-
46-
## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
47-
# router: conservative_router
48-
49-
yaml:
50-
write:
51-
# do not wrap lines at 80 characters
52-
line_width: -1
53-
54-
## Pretty-print JSON:
55-
# json:
56-
# write:
57-
# indent: ' '
58-
# space: ' '
59-
# object_nl: "\n"
60-
# array_nl: "\n"
61-
62-
# Find translate calls
63-
search:
64-
## Paths or `Find.find` patterns to search in:
65-
paths:
66-
- app/
67-
- spec/
68-
- app/assets/javascripts/
69-
70-
## Root directories for relative keys resolution.
71-
# relative_roots:
72-
# - app/controllers
73-
# - app/helpers
74-
# - app/mailers
75-
# - app/presenters
76-
# - app/views
77-
78-
## Directories where method names which should not be part of a relative key resolution.
79-
# By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key.
80-
# Directories listed here will not consider the name of the method part of the resolved key
81-
#
82-
# relative_exclude_method_name_paths:
83-
# -
84-
85-
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
86-
## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
87-
## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
88-
exclude:
89-
- app/assets/images
90-
- app/assets/fonts
91-
- app/assets/videos
92-
- app/assets/builds
93-
- spec/fixtures
94-
95-
## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
96-
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
97-
# only: ["*.rb", "*.html.slim"]
98-
99-
## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
100-
# strict: true
101-
102-
## Allows adding ast_matchers for finding translations using the AST-scanners
103-
## The available matchers are:
104-
## - RailsModelMatcher
105-
## Matches ActiveRecord translations like
106-
## User.human_attribute_name(:email) and User.model_name.human
107-
##
108-
## To implement your own, please see `I18n::Tasks::Scanners::AstMatchers::BaseMatcher`.
109-
# <%# I18n::Tasks.add_ast_matcher('I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher') %>
110-
111-
## Multiple scanners can be used. Their results are merged.
112-
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
113-
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
114-
115-
## Translation Services
116-
# translation:
117-
# # Google Translate
118-
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
119-
# google_translate_api_key: "AbC-dEf5"
120-
# # DeepL Pro Translate
121-
# # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
122-
# deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
123-
# # deepl_host: "https://api.deepl.com"
124-
# # deepl_version: "v2"
125-
# # add additional options to the DeepL.translate call: https://www.deepl.com/docs-api/translate-text/translate-text/
126-
# deepl_options:
127-
# formality: prefer_less
128-
## Do not consider these keys missing:
129-
ignore_missing:
130-
- 'linter.*'
131-
132-
## Consider these keys used:
1331
ignore_unused:
134-
- 'activerecord.{attributes,errors,models}.*'
135-
- 'linter.*'
136-
- 'will_paginate.*'
137-
138-
## Exclude these keys from the `i18n_tasks eq-base' report:
139-
# ignore_eq_base:
140-
# all:
141-
# - common.ok
142-
# fr,es:
143-
# - common.brand
144-
145-
## Exclude these keys from the `i18n_tasks check-consistent-interpolations` report:
146-
ignore_inconsistent_interpolations:
147-
- 'shared.errors_one'
148-
- 'shared.errors_other'
149-
150-
## Ignore these keys completely:
151-
# ignore:
152-
153-
154-
## Sometimes, it isn't possible for i18n_tasks to match the key correctly,
155-
## e.g. in case of a relative key defined in a helper method.
156-
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
157-
#
158-
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
159-
# only: %w(*.html.haml *.html.slim),
160-
# patterns: [['= title\b', '.page_title']] %>
161-
#
162-
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
163-
#
164-
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
165-
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>
2+
- 'local_time.*'

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}

0 commit comments

Comments
 (0)