From 093ef72e6489d96fb6ffae8d58d7cb1cb7ff77ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 22 Feb 2022 11:19:19 +0100 Subject: Prepare code for translation. --- module/vcomponent/formats/common/types.scm | 11 ++++++----- module/vcomponent/formats/ical/output.scm | 3 ++- module/vcomponent/formats/ical/parse.scm | 29 +++++++++++++++++++++-------- module/vcomponent/formats/ical/types.scm | 8 +++++--- module/vcomponent/formats/vdir/parse.scm | 3 ++- module/vcomponent/formats/xcal/output.scm | 3 ++- module/vcomponent/formats/xcal/parse.scm | 5 +++-- module/vcomponent/formats/xcal/types.scm | 3 ++- 8 files changed, 43 insertions(+), 22 deletions(-) (limited to 'module/vcomponent/formats') 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))) -- cgit v1.2.3