diff options
Diffstat (limited to '')
-rw-r--r-- | module/calp/server/routes.scm | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm index 88f641fb..d05451eb 100644 --- a/module/calp/server/routes.scm +++ b/module/calp/server/routes.scm @@ -33,7 +33,11 @@ :use-module (calp util config) :use-module (calp html view calendar) - :use-module ((calp html view search) :select (search-result-page))) + :use-module ((calp html view search) :select (search-result-page)) + + :use-module (calp translation) + + ) @@ -49,8 +53,13 @@ ;; start with /static. (define (directory-table prefix dir) `(table (@ (class "directory-table")) - (thead - (tr (th "") (th "Name") (th "Perm") (th "Size"))) + (thead + (tr (th "") + (th ,(_ "Name")) + ;; File permissions, should be about as long as three digits + (th ,(_ "Perm")) + ;; File size + (th ,(_ "Size")))) (tbody (tr (td "↩️") (td (@ (colspan 3)) (a (@ (href ,(-> (path-split dir) @@ -80,7 +89,7 @@ (scm-error 'misc-error "directory-table" - "Scandir argument invalid or not directory: ~s" + (_ "Scandir argument invalid or not directory: ~s") (list dir) '()))))))) @@ -122,7 +131,7 @@ (GET "/" () (return '((content-type text/html)) (sxml->html-string - '(body (a (@ (href "/today")) "Gå till idag") + '(body (a (@ (href "/today")) ,(_ "Go to Today")) (script "window.onload = function() { document.getElementsByTagName('a')[0].click();}"))))) @@ -175,7 +184,7 @@ (POST "/remove" (uid) (unless uid (return (build-response code: 400) - "uid required")) + (_ "uid required"))) (aif (get-event-by-uid global-event-object uid) (begin @@ -187,10 +196,10 @@ (set! (param (prop* it 'X-HNH-REMOVED) 'VALUE) "BOOLEAN") (unless ((@ (vcomponent formats vdir save-delete) save-event) it) (return (build-response code: 500) - "Saving event to disk failed.")) + (_ "Saving event to disk failed."))) (return (build-response code: 204))) (return (build-response code: 400) - (format #f "No event with UID '~a'" uid)))) + (format #f (_ "No event with UID '~a'") uid)))) ;; TODO this fails when dtstart is <date>. ;; @var{cal} should be the name of the calendar encoded in base64. @@ -198,7 +207,7 @@ (unless (and cal data) (return (build-response code: 400) - "Both 'cal' and 'data' required\r\n")) + (string-append (_ "Both 'cal' and 'data' required") "\r\n"))) ;; NOTE that this leaks which calendar exists, @@ -211,7 +220,8 @@ (unless calendar (return (build-response code: 400) - (format #f "No calendar with name [~a]\r\n" calendar-name))) + (format #f "~@?\r\n" (_ "No calendar with name [~a]") + calendar-name))) ;; Expected form of data (but in XML) is: ;; @example @@ -240,11 +250,13 @@ #f)) (lambda (err port . args) (return (build-response code: 400) - (format #f "XML parse error ~{~a~}\r\n" args))))))) + (format #f "~a ~{~a~}\r\n" + (_ "XML parse error") + args))))))) (unless (eq? 'VEVENT (type event)) (return (build-response code: 400) - "Object not a VEVENT\r\n")) + (string-append (_ "Object not a VEVENT") "\r\n"))) ;; NOTE add-event uses the given UID if one is given, ;; but generates its own if not. It might be a good idea @@ -320,7 +332,7 @@ ;; and "program parent" into different fields. (lambda () (sxml->xml ((@ (vcomponent formats xcal output) vcomponent->sxcal) it))))) (return (build-response code: 404) - (format #f "No component with UID=~a found." uid)))) + (format #f (_ "No component with UID=~a found.") uid)))) (GET "/calendar/:uid{.*}.ics" (uid) (aif (get-event-by-uid global-event-object uid) @@ -329,7 +341,7 @@ (lambda () (print-components-with-fake-parent (list it))))) (return (build-response code: 404) - (format #f "No component with UID=~a found." uid)))) + (format #f (_ "No component with UID=~a found.") uid)))) (GET "/search/text" (q) (return (build-response |