From 075f3cfa1a112514cee16a5dbc1b0a5d5a1e1d67 Mon Sep 17 00:00:00 2001 From: kidhab <32387157+kidhab@users.noreply.github.com> Date: Sat, 10 Jun 2023 10:31:22 +0200 Subject: [PATCH] Make date configurable via locales (#997) --- app/helpers/application_helper.rb | 2 +- config/initializers/time_formats.rb | 1 + config/locales/de.yml | 3 +++ config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ config/locales/fr.yml | 3 +++ config/locales/nl.yml | 3 +++ config/locales/tr.yml | 4 +++- 8 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 config/initializers/time_formats.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b962507b..8b8a5f95 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,7 +4,7 @@ module ApplicationHelper include PathHelper def format_time(time = Time.now) - I18n.l(time, format: '%d.%m.%Y %H:%M') unless time.nil? + I18n.l(time, format: :foodsoft_datetime) unless time.nil? end def format_date(time = Time.now) diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb new file mode 100644 index 00000000..b0447b7e --- /dev/null +++ b/config/initializers/time_formats.rb @@ -0,0 +1 @@ +Time::DATE_FORMATS[:foodsoft_datetime] = "%d.%m.%Y %H:%M" diff --git a/config/locales/de.yml b/config/locales/de.yml index 5c556357..12033f57 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -1876,3 +1876,6 @@ de: title: Arbeitsgruppen update: notice: Arbeitsgruppe wurde aktualisiert + time: + formats: + foodsoft_datetime: "%d.%m.%Y %H:%M" diff --git a/config/locales/en.yml b/config/locales/en.yml index 10ee1fba..66323cad 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1903,3 +1903,6 @@ en: title: Workgroups update: notice: Workgroup was updated + time: + formats: + foodsoft_datetime: "%Y-%m-%d %H:%M" diff --git a/config/locales/es.yml b/config/locales/es.yml index d3a00a67..44812b83 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1618,3 +1618,6 @@ es: title: Grupos de trabajo update: notice: El grupo de trabajo se actualizó. + time: + formats: + foodsoft_datetime: "%d/%b/%Y %H:%M" diff --git a/config/locales/fr.yml b/config/locales/fr.yml index a6df1544..5b615b38 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1375,3 +1375,6 @@ fr: title: Équipes update: notice: L'équipe a été mise à jour + time: + formats: + foodsoft_datetime: "%d/%m/%Y %H:%M" diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 384e8839..f34a8883 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -1868,3 +1868,6 @@ nl: title: Werkgroepen update: notice: Werkgroep is bijgewerkt + time: + formats: + foodsoft_datetime: "%d-%m-%Y %H:%M" diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 8fb92b7a..b66d5c06 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -1903,4 +1903,6 @@ tr: title: Çalışma Grupları update: notice: Çalışma grubu güncellendi. - \ No newline at end of file + time: + formats: + foodsoft_datetime: "%d.%b.%Y %H:%M"