aboutsummaryrefslogtreecommitdiff
path: root/module/vcomponent
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/vcomponent
parentDatetime restrict imports. (diff)
downloadcalp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.gz
calp-093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee.tar.xz
Prepare code for translation.
Diffstat (limited to 'module/vcomponent')
-rw-r--r--module/vcomponent/datetime/output.scm11
-rw-r--r--module/vcomponent/formats/common/types.scm11
-rw-r--r--module/vcomponent/formats/ical/output.scm3
-rw-r--r--module/vcomponent/formats/ical/parse.scm29
-rw-r--r--module/vcomponent/formats/ical/types.scm8
-rw-r--r--module/vcomponent/formats/vdir/parse.scm3
-rw-r--r--module/vcomponent/formats/xcal/output.scm3
-rw-r--r--module/vcomponent/formats/xcal/parse.scm5
-rw-r--r--module/vcomponent/formats/xcal/types.scm3
-rw-r--r--module/vcomponent/util/instance.scm3
-rw-r--r--module/vcomponent/util/instance/methods.scm4
-rw-r--r--module/vcomponent/util/parse-cal-path.scm5
12 files changed, 59 insertions, 29 deletions
diff --git a/module/vcomponent/datetime/output.scm b/module/vcomponent/datetime/output.scm
index fa662286..a0ab9941 100644
--- a/module/vcomponent/datetime/output.scm
+++ b/module/vcomponent/datetime/output.scm
@@ -5,6 +5,7 @@
:use-module (datetime)
:use-module (vcomponent base)
:use-module (text util)
+ :use-module (calp translation)
)
(define-config summary-filter (lambda (_ a) a)
@@ -14,13 +15,14 @@
pre: (ensure procedure?))
;; ev → sxml
+;; TODO translation
(define-public (format-recurrence-rule ev)
- `("Upprepas "
+ `(,(_ "Upprepas ")
,((@ (vcomponent recurrence display) format-recurrence-rule)
(prop ev 'RRULE))
,@(awhen (prop* ev 'EXDATE)
(list
- ", undantaget "
+ (_ ", undantaget ")
(add-enumeration-punctuation
(map (lambda (d)
(if (date? d)
@@ -43,7 +45,10 @@
(define-public (format-description ev str)
(catch #t (lambda () ((get-config 'description-filter) ev str))
(lambda (err . args)
- (warning "~a on formatting description, ~s" 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
diff --git a/module/vcomponent/formats/common/types.scm b/module/vcomponent/formats/common/types.scm
index efe17f36..9768cf70 100644
--- a/module/vcomponent/formats/common/types.scm
+++ b/module/vcomponent/formats/common/types.scm
@@ -5,13 +5,14 @@
:use-module (datetime)
:use-module (srfi srfi-9 gnu)
:use-module (datetime timespec)
+ :use-module (calp translation)
)
;; BINARY
(define (parse-binary props value)
;; p 30
(unless (string=? "BASE64" (hashq-ref props 'ENCODING))
- (warning "Binary field not marked ENCODING=BASE64"))
+ (warning (_ "Binary field not marked ENCODING=BASE64")))
;; For icalendar no extra whitespace is allowed in a
;; binary field (except for line wrapping). This differs
@@ -23,7 +24,7 @@
(cond
[(string=? "TRUE" value) #t]
[(string=? "FALSE" value) #f]
- [else (warning "~a invalid boolean" value)]))
+ [else (warning (_ "~a invalid boolean") value)]))
;; CAL-ADDRESS ⇒ uri
@@ -56,7 +57,7 @@
(define (parse-integer props value)
(let ((n (string->number value)))
(unless (integer? n)
- (warning "Non integer as integer"))
+ (warning (_ "Non integer as integer")))
n))
;; PERIOD
@@ -87,7 +88,7 @@
(case (cadr rem)
[(#\n #\N) (loop (cddr rem) (cons #\newline str) done)]
[(#\; #\, #\\) => (lambda (c) (loop (cddr rem) (cons c str) done))]
- [else => (lambda (c) (warning "Non-escapable character: ~a" c)
+ [else => (lambda (c) (warning (_ "Non-escapable character: ~a") c)
(loop (cddr rem) str done))])]
[(#\,)
(loop (cdr rem) '() (cons (reverse-list->string str) done))]
@@ -136,4 +137,4 @@
(define-public (get-parser type)
(or (hashq-ref type-parsers type #f)
- (error "No parser for type" type)))
+ (error (_ "No parser for type") type)))
diff --git a/module/vcomponent/formats/ical/output.scm b/module/vcomponent/formats/ical/output.scm
index fba8bffc..489cdc00 100644
--- a/module/vcomponent/formats/ical/output.scm
+++ b/module/vcomponent/formats/ical/output.scm
@@ -15,6 +15,7 @@
:use-module (vcomponent geo)
:use-module (vcomponent formats ical types)
:use-module (vcomponent recurrence)
+ :use-module (calp translation)
:autoload (vcomponent util instance) (global-event-object)
)
@@ -90,7 +91,7 @@
(get-writer 'TEXT)]
[else
- (warning "Unknown key ~a" key)
+ (warning (_ "Unknown key ~a") key)
(get-writer 'TEXT)]))
(catch #t #; 'wrong-type-arg
diff --git a/module/vcomponent/formats/ical/parse.scm b/module/vcomponent/formats/ical/parse.scm
index 34812a2c..8b6cffeb 100644
--- a/module/vcomponent/formats/ical/parse.scm
+++ b/module/vcomponent/formats/ical/parse.scm
@@ -9,6 +9,7 @@
:use-module (vcomponent base)
:use-module (vcomponent geo)
:use-module (vcomponent formats common types)
+ :use-module (calp translation)
)
(define string->symbol
@@ -120,7 +121,7 @@
(lambda (params value)
(let ((vv (parser params value)))
(when (list? vv)
- (throw 'parse-error "List in enum field"))
+ (throw 'parse-error (_ "List in enum field")))
(let ((v (string->symbol vv)))
(unless (memv v enum)
(warning "~a ∉ { ~{~a~^, ~} }"
@@ -155,7 +156,7 @@
(lambda (params value)
(let ((v ((get-parser 'TEXT) params value)))
(unless (= 1 (length v))
- (warning "List in non-list field: ~s" v))
+ (warning (_ "List in non-list field: ~s") v))
(string-join v ",")))]
;; TEXT, but allow a list
@@ -192,7 +193,7 @@
DRAFT FINAL CANCELED))]
[(memv key '(REQUEST-STATUS))
- (throw 'parse-error "TODO Implement REQUEST-STATUS")]
+ (throw 'parse-error (_ "TODO Implement REQUEST-STATUS"))]
[(memv key '(ACTION))
(enum-parser '(AUDIO DISPLAY EMAIL
@@ -226,7 +227,7 @@
(compose car (get-parser 'TEXT))]
[else
- (warning "Unknown key ~a" key)
+ (warning (_ "Unknown key ~a") key)
(compose car (get-parser 'TEXT))])))
;; If we produced a list create multiple VLINES from it.
@@ -273,9 +274,15 @@
(lambda (fmt . args)
(let ((linedata (get-metadata head*)))
(format
- #f "WARNING parse error around ~a
+ #f
+ ;; arguments:
+ ;; linedata
+ ;; ~?
+ ;; source line
+ ;; source file
+ (_ "WARNING parse error around ~a
~?
- line ~a ~a~%"
+ line ~a ~a~%")
(get-string linedata)
fmt args
(get-line linedata)
@@ -321,10 +328,16 @@
(lambda (err fmt . args)
(let ((linedata (get-metadata head*)))
(display (format
- #f "ERROR parse error around ~a
+ #f
+ ;; arguments
+ ;; linedata
+ ;; ~?
+ ;; source line
+ ;; source file
+ (_ "ERROR parse error around ~a
~?
line ~a ~a
- Defaulting to string~%"
+ Defaulting to string~%")
(get-string linedata)
fmt args
(get-line linedata)
diff --git a/module/vcomponent/formats/ical/types.scm b/module/vcomponent/formats/ical/types.scm
index 39b3b1e3..67f9f633 100644
--- a/module/vcomponent/formats/ical/types.scm
+++ b/module/vcomponent/formats/ical/types.scm
@@ -4,7 +4,9 @@
:use-module (hnh util exceptions)
:use-module (base64)
:use-module (datetime)
- :use-module (datetime timespec))
+ :use-module (datetime timespec)
+ :use-module (calp translation)
+ )
;; TODO shouldn't these really take vline:s?
@@ -35,7 +37,7 @@
;; TODO
(define (write-period _ value)
- (warning "PERIOD writer not yet implemented")
+ (warning (_ "PERIOD writer not yet implemented"))
(with-output-to-string
(lambda () (write value))))
@@ -92,4 +94,4 @@
(define-public (get-writer type)
(or (hashq-ref type-writers type #f)
- (error "No writer for type" type)))
+ (error (_ "No writer for type") type)))
diff --git a/module/vcomponent/formats/vdir/parse.scm b/module/vcomponent/formats/vdir/parse.scm
index c4a48889..4fc96e71 100644
--- a/module/vcomponent/formats/vdir/parse.scm
+++ b/module/vcomponent/formats/vdir/parse.scm
@@ -15,6 +15,7 @@
:use-module ((hnh util path) :select (path-append))
:use-module (hnh util exceptions)
:use-module (vcomponent base)
+ :use-module (calp translation)
:use-module (vcomponent formats ical parse)
)
@@ -58,7 +59,7 @@
;; by RECURRENCE-ID. As far as I can tell this goes against
;; the standard. Section 3.8.4.4.
(case (length events)
- [(0) (warning "No events in component~%~a"
+ [(0) (warning (_ "No events in component~%~a")
(prop item '-X-HNH-FILENAME))]
[(1)
(let ((child (car events)))
diff --git a/module/vcomponent/formats/xcal/output.scm b/module/vcomponent/formats/xcal/output.scm
index 81fab41c..26018d92 100644
--- a/module/vcomponent/formats/xcal/output.scm
+++ b/module/vcomponent/formats/xcal/output.scm
@@ -7,6 +7,7 @@
:use-module (ice-9 match)
:use-module (datetime)
:use-module (srfi srfi-1)
+ :use-module (calp translation)
)
@@ -69,7 +70,7 @@
(get-writer 'TEXT)]
[else
- (warning "Unknown key ~a" key)
+ (warning (_ "Unknown key ~a") key)
(get-writer 'TEXT)]))
(writer ((@@ (vcomponent base) get-vline-parameters) vline) (value vline)))
diff --git a/module/vcomponent/formats/xcal/parse.scm b/module/vcomponent/formats/xcal/parse.scm
index 7dee8d67..66bb8460 100644
--- a/module/vcomponent/formats/xcal/parse.scm
+++ b/module/vcomponent/formats/xcal/parse.scm
@@ -9,6 +9,7 @@
:use-module (vcomponent formats common types)
:use-module (datetime)
:use-module (srfi srfi-1)
+ :use-module (calp translation)
)
;; symbol, ht, (list a) -> non-list
@@ -83,7 +84,7 @@
(string->number value))
(else (throw
'key-error
- "Invalid type ~a, with value ~a"
+ (_ "Invalid type ~a, with value ~a")
type value))))))
;; freq until count interval wkst
@@ -153,7 +154,7 @@
(case tag-name
[(request-status)
;; TODO
- (warning "Request status not yet implemented")
+ (warning (_ "Request status not yet implemented"))
#f]
((transp) (parse-enum
diff --git a/module/vcomponent/formats/xcal/types.scm b/module/vcomponent/formats/xcal/types.scm
index 05fbc8c6..8f13d3d1 100644
--- a/module/vcomponent/formats/xcal/types.scm
+++ b/module/vcomponent/formats/xcal/types.scm
@@ -2,6 +2,7 @@
:use-module (hnh util)
:use-module (vcomponent formats ical types)
:use-module (datetime)
+ :use-module (calp translation)
)
(define (write-boolean _ v)
@@ -51,4 +52,4 @@
(define-public (get-writer type)
(or (hashq-ref sxml-writers type #f)
- (error "No writer for type" type)))
+ (error (_ "No writer for type") type)))
diff --git a/module/vcomponent/util/instance.scm b/module/vcomponent/util/instance.scm
index 6e1e765f..d17b672a 100644
--- a/module/vcomponent/util/instance.scm
+++ b/module/vcomponent/util/instance.scm
@@ -2,6 +2,7 @@
:use-module (hnh util)
:use-module ((calp util config) :select (get-config))
:use-module ((oop goops) :select (make))
+ :use-module (calp translation)
:export (global-event-object)
)
@@ -18,5 +19,5 @@
(define-public (reload)
(let ((new-value (make (@@ (vcomponent util instance methods) <events>)
calendar-files: (get-config 'calendar-files))))
- (display "Reload done\n" (current-error-port))
+ (format (current-error-port) (_ "Reload done~%"))
(set! global-event-object new-value)))
diff --git a/module/vcomponent/util/instance/methods.scm b/module/vcomponent/util/instance/methods.scm
index 120ab2fe..e2e8a777 100644
--- a/module/vcomponent/util/instance/methods.scm
+++ b/module/vcomponent/util/instance/methods.scm
@@ -11,6 +11,8 @@
:use-module ((vcomponent datetime) :select (ev-time<?))
:use-module (oop goops)
+ :use-module (calp translation)
+
:export (add-event
remove-event
@@ -50,7 +52,7 @@
(define-method (initialize (this <events>) args)
(next-method)
- (format (current-error-port) "Building <events> from~%")
+ (format (current-error-port) (_ "Building <events> from~%"))
(for calendar in (slot-ref this 'calendar-files)
(format (current-error-port) " - ~a~%" calendar))
diff --git a/module/vcomponent/util/parse-cal-path.scm b/module/vcomponent/util/parse-cal-path.scm
index 11a32064..7a5fea29 100644
--- a/module/vcomponent/util/parse-cal-path.scm
+++ b/module/vcomponent/util/parse-cal-path.scm
@@ -2,6 +2,7 @@
:use-module (hnh util)
:use-module ((calp util time) :select (report-time!))
:use-module (vcomponent base)
+ :use-module (calp translation)
:use-module ((vcomponent formats ical parse)
:select (parse-calendar))
:use-module ((vcomponent formats vdir parse)
@@ -19,13 +20,13 @@
(set! (prop comp '-X-HNH-SOURCETYPE) 'file)
comp) ]
[(directory)
- (report-time! "Parsing ~a" path)
+ (report-time! (_ "Parsing ~a") path)
(let ((comp (parse-vdir path)))
(set! (prop comp '-X-HNH-SOURCETYPE) 'vdir
(prop comp '-X-HNH-DIRECTORY) path)
comp)]
[(block-special char-special fifo socket unknown symlink)
- => (lambda (t) (error "Can't parse file of type " t))]))
+ => (lambda (t) (error (_ "Can't parse file of type ") t))]))
(unless (prop cal "NAME")
(set! (prop cal "NAME")