Skip to content

Commit

Permalink
[#16377] fix: improve month translation
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Jul 26, 2023
1 parent 5257a9c commit ff888db
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
18 changes: 17 additions & 1 deletion src/quo2/components/calendar/calendar_month/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@
(:require [utils.i18n :as i18n]
[utils.datetime :as dt]))

(def ^:const months-with-year
"Maps the corresponding string representation of a month
By it's numeric index as in cljs-time"
{1 "january-year"
2 "february-year"
3 "march-year"
4 "april-year"
5 "may-year"
6 "june-year"
7 "july-year"
8 "august-year"
9 "september-year"
10 "october-year"
11 "november-year"
12 "december-year"})

(defn format-month-year
[year month]
(let [month (cond
(or (nil? month) (zero? month)) 1
(> month 12) 12
:else month)]
(str (i18n/label (get dt/full-months month)) " " year)))
(str (i18n/label (get months-with-year month) {:year year}))))

(defn next-month
[year month]
Expand Down
16 changes: 0 additions & 16 deletions src/utils/datetime.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,6 @@
11 "nov"
12 "dec"})

(def ^:const full-months
"Maps the corresponding string representation of a month
By it's numeric index as in cljs-time"
{1 "january"
2 "february"
3 "march"
4 "april"
5 "may"
6 "june"
7 "july"
8 "august"
9 "september"
10 "october"
11 "november"
12 "december"})

(def one-second 1000)
(def minute (* 60 one-second))
(defn minutes [m] (* m minute))
Expand Down
23 changes: 12 additions & 11 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2228,17 +2228,18 @@
"fr": "Fr",
"sa": "Sa",
"su": "Su",
"january": "January",
"february": "February",
"march": "March",
"april": "April",
"june": "June",
"july": "July",
"august": "August",
"september": "September",
"october": "October",
"november": "November",
"december": "December",
"january-year": "January {{year}}",
"february-year": "February {{year}}",
"march-year": "March {{year}}",
"april-year": "April {{year}}",
"may-year": "May {{year}}",
"june-year": "June {{year}}",
"july-year": "July {{year}}",
"august-year": "August {{year}}",
"september-year": "September {{year}}",
"october-year": "October {{year}}",
"november-year": "November {{year}}",
"december-year": "December {{year}}",
"mon": "Mon",
"tue": "Tue",
"wed": "Wed",
Expand Down

0 comments on commit ff888db

Please sign in to comment.