aboutsummaryrefslogtreecommitdiff
path: root/module/calp/entry-points
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/entry-points
parentDatetime restrict imports. (diff)
downloadcalp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.gz
calp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.xz
Prepare code for translation.
Diffstat (limited to 'module/calp/entry-points')
-rw-r--r--module/calp/entry-points/benchmark.scm8
-rw-r--r--module/calp/entry-points/convert.scm13
-rw-r--r--module/calp/entry-points/html.scm51
-rw-r--r--module/calp/entry-points/ical.scm8
-rw-r--r--module/calp/entry-points/import.scm38
-rw-r--r--module/calp/entry-points/server.scm38
-rw-r--r--module/calp/entry-points/terminal.scm7
-rw-r--r--module/calp/entry-points/text.scm15
-rw-r--r--module/calp/entry-points/tidsrapport.scm24
9 files changed, 107 insertions, 95 deletions
diff --git a/module/calp/entry-points/benchmark.scm b/module/calp/entry-points/benchmark.scm
index 5db9b9df..31ea958a 100644
--- a/module/calp/entry-points/benchmark.scm
+++ b/module/calp/entry-points/benchmark.scm
@@ -5,6 +5,8 @@
:use-module (hnh util options)
:use-module ((srfi srfi-41) :select (stream->list))
+ :use-module (calp translation)
+
:use-module ((vcomponent util instance methods) :select (get-event-set))
:autoload (vcomponent util instance) (global-event-object)
@@ -15,9 +17,9 @@
(define opt-spec
`((enable-output (single-char #\o)
(description
- "Output is be default supressed, since many fields contain way to much data "
- "to read. This turns it on again."))
- (help (single-char #\h) (description "Print this help."))))
+ ,(_ "Output is by default supressed, since many fields contain way to much data to read. This turns it on again.")
+ ))
+ (help (single-char #\h) (description ,(_ "Print this help.")))))
(define (main args)
diff --git a/module/calp/entry-points/convert.scm b/module/calp/entry-points/convert.scm
index 3f602b07..5f298de4 100644
--- a/module/calp/entry-points/convert.scm
+++ b/module/calp/entry-points/convert.scm
@@ -4,18 +4,19 @@
:use-module (hnh util options)
:use-module (ice-9 getopt-long)
:use-module (sxml simple)
+ :use-module (calp translation)
)
(define opt-spec
- `((from (single-char #\f) (value (options "xcal" "ical"))
- (description "Input format (infered from " (i "infile") ")"))
+ `((from (single-char #\f) (value (options "xcal" "ical"))
+ (description ,(xml->sxml (_ "<group>Input format (otherwise infered from <i>infile</i>)</group>"))))
(to (single-char #\t) (value (options "xcal" "ical"))
- (description "Output format (infered from " (i "outfile") ")"))
- (infile (value #t) (single-char #\i) (description "Input file"))
- (outfile (value #t) (single-char #\o) (description "Output file"))
- (help (single-char #\h) (description "Print this help."))))
+ (description ,(xml->sxml (_ "<group>Output format (otherwise infered from <i>outfile</i>)</group>"))))
+ (infile (value #t) (single-char #\i) (description ,(_ "Input file")))
+ (outfile (value #t) (single-char #\o) (description ,(_ "Output file")))
+ (help (single-char #\h) (description ,(_ "Print this help.")))))
(define (filename-to-type filename)
diff --git a/module/calp/entry-points/html.scm b/module/calp/entry-points/html.scm
index 7c4fe257..2a559794 100644
--- a/module/calp/entry-points/html.scm
+++ b/module/calp/entry-points/html.scm
@@ -18,9 +18,10 @@
:use-module ((vcomponent util instance methods)
:select (get-calendars get-event-set))
- :use-module ((sxml simple) :select (sxml->xml))
+ :use-module ((sxml simple) :select (sxml->xml xml->sxml))
:use-module ((sxml transformations) :select (href-transformer))
:use-module ((xdg basedir) :prefix xdg-)
+ :use-module (calp translation)
:autoload (vcomponent util instance) (global-event-object)
)
@@ -28,39 +29,35 @@
(define opt-spec
`((from (value #t) (single-char #\F)
- (description "Start date of output.")
+ (description ,(_ "Start date of output."))
)
(count (value #t)
- (description "How many pages should be rendered."
- "If --style=" (b "week") " and --from=" (b "2020-04-27")
- " then --count=" (b 4) " would render the four pages "
- "2020-04-27, 2020-05-04, 2020-05-11, and 2020-05-25. "
- "Defaults to 12 to give a whole year when --style=" (b "month") "."
- ))
+ (description ,(xml->sxml (_ "<group>How many pages should be rendered.
+If --style=<b>week</b> and --from=<b>2020-04-27</b>;
+then --count=<b>4</b> would render the four pages
+2020-04-27, 2020-05-04, 2020-05-11, and 2020-05-25.
+Defaults to 12 to give a whole year when --style=<b>month</b></group>"))))
(target (single-char #\t) (value #t)
- (description "Directory where html files should end up. Default to " (b "./html")))
+ (description ,(xml->sxml (_ "<group>Directory where html files should end up. Default to <b>./html</b></group>"))))
(style (value #t) (predicate ,(lambda (v) (memv (string->symbol v)
'(small wide week table))))
- (description "How the body of the HTML page should be layed out. "
- (br) (b "week")
- " gives a horizontally scrolling page with 7 elements, "
- "where each has events graphically laid out hour by hour."
- (br) (b "table")
- " gives a month in overview as a table. Each block contains "
- "the events for the given day, in order of start time. They are "
- "however not graphically sized. "
- (br) (b "wide")
- " is the same as week, but gives a full month.")
- )
+ (description ,(xml->sxml (_ "<group>How the body of the HTML page should be layed out.
+<br/><b>week</b>
+gives a horizontally scrolling page with 7 elements, where each has events
+graphically laid out hour by hour.
+<br/><b>table</b>
+gives a month in overview as a table. Each block contains the events for the
+given day, in order of start time. They are however not graphically sized.
+<br/><b>wide</b>
+is the same as week, but gives a full month.</group>"))))
(standalone
- (description "Creates a standalone document instead of an HTML fragment "
- "for embedding in a larger page. Currently only applies to the "
- (i "small") "style"))
+ (description ,(xml->sxml (_ "<group>Creates a standalone document instead of an HTML fragment
+for embedding in a larger page. Currently only applies to the <i>small</i> style</group>"))))
- (help (single-char #\h) (description "Print this help."))))
+ (help (single-char #\h) (description ,(_ "Print this help.")))))
@@ -99,7 +96,7 @@
(stream-for-each
(lambda (start-date)
(define fname (path-append target-directory (date->string start-date "~1.xml")))
- (format (current-error-port) "Writing to [~a]~%" fname)
+ (format (current-error-port) (_ "Writing to [~a]~%") fname)
(with-output-to-file fname
(lambda () (sxml->xml (re-root-static
(apply html-generate
@@ -167,7 +164,7 @@
pre-start: (start-of-week start)
post-end: (end-of-week (end-of-month start)))]
[else
- (error "Unknown html style: ~a" style)])
+ (error (_ "Unknown html style: ~a") style)])
- ((@ (calp util time) report-time!) "all done")
+ ((@ (calp util time) report-time!) (_ "all done"))
)
diff --git a/module/calp/entry-points/ical.scm b/module/calp/entry-points/ical.scm
index 938b0b35..e164c340 100644
--- a/module/calp/entry-points/ical.scm
+++ b/module/calp/entry-points/ical.scm
@@ -5,14 +5,16 @@
:use-module (vcomponent formats ical output)
:use-module (ice-9 getopt-long)
:use-module (datetime)
+ :use-module (calp translation)
+ :use-module (calp translation)
)
(define opt-spec
- '((from (value #t) (single-char #\F))
+ `((from (value #t) (single-char #\F))
(to (value #t) (single-char #\T)
- (description "Returns all elements between these two dates."))
+ (description ,(_ "Returns all elements between these two dates.")))
(help (single-char #\h)
- (description "Print this help."))))
+ (description ,(_ "Print this help.")))))
(define (main args)
(define opts (getopt-long args (getopt-opt opt-spec)))
diff --git a/module/calp/entry-points/import.scm b/module/calp/entry-points/import.scm
index 441ff527..28fb72a6 100644
--- a/module/calp/entry-points/import.scm
+++ b/module/calp/entry-points/import.scm
@@ -11,16 +11,17 @@
:use-module (vcomponent)
;; :use-module ((vcomponent formats ical parse) :select (parse-cal-path))
:use-module ((vcomponent util parse-cal-path) :select (parse-cal-path))
+ :use-module (calp translation)
:autoload (vcomponent util instance) (global-event-object)
)
(define options
- '((calendar (value #t) (single-char #\c)
- (description "Name of calendar to import into"))
+ `((calendar (value #t) (single-char #\c)
+ (description ,(_ "Name of calendar to import into")))
(file (value #t) (single-char #\f)
- (description "ics file to import"))
+ (description ,(_ "ics file to import")))
(help (single-char #\h)
- (description "Print this help."))))
+ (description ,(_ "Print this help.")))))
(define (main args)
(define opts (getopt-long args (getopt-opt options)))
@@ -39,27 +40,24 @@
(get-calendars global-event-object)))))
(unless calendar
- (format (current-error-port) "No calendar named ~s~%" cal-name)
+ (format (current-error-port) (_ "No calendar named ~s~%") cal-name)
(throw 'return))
(let ((new-events (parse-cal-path fname)))
- (format #t "About to the following ~a events into ~a~%~{~a~^~%~}~%"
+ (format #t (_ "About to import the following ~a events into ~a~%")
(length (children new-events))
- (prop calendar 'NAME)
+ (prop calendar 'NAME))
+ (format #t "~{~a~^~%~}~%"
(map (extract 'SUMMARY) (children new-events)))
- (format #t "Continue? [Y/n] ")
+ (format #t (_ "Continue? [Y/n] "))
- (let loop ((c #\space))
- (case c
- [(#\n #\N) (throw 'return)]
- [(#\y #\Y) (map (lambda (e)
- (add-event calendar e)
- (save-event e))
- (children new-events))]
- [else
- (let ((line (read-line)))
- (loop (if (string-null? line)
- #\Y (string-ref line 0))))]))
- )))
+ (let loop ((line (read-line)))
+ (case (if (string-null? line) 'yes (yes-no-check line))
+ [(no) (throw 'return)]
+ [(yes) (map (lambda (e)
+ (add-event calendar e)
+ (save-event e))
+ (children new-events))]
+ [else (loop line (read-line))])))))
diff --git a/module/calp/entry-points/server.scm b/module/calp/entry-points/server.scm
index c9ff339a..d42a5d3a 100644
--- a/module/calp/entry-points/server.scm
+++ b/module/calp/entry-points/server.scm
@@ -6,6 +6,8 @@
:use-module (srfi srfi-1)
:use-module (ice-9 getopt-long)
+ :use-module (calp translation)
+ :use-module (sxml simple)
:use-module ((calp server server) :select (start-server))
@@ -13,25 +15,23 @@
(define options
- '((port (value #t) (single-char #\p)
- (description "Bind to TCP port, defaults to " (i 8080) "."
- (br) "Can also be set through the config variable "
- (i "port") "."))
+ `((port (value #t) (single-char #\p)
+ (description ,(xml->sxml (_ "<group>Bind to TCP port, defaults to <i>8080</i>.
+<br/>Can also be set through the config variable
+<i>port</i>.</group>"))))
(addr (value #t)
-
- (description "Address to use, defaults to " (i "0.0.0.0")
- " for IPv4, and " (i "[::]") " for IPv6.")
- )
+ (description ,(xml->sxml (_ "<group>Address to use, defaults to <i>0.0.0.0</i> for IPv4,
+and <i>[::]</i> for IPv6</group>"))))
;; numbers as single-char doesn't work.
- (six (description "Use IPv6."))
- (four (description "Use IPv4."))
- (sigusr (description "Reload events on SIGUSR1"))
+ (six (description ,(_ "Use IPv6.")))
+ (four (description ,(_ "Use IPv4.")))
+ (sigusr (description ,(_ "Reload events on SIGUSR1")))
(help (single-char #\h)
- (description "Print this help."))))
+ (description ,(_ "Print this help.")))))
(define-config port 8080
- description: "Port to which the web server should bind.")
+ description: (_ "Port to which the web server should bind."))
(define-public (main args)
@@ -60,18 +60,22 @@
"::" "0.0.0.0")))
(when (option-ref opts 'sigusr #f)
- (display "Listening for SIGUSR1\n" (current-error-port))
+ (format (current-error-port) (_ "Listening for SIGUSR1~%"))
;; NOTE this uses the main thread, and does therefore block HTTP requests
;; while reloading. However, it appears to not cause any race conditions.
(sigaction SIGUSR1
(lambda _
- (display "Received SIGUSR1, reloading calendars\n"
- (current-error-port))
+ (format (current-error-port) (_ "Received SIGUSR1, reloading calendars~%"))
((@ (vcomponent util instance) reload)))))
- (format #t "Starting server on ~a:~a~%I'm ~a, runing from ~a~%"
+ ;; Arguments are
+ ;; IP-address which we bind to
+ ;; Port which we listen to
+ ;; PID of this process
+ ;; PWD of this process
+ (format #t (_ "Starting server on ~a:~a~%I'm ~a, runing from ~a~%")
addr port
(getpid) (getcwd))
diff --git a/module/calp/entry-points/terminal.scm b/module/calp/entry-points/terminal.scm
index b0be318c..dd35b8f3 100644
--- a/module/calp/entry-points/terminal.scm
+++ b/module/calp/entry-points/terminal.scm
@@ -6,12 +6,13 @@
:use-module (datetime)
:use-module (vulgar)
:use-module (hnh util options)
+ :use-module (calp translation)
)
(define options
- '((date (value #t) (single-char #\d)
- (description "Which date to start on."))
- (help (single-char #\t) (description "Print this help."))
+ `((date (value #t) (single-char #\d)
+ (description ,(_ "Which date to start on.")))
+ (help (single-char #\t) (description ,(_ "Print this help.")))
))
(define (main args)
diff --git a/module/calp/entry-points/text.scm b/module/calp/entry-points/text.scm
index 0a5744b3..921afb80 100644
--- a/module/calp/entry-points/text.scm
+++ b/module/calp/entry-points/text.scm
@@ -4,16 +4,18 @@
:use-module (ice-9 getopt-long)
:use-module (hnh util io)
:use-module (hnh util options)
+ :use-module (calp translation)
+ :use-module (sxml simple)
)
(define options
- '((width (value #t) (single-char #\w)
- (description "Width of written text, defaults to 70 chars."))
+ `((width (value #t) (single-char #\w)
+ (description ,(_ "Width of written text, defaults to 70 chars.")))
(file (value #t) (single-char #\f)
- (description "Read from " (i "file") " instead of standard input."))
+ (description ,(xml->sxml (_ "<group>Read from <i>file</i> instead of standard input.</group>"))))
(help (single-char #\h)
- (description "Prints this help."))))
+ (description ,(_ "Prints this help.")))))
(define (main args)
(define opts (getopt-long args (getopt-opt options)))
@@ -24,6 +26,9 @@
(for-each (lambda (l) (display l) (newline))
(flow-text
- (with-input-from-port (open-input-port (option-ref opts 'file "-"))
+ (with-input-from-port (let ((fname (option-ref opts 'file "-")))
+ (if (string=? fname "-")
+ (current-input-port)
+ (open-input-file fname)))
(@ (ice-9 rdelim) read-string))
#:width (or (string->number (option-ref opts 'width "")) 70))))
diff --git a/module/calp/entry-points/tidsrapport.scm b/module/calp/entry-points/tidsrapport.scm
index 5ff43cf7..a05c3b78 100644
--- a/module/calp/entry-points/tidsrapport.scm
+++ b/module/calp/entry-points/tidsrapport.scm
@@ -42,6 +42,8 @@
:use-module (hnh util)
:use-module (hnh util options)
:use-module (ice-9 getopt-long)
+ :use-module (calp translation)
+ :use-module (sxml simple)
:use-module (datetime)
)
@@ -165,20 +167,20 @@ trailer
)
(define opt-spec
- '((pdf (value #t)
- (description "Input pdf fill"))
+ `((pdf (value #t)
+ (description ,(_ "Input pdf file")))
(output (single-char #\o) (value optional)
- (description "Output file"))
+ (description ,(_ "Output file")))
(data (value optional)
- (description "Static data to fill fields with")
+ (description ,(_ "Static data to fill fields with"))
)
(template (value optional)
- (description "Map between real field names and human readable names." (br)
- "If data is given, but not trans, then data is assumed to be in a correct format"))
+ (description ,(xml->sxml (_ "<group>Map between real field names and human readable names.<br/>
+If data is given, but not trans, then data is assumed to be in a correct format</group>"))))
(search (value #t)
(description
- "Search term for dynamic filling. Supports basic globbing"))))
+ ,(_ "Search term for dynamic filling. Supports basic globbing")))))
(define (parse-search str)
(cond [(string-match "\\{(.*)\\}" str)
@@ -204,7 +206,7 @@ trailer
(define template
(call-with-input-file
(or (option-ref opts 'template #f)
- (error "Template required"))
+ (error (_ "Template required")))
read))
(define prepared-data
@@ -232,9 +234,9 @@ trailer
(define days
(let ((days (assoc-ref group 'days)))
(cond ((not (list? days))
- (error "Needs list, not pair"))
+ (error (_ "Needs list, not pair")))
((null? days)
- (error "Need more days"))
+ (error (_ "Need more days")))
((and (list? (car days)) (eqv? '- (caar days)))
(map (lambda (s) (string-append prefix (->string s)))
(iota (1+ (- (list-ref (car days) 2)
@@ -250,7 +252,7 @@ trailer
,@(build-alist work-hours days)
(,sum ,(apply + work-hours))))
(or (assoc-ref template 'groups)
- (error "Groups required in template"))
+ (error (_ "Groups required in template")))
search)))
(define report