aboutsummaryrefslogtreecommitdiff
path: root/module/calp/html
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-02-22 11:19:19 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-02-22 21:08:41 +0100
commit093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee (patch)
treed164e37c20e562588700d86379cfda1b0ca3c596 /module/calp/html
parentDatetime restrict imports. (diff)
downloadcalp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.gz
calp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.xz
Prepare code for translation.
Diffstat (limited to 'module/calp/html')
-rw-r--r--module/calp/html/caltable.scm4
-rw-r--r--module/calp/html/components.scm3
-rw-r--r--module/calp/html/config.scm5
-rw-r--r--module/calp/html/util.scm5
-rw-r--r--module/calp/html/vcomponent.scm103
-rw-r--r--module/calp/html/view/calendar.scm53
-rw-r--r--module/calp/html/view/calendar/week.scm9
-rw-r--r--module/calp/html/view/search.scm13
8 files changed, 117 insertions, 78 deletions
diff --git a/module/calp/html/caltable.scm b/module/calp/html/caltable.scm
index dd2d4b03..77580844 100644
--- a/module/calp/html/caltable.scm
+++ b/module/calp/html/caltable.scm
@@ -1,4 +1,5 @@
(define-module (calp html caltable)
+
:use-module (hnh util)
:use-module (calp html util)
:use-module (datetime)
@@ -35,6 +36,7 @@
;; making the text red for all holidays, or creating a yellow background
;; for events from a specific source.
(time (@ (datetime ,(date->string date "~Y-~m-~d")))
+ ;; TODO should this field be translated?
,(day date)))))
(define month-start (start-of-month start-date))
@@ -49,11 +51,13 @@
;; top row, names of week days
,@(map (lambda (d) `(div (@ (class "column-head"))
+ ;; TODO this SHOULD be translated
,(string-titlecase (week-day-name d 2))))
(weekday-list))
;; left columun, week numbers
,@(map (lambda (v) `(div (@ (class "row-head")) ,v))
+ ;; TODO translate this
(map week-number
(stream->list
(stream-take-while (lambda (s) (date<= s post-end))
diff --git a/module/calp/html/components.scm b/module/calp/html/components.scm
index 2f8c85ec..0d6fbf1c 100644
--- a/module/calp/html/components.scm
+++ b/module/calp/html/components.scm
@@ -2,6 +2,7 @@
:use-module (hnh util)
:use-module (ice-9 curried-definitions)
:use-module (ice-9 match)
+ :use-module (calp translation)
:export (xhtml-doc)
)
@@ -57,7 +58,7 @@
allow-other-keys:
rest: args)
(when (and onclick href)
- (error "Only give one of onclick, href and submit."))
+ (error (_ "Only give one of onclick, href and submit.")))
(let ((body #f))
`(,(cond [href 'a]
diff --git a/module/calp/html/config.scm b/module/calp/html/config.scm
index 6bd1e0ec..08a4b2e8 100644
--- a/module/calp/html/config.scm
+++ b/module/calp/html/config.scm
@@ -1,11 +1,12 @@
(define-module (calp html config)
:use-module (hnh util)
:use-module (calp util config)
+ :use-module (calp translation)
)
(define-public debug (make-parameter #f))
(define-config debug #f
- description: "Places the generated thingy in debug mode"
+ description: (_ "Places the generated thingy in debug mode")
post: debug)
@@ -13,6 +14,6 @@
;;; but this works for the time being.
(define-public edit-mode (make-parameter #t))
(define-config edit-mode #t
- description: "Makes the document editable"
+ description: (_ "Makes the document editable")
post: edit-mode)
diff --git a/module/calp/html/util.scm b/module/calp/html/util.scm
index 75137d4e..aa3d9233 100644
--- a/module/calp/html/util.scm
+++ b/module/calp/html/util.scm
@@ -1,5 +1,6 @@
(define-module (calp html util)
- :use-module (hnh util))
+ :use-module (hnh util)
+ :use-module (calp translation))
(define-public (date-link date)
@@ -30,6 +31,6 @@
#xFF))
"#000000" "#FFFFFF")))
(lambda args
- (format (current-error-port) "Error calculating foreground color?~%~s~%" args)
+ (format (current-error-port) (_ "Error calculating foreground color?~%~s~%") args)
"#FF0000"
)))
diff --git a/module/calp/html/vcomponent.scm b/module/calp/html/vcomponent.scm
index 16f418c5..ffdd37e2 100644
--- a/module/calp/html/vcomponent.scm
+++ b/module/calp/html/vcomponent.scm
@@ -24,6 +24,7 @@
))
:use-module ((calp util config) :select (get-config))
:use-module ((base64) :select (base64encode))
+ :use-module (calp translation)
)
;; used by search view
@@ -45,10 +46,13 @@
"unknown")))))
(time ,(let ((dt (prop event 'DTSTART)))
(if (datetime? dt)
- (datetime->string dt "~Y-~m-~d ~H:~M")
- (date->string dt "~Y-~m-~d" ))))
+ ;; Compact event list date + time
+ (datetime->string dt (_ "~Y-~m-~d ~H:~M"))
+ ;; Compact event list date only
+ (date->string dt (_ "~Y-~m-~d") ))))
(a (@ (href ,(date->string (as-date (prop event 'DTSTART)) "/week/~Y-~m-~d.html")))
- "View 📅")
+ ;; Button for viewing calendar, accompanied by a calendar icon
+ ,(_ "View") " 📅")
(span ,(prop event 'SUMMARY)))))
(cons
(calendar-styles calendars)
@@ -86,6 +90,7 @@
(data-property "summary"))
,(prop ev 'SUMMARY))))
(div
+ ;; TODO localize this?
,(call-with-values (lambda () (fmt-time-span ev))
(case-lambda [(start)
`(div (time (@ (class "dtstart")
@@ -118,7 +123,7 @@
(div (@ (class "fields"))
,(when (and=> (prop ev 'LOCATION) (negate string-null?))
- `(div (b "Plats: ")
+ `(div (b ,(_ "Location: "))
(div (@ (class "location") (data-property "location"))
,(string-map (lambda (c) (if (char=? c #\,) #\newline c))
(prop ev 'LOCATION)))))
@@ -195,8 +200,10 @@
,@(format-recurrence-rule ev)))
,(when (prop ev 'LAST-MODIFIED)
- `(div (@ (class "last-modified")) "Senast ändrad "
- ,(datetime->string (prop ev 'LAST-MODIFIED) "~1 ~H:~M"))))
+ `(div (@ (class "last-modified")) ,(_ "Last modified") " "
+ ,(datetime->string (prop ev 'LAST-MODIFIED)
+ ;; Last modified datetime
+ (_ "~1 ~H:~M")))))
))))
@@ -206,7 +213,9 @@
(define-public (fmt-day day)
(let* (((date . events) day))
`(section (@ (class "text-day"))
- (header (h2 ,(let ((s (date->string date "~Y-~m-~d")))
+ (header (h2 ,(let ((s (date->string date
+ ;; Header for sidebar day
+ (_ "~Y-~m-~d"))))
`(a (@ (href "#" ,s)
(class "hidelink")) ,s))))
,@(stream->list
@@ -291,12 +300,13 @@
;; TODO possibly unused?
(define (repeat-info event)
`(div (@ (class "eventtext"))
- (h2 "Upprepningar")
+ (h2 ,(_ "Recurrences"))
(table (@ (class "recur-components"))
,@((@@ (vcomponent recurrence internal) map-fields)
(lambda (key value)
`(tr (@ (class ,key)) (th ,key)
(td
+ ;; TODO Should these date string be translated?
,(case key
((wkst) (week-day-name value))
((until) (if (date? value)
@@ -341,6 +351,7 @@
`(select (@ ,@args)
(option "-")
,@(map (lambda (x) `(option (@ (value ,(car x))) ,(cadr x)))
+ ;; TODO translate
'((MO "Monday")
(TU "Tuesday")
(WE "Wednesday")
@@ -360,7 +371,8 @@
(div (@ (class " eventtext edit-tab "))
(form (@ (class "edit-form"))
(select (@ (class "calendar-selection"))
- (option "- Choose a Calendar -")
+ ;; NOTE flytta "muffarna" utanför
+ (option ,(_ "- Choose a Calendar -"))
,@(let ((dflt (get-config 'default-calendar)))
(map (lambda (calendar)
(define name (prop calendar 'NAME))
@@ -370,7 +382,7 @@
,name))
calendars)))
(h3 (input (@ (type "text")
- (placeholder "Sammanfattning")
+ (placeholder ,(_ "Summary"))
(name "summary") (required)
(data-property "summary")
; (value ,(prop ev 'SUMMARY))
@@ -379,24 +391,24 @@
(div (@ (class "timeinput"))
,@(with-label
- "Starttid"
+ (_ "Start time")
'(date-time-input (@ (name "dtstart")
(data-property "dtstart")
)))
,@(with-label
- "Sluttid"
+ (_ "End time")
'(date-time-input (@ (name "dtend")
(data-property "dtend"))))
(div (@ (class "checkboxes"))
,@(with-label
- "Heldag?"
+ (_ "Whole day?")
`(input (@ (type "checkbox")
(name "wholeday")
)))
,@(with-label
- "Upprepande?"
+ (_ "Recurring?")
`(input (@ (type "checkbox")
(name "has_repeats")
))))
@@ -404,8 +416,8 @@
)
,@(with-label
- "Plats"
- `(input (@ (placeholder "Plats")
+ (_ "Location")
+ `(input (@ (placeholder ,(_ "Location"))
(name "location")
(type "text")
(data-property "location")
@@ -413,20 +425,20 @@
)))
,@(with-label
- "Beskrivning"
- `(textarea (@ (placeholder "Beskrivning")
+ (_ "Description")
+ `(textarea (@ (placeholder ,(_ "Description"))
(data-property "description")
(name "description"))
; ,(prop ev 'DESCRIPTION)
))
,@(with-label
- "Kategorier"
+ (_ "Categories")
`(input-list
(@ (name "categories")
(data-property "categories"))
(input (@ (type "text")
- (placeholder "Kattegori")))))
+ (placeholder (_ "Category"))))))
;; TODO This should be a "list" where any field can be edited
;; directly. Major thing holding us back currently is that
@@ -458,6 +470,7 @@
"↺")
(span (@ (class "summary")
(data-property "summary")))))
+ ;; TODO should't the time tags contain something?
(div (div (time (@ (class "dtstart")
(data-property "dtstart")
(data-fmt "~L~H:~M")
@@ -474,7 +487,7 @@
; "20:56"
))
(div (@ (class "fields"))
- (div (b "Plats: ")
+ (div (b ,("Location: "))
(div (@ (class "location")
(data-property "location"))
; "Alsättersgatan 13"
@@ -496,7 +509,7 @@
;; "varje vecka"
;; ".")
(div (@ (class "last-modified"))
- "Senast ändrad -"
+ ,(_ "Last Modified") " -"
; "2021-09-29 19:56"
))))))
@@ -504,21 +517,21 @@
`(template
(@ (id "vevent-edit-rrule"))
(div (@ (class "eventtext"))
- (h2 "Upprepningar")
+ (h2 ,(_ "Recurrences"))
(dl
- (dt "Frequency")
+ (dt ,(_ "Frequency"))
(dd (select (@ (name "freq"))
(option "-")
,@(map (lambda (x) `(option (@ (value ,x)) ,(string-titlecase (symbol->string x))))
'(SECONDLY MINUTELY HOURLY DAILY WEEKLY MONTHLY YEARLY))))
- (dt "Until")
+ (dt ,(_ "Until"))
(dd (date-time-input (@ (name "until"))))
- (dt "Conut")
+ (dt ,(_ "Conut"))
(dd (input (@ (type "number") (name "count") (min 0))))
- (dt "Interval")
+ (dt ,(_ "Interval"))
(dd (input (@ (type "number") (name "interval") ; min and max depend on FREQ
)))
@@ -532,14 +545,14 @@
(dd (input-list (@ (name ,name))
(input (@ (type "number")
(min ,min) (max ,max)))))))
- '((bysecond "By Second" 0 60)
- (byminute "By Minute" 0 59)
- (byhour "By Hour" 0 23)
- (bymonthday "By Month Day" -31 31) ; except 0
- (byyearday "By Year Day" -366 366) ; except 0
- (byweekno "By Week Number" -53 53) ; except 0
- (bymonth "By Month" 1 12)
- (bysetpos "By Set Position" -366 366) ; except 0
+ '((bysecond ,(_ "By Second") 0 60)
+ (byminute ,(_ "By Minute") 0 59)
+ (byhour ,(_ "By Hour") 0 23)
+ (bymonthday ,(_ "By Month Day") -31 31) ; except 0
+ (byyearday ,(_ "By Year Day") -366 366) ; except 0
+ (byweekno ,(_ "By Week Number") -53 53) ; except 0
+ (bymonth ,(_ "By Month") 1 12)
+ (bysetpos ,(_ "By Set Position") -366 366) ; except 0
)))
;; (dt "By Week Day")
@@ -550,7 +563,7 @@
;; ,(week-day-select '())
;; ))
- (dt "Weekstart")
+ (dt ,(_ "Weekstart"))
(dd ,(week-day-select '((name "wkst")))))))
)
@@ -565,32 +578,36 @@
(nav (@ (class "popup-control"))
(button (@ (class "close-button")
- (title "Stäng")
+ ;; Close this popup
+ (title ,(_ "Close"))
(aria-label "Close"))
"×")
(button (@ (class "maximize-button")
- (title "Fullskärm")
+ ;; Make this popup occupy the entire screen
+ (title ,(_ "Fullscreen"))
;; (aria-label "")
)
"🗖")
(button (@ (class "remove-button")
- (title "Ta Bort"))
+ ;; Remove/Trash the event this popup represent
+ ;; Think garbage can
+ (title ,(_ "Remove")))
"🗑"))
(tab-group (@ (class "window-body"))
(vevent-description
- (@ (data-label "📅") (data-title "Översikt")
+ (@ (data-label "📅") (data-title ,(_ "Overview"))
(class "vevent")))
(vevent-edit
- (@ (data-label "🖊") (data-title "Redigera")))
+ (@ (data-label "🖊") (data-title ,(_ "Edit"))))
;; (vevent-edit-rrule
;; (@ (data-label "↺") (data-title "Upprepningar")))
(vevent-changelog
- (@ (data-label "📒") (date-title "Changelog")))
+ (@ (data-label "📒") (date-title ,(_ "Changelog"))))
,@(when (debug)
'((vevent-dl
- (@ (data-label "🐸") (data-title "Debug")))))))))
+ (@ (data-label "🐸") (data-title ,(_ "Debug"))))))))))
diff --git a/module/calp/html/view/calendar.scm b/module/calp/html/view/calendar.scm
index ecdce291..c7a5c8c2 100644
--- a/module/calp/html/view/calendar.scm
+++ b/module/calp/html/view/calendar.scm
@@ -27,6 +27,7 @@
:use-module ((vcomponent util group)
:select (group-stream get-groups-between))
:use-module ((base64) :select (base64encode))
+ :use-module (calp translation)
)
@@ -72,10 +73,10 @@
,display)))
(unless next-start
- (error 'html-generate "Next-start needs to be a procedure"))
+ (error 'html-generate (_ "Next-start needs to be a procedure")))
(unless prev-start
- (error 'html-generate "Prev-start needs to be a procedure"))
+ (error 'html-generate (_ "Prev-start needs to be a procedure")))
(xhtml-doc
(@ (lang sv))
@@ -86,9 +87,11 @@
(meta (@ (name viewport)
(content "width=device-width, initial-scale=0.5")))
(meta (@ (name description)
- (content "Calendar for the dates between "
- ,(date->string start-date) " and "
- ,(date->string end-date))))
+ (content ,(format #f (_ "Calendar for the dates between ~a and ~a")
+ ;; start date metainfo
+ (date->string start-date (_ "~Y-~m-~d"))
+ ;; end date metainfo
+ (date->string end-date (_ "~Y-~m-~d"))))))
;; NOTE this is only for the time actually part of this calendar.
;; overflowing times from pre-start and post-end is currently ignored here.
(meta (@ (name start-time)
@@ -148,10 +151,12 @@ window.default_calendar='~a';"
;; Page footer
(footer
(@ (style "grid-area: footer"))
- (span "Page generated " ,(date->string (current-date)))
- (span "Current time " (current-time (@ (interval 1))))
+ (span ,(_ "Page generated ")
+ ;; Generation data
+ ,(date->string (current-date) (_ "~Y-~m-~d")))
+ (span ,(_ "Current time ") (current-time (@ (interval 1))))
(span (a (@ (href ,(repo-url)))
- "Source Code")))
+ ,(_ "Source Code"))))
;; Small calendar and navigation
(nav (@ (class "calnav") (style "grid-area: nav"))
@@ -161,10 +166,12 @@ window.default_calendar='~a';"
(start-of-week start-date)
start-date)
"/week/~1.html")
- "veckovy")
+ ;; Button to view week
+ (_ "Week"))
,(btn href: (date->string (set (day start-date) 1) "/month/~1.html")
- "månadsvy")
+ ;; button to view month
+ (_ "Month"))
(today-button
(a (@ (class "btn")
@@ -173,7 +180,8 @@ window.default_calendar='~a';"
[(month) "view=month"]
[(week) "view=week"]
[else ""]))))
- "idag")))
+ ;; Button to go to today
+ ,(_ "Today"))))
(div (@ (id "jump-to"))
;; Firefox's accessability complain about each date
@@ -193,9 +201,11 @@ window.default_calendar='~a';"
,(btn "➔"))))
(details (@ (open) (style "grid-area: cal"))
- (summary "Month overview")
+ (summary ,(_ "Month overview"))
(div (@ (class "smallcall-head"))
- ,(string-titlecase (date->string start-date "~B ~Y")))
+ ,(string-titlecase (date->string start-date
+ ;; Header of small calendar
+ (_ "~B ~Y"))))
;; NOTE it might be a good idea to put the navigation buttons
;; earlier in the DOM-tree/tag order. At least Vimium's
;; @key{[[} keybind sometimes finds parts of events instead.
@@ -220,17 +230,17 @@ window.default_calendar='~a';"
(action "/search/text"))
(input (@ (type "text")
(name "q")
- (placeholder "Sök")))
+ ;; Search placeholder
+ (placeholder ,(_ "Search"))))
(input (@ (type "submit")
(value ">"))))
,(when (or (debug) (edit-mode))
`(details (@ (class "sliders"))
- (summary "Option sliders")
-
+ (summary ,(_ "Option sliders"))
,@(when (edit-mode)
- `((label "Event blankspace")
+ `((label ,(_ "Event blankspace"))
,(slider-input
variable: "editmode"
min: 0
@@ -239,7 +249,7 @@ window.default_calendar='~a';"
value: 1)))
,@(when (debug)
- `((label "Fontsize")
+ `((label ,(_ "Fontsize"))
,(slider-input
unit: "pt"
min: 1
@@ -250,7 +260,7 @@ window.default_calendar='~a';"
;; List of calendars
(details (@ (class "calendarlist"))
- (summary "Calendar list")
+ (summary ,(_ "Calendar list"))
(ul ,@(map
(lambda (calendar)
`(li (@ (data-calendar ,(base64encode (prop calendar 'NAME))))
@@ -276,7 +286,7 @@ window.default_calendar='~a';"
;; Events which started before our start point,
;; but "spill" into our time span.
(section (@ (class "text-day"))
- (header (h2 "Tidigare"))
+ (header (h2 ,(_ "Earlier")))
;; TODO this group gets styles applied incorrectly.
;; Figure out way to merge it with the below call.
,@(stream->list
@@ -284,8 +294,7 @@ window.default_calendar='~a';"
(lambda (ev)
(fmt-single-event
ev `((id ,(html-id ev))
- (data-calendar ,(base64encode (or (prop (parent ev) 'NAME)
- "unknown"))))))
+ (data-calendar ,(base64encode (or (prop (parent ev) 'NAME) "unknown"))))))
(stream-take-while
(compose (cut date/-time<? <> start-date)
(extract 'DTSTART))
diff --git a/module/calp/html/view/calendar/week.scm b/module/calp/html/view/calendar/week.scm
index 5b12a351..921bdb83 100644
--- a/module/calp/html/view/calendar/week.scm
+++ b/module/calp/html/view/calendar/week.scm
@@ -17,6 +17,7 @@
:select (make-block output-uid) )
;; :use-module ((calp html components)
;; :select ())
+ :use-module (calp translation)
:use-module ((vcomponent util group)
:select (group-stream get-groups-between))
)
@@ -30,7 +31,9 @@
(div (@ (class "days"))
;; Top left area
(div (@ (class "week-indicator"))
- (span (@ (style "font-size: 50%")) "v.") ; figure out if we want this...
+ (span (@ (style "font-size: 50%"))
+ ;; Week number prefix
+ ,(_ "v."))
,@(->> (week-number start-date)
number->string string->list
(map (lambda (c) `(span ,(string c))))))
@@ -43,8 +46,10 @@
,@(map (lambda (day-date)
`(div (@ (class "meta"))
(span (@ (class "daydate"))
- ,(date->string day-date "~Y-~m-~d"))
+ ;; Week view header format
+ ,(date->string day-date (_ "~Y-~m-~d")))
(span (@ (class "dayname"))
+ ;; TODO translation here?
,(string-titlecase (date->string day-date "~a")))))
range)
,@(stream->list
diff --git a/module/calp/html/view/search.scm b/module/calp/html/view/search.scm
index 9b03151b..08436bc5 100644
--- a/module/calp/html/view/search.scm
+++ b/module/calp/html/view/search.scm
@@ -8,6 +8,7 @@
:select (xhtml-doc include-css))
:use-module ((calp html vcomponent)
:select (compact-event-list))
+ :use-module (calp translation)
)
;; Display the result of a search term, but doesn't do any searching
@@ -24,25 +25,25 @@
errors has-query? search-term search-result page paginator)
(xhtml-doc
(@ (lang sv))
- (head (title "Search results")
+ (head (title ,(_ "Search results"))
,(include-css "/static/style.css"))
(body
- (a (@ (href ("/today"))) "Till Idag")
- (h2 "Search term")
+ (a (@ (href ("/today"))) ,(_ "Show today"))
+ (h2 ,(_ "Search term"))
(form
(pre (textarea (@ (name "q") (rows 5) (spellcheck false)
(style "width:100%"))
,(when has-query?
(with-output-to-string
(lambda () (pretty-print search-term))))))
- (label (@ (for "onlyfuture")) "limit to future occurences")
+ (label (@ (for "onlyfuture")) ,(_ "limit to future occurences"))
(input (@ (name "onlyfuture") (id "onlyfuture") (type checkbox)))
(input (@ (type submit))))
,@(if errors
- `((h2 "Error searching")
+ `((h2 ,(_ "Error searching"))
(div (@ (class "error"))
(pre ,errors)))
- `((h2 "Result (page " ,page ")")
+ `((h2 ,(format #f (_ "Result (page ~a)") page))
(ul ,@(compact-event-list search-result))
(div (@ (class "paginator"))
,@(paginator->list