aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent/datetime/output.scm
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-04-07 22:12:29 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2022-04-07 22:12:29 +0200
commite377df7b305514d721510fe1f15921647ebc7552 (patch)
tree35dd17aaf5e29c44c0f13401b6cb86e4d7df5acd /module/vcomponent/datetime/output.scm
parentRename filename-extension{ => ?}. (diff)
parentFix translation for (vcomponent datetime output). (diff)
downloadcalp-e377df7b305514d721510fe1f15921647ebc7552.tar.gz
calp-e377df7b305514d721510fe1f15921647ebc7552.tar.xz
Merge branch 'translation'
Diffstat (limited to 'module/vcomponent/datetime/output.scm')
-rw-r--r--module/vcomponent/datetime/output.scm54
1 files changed, 39 insertions, 15 deletions
diff --git a/module/vcomponent/datetime/output.scm b/module/vcomponent/datetime/output.scm
index 2b528423..fe909ebb 100644
--- a/module/vcomponent/datetime/output.scm
+++ b/module/vcomponent/datetime/output.scm
@@ -3,31 +3,52 @@
:use-module (datetime)
:use-module (vcomponent base)
:use-module (text util)
+ :use-module (calp translation)
+ :use-module ((vcomponent recurrence display) :select (format-recurrence-rule))
)
;; ev → sxml
+;; TODO translation
(define-public (format-recurrence-rule ev)
- `("Upprepas "
- ,((@ (vcomponent recurrence display) format-recurrence-rule)
- (prop ev 'RRULE))
+ ;; [FRR]
+ ;; Part of the sentance "Repeated [every two weeks], except on ~a, ~a & ~a"
+ ;; See everything tagged [FRR]
+ `(,(_ "Repeated ")
+ ,(format-recurrence-rule (prop ev 'RRULE))
,@(awhen (prop* ev 'EXDATE)
(list
- ", undantaget "
+ ;; See [FRR]
+ (_ ", except on ")
(add-enumeration-punctuation
(map (lambda (d)
+ ;; TODO show year if different from current year
(if (date? d)
- ;; NOTE possibly show year?
- (date->string d "~e ~b")
+ ;; [FRR] Exception date without time
+ (date->string d (_ "~e ~b"))
;; NOTE only show time when it's different than the start time?
;; or possibly only when FREQ is hourly or lower.
(if (memv ((@ (vcomponent recurrence internal) freq)
- (prop ev 'RRULE))
- '(HOURLY MINUTELY SECONDLY))
- (datetime->string d "~e ~b ~k:~M")
- (datetime->string d "~e ~b"))))
+ (prop ev 'RRULE))
+ '(HOURLY MINUTELY SECONDLY))
+ ;; [FRR] Exception date with time
+ (datetime->string d (_ "~e ~b ~k:~M"))
+ ;; [FRR] Exception date without time
+ (datetime->string d (_ "~e ~b")))))
(map value it)))))
"."))
+(define-public (format-summary ev str)
+ ((get-config 'summary-filter) ev str))
+
+;; NOTE this should have information about context (html/term/...)
+(define-public (format-description ev str)
+ (catch #t (lambda () ((get-config 'description-filter) ev str))
+ (lambda (err . args)
+ ;; Warning message for failure to format description.
+ ;; First argument is name of warning/error,
+ ;; second is error arguments
+ (warning (_ "~a on formatting description, ~s") err args)
+ str)))
;; Takes an event, and returns a pretty string for the time interval
;; the event occupies.
@@ -37,9 +58,9 @@
(cond [(prop ev 'DTEND)
=> (lambda (e)
(if (date= e (date+ s (date day: 1)))
- "~Y-~m-~d" ; start = end, only return one value
- (values "~Y-~m-~d"
- "~Y-~m-~d")))]
+ (_ "~Y-~m-~d") ; start = end, only return one value
+ (values (_ "~Y-~m-~d")
+ (_ "~Y-~m-~d"))))]
;; no end value, just return start
[else (date->string s)]))]
[else ; guaranteed datetime
@@ -47,6 +68,9 @@
(e (prop ev 'DTEND)))
(if e
(let ((fmt-str (if (date= (get-date s) (get-date e))
- "~H:~M" "~Y-~m-~d ~H:~M")))
+ (_ "~H:~M")
+ ;; Note the non-breaking space
+ (_ "~Y-~m-~d ~H:~M"))))
(values fmt-str fmt-str))
- "~Y-~m-~d ~H:~M"))]))
+ ;; Note the non-breaking space
+ (_ "~Y-~m-~d ~H:~M")))]))