summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivien Kraus <vivien@planete-kraus.eu>2024-02-16 21:13:42 +0100
committerVivien Kraus <vivien@planete-kraus.eu>2024-02-16 21:13:42 +0100
commit0b72e9f387d427a0cb5d0b00ab814afc1fe7a626 (patch)
tree4140d34a16db5819b7bf6859e51c9361876df1b1
parent25fb0449940d96aeae65c9896380eaf88e5be294 (diff)
Set up i18n
-rw-r--r--guile/email-key-rotation.scm19
-rw-r--r--guile/email-key-rotation/dkim.scm19
-rw-r--r--guile/email-key-rotation/dns.scm13
-rw-r--r--guile/email-key-rotation/gandi.scm11
-rw-r--r--guile/email-key-rotation/openssl.scm13
-rw-r--r--guile/email-key-rotation/srs.scm19
-rw-r--r--guile/email-key-rotation/tests.scm56
-rw-r--r--guile/email-key-rotation/tests/fake-gandi-livedns.scm23
-rw-r--r--guile/email-key-rotation/tests/fake-openssl.scm7
9 files changed, 106 insertions, 74 deletions
diff --git a/guile/email-key-rotation.scm b/guile/email-key-rotation.scm
index de6fdec..2c5d5f6 100644
--- a/guile/email-key-rotation.scm
+++ b/guile/email-key-rotation.scm
@@ -7,6 +7,7 @@
#:use-module (ice-9 exceptions)
#:use-module (ice-9 match)
#:use-module (ice-9 receive)
+ #:use-module (ice-9 i18n)
#:use-module (srfi srfi-9 gnu)
#:use-module (sxml match)
#:use-module (sxml simple)
@@ -34,6 +35,8 @@
materialize)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define-immutable-record-type <configuration>
(make-configuration dkim-state srs-state private-opensmtpd-config-file dkim-current-selector-file dkim-current-key-file gandi-configuration)
configuration?
@@ -111,7 +114,7 @@
(make-exception-with-origin 'sxml->configuration)
(make-exception-with-irritants (list sxml))
(make-exception-with-message
- "cannot read the XML fragment as a configuration.")
+ (G_ "cannot read the XML fragment as a configuration."))
exn)))
(lambda ()
(receive (essential extra-state)
@@ -127,7 +130,7 @@
(make-exception-with-origin 'xml->configuration)
(make-exception-with-irritants (list port))
(make-exception-with-message
- "cannot read a configuration from file.")
+ (G_ "cannot read a configuration from file."))
exn)))
(lambda ()
(sxml->configuration
@@ -141,7 +144,7 @@
(make-exception-with-origin 'configuration->sxml)
(make-exception-with-irritants (list config))
(make-exception-with-message
- "when converting a configuration to SXML:")
+ (G_ "when converting a configuration to SXML:"))
exn)))
(lambda ()
(match config
@@ -172,7 +175,7 @@
(make-exception
(make-exception-with-irritants (list config-file))
(make-exception-with-message
- (format #f "when materializing the configuration file:"))
+ (format #f (G_ "when materializing the configuration file:")))
exn)))
(lambda ()
(when (and (dkim-state config-file)
@@ -195,7 +198,7 @@
(make-exception
(make-exception-with-irritants (list dns-record))
(make-exception-with-message
- (format #f "when publishing ~a record for ~a:"
+ (format #f (G_ "when publishing ~a record for ~a:")
(dns:type dns-record)
(dns:name dns-record)))
exn)))
@@ -212,7 +215,7 @@
(make-exception
(make-exception-with-irritants (list config-file))
(make-exception-with-message
- (format #f "when writing the private opensmtpd configuration file:"))
+ (format #f (G_ "when writing the private opensmtpd configuration file:")))
exn)))
(lambda ()
(call-with-output-file
@@ -237,7 +240,7 @@
(make-exception-with-origin 'initialize)
(make-exception-with-irritants (list selectors private-opensmtpd-config-file dkim-current-selector-file dkim-current-key-file gandi-api-key gandi-domain))
(make-exception-with-message
- "when creating a new config file")
+ (G_ "when creating a new config file"))
exn)))
(lambda ()
(parameterize
@@ -259,7 +262,7 @@
(make-exception-with-origin 'rotate)
(make-exception-with-irritants (list configuration))
(make-exception-with-message
- "when rotating a config file")
+ (G_ "when rotating a config file"))
exn)))
(lambda ()
(parameterize
diff --git a/guile/email-key-rotation/dkim.scm b/guile/email-key-rotation/dkim.scm
index 69c1a74..f13d5b4 100644
--- a/guile/email-key-rotation/dkim.scm
+++ b/guile/email-key-rotation/dkim.scm
@@ -9,6 +9,7 @@
#:use-module (ice-9 exceptions)
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
+ #:use-module (ice-9 i18n)
#:use-module (srfi srfi-9 gnu)
#:use-module (sxml match)
#:export (<key>
@@ -26,6 +27,8 @@
dns-records)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define-immutable-record-type <key>
(make-key current-selector next-selectors current-private-key expired-private-key)
key?
@@ -43,7 +46,7 @@
(make-exception-with-origin 'sxml->key)
(make-exception-with-irritants (list sxml))
(make-exception-with-message
- "cannot read the XML fragment as a key.")
+ (G_ "cannot read the XML fragment as a key."))
exn)))
(lambda ()
(sxml-match
@@ -78,7 +81,7 @@
(make-exception-with-origin 'key->sxml)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "when converting a DKIM key to SXML:")
+ (G_ "when converting a DKIM key to SXML:"))
exn)))
(lambda ()
(match key
@@ -106,7 +109,7 @@
(make-exception-with-origin 'initialize)
(make-exception-with-irritants (list selectors))
(make-exception-with-message
- "when initializing a new DKIM key:")
+ (G_ "when initializing a new DKIM key:"))
exn)))
(lambda ()
(make-key (car selectors)
@@ -122,7 +125,7 @@
(make-exception-with-origin 'rotate)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "when rotating a DKIM key:")
+ (G_ "when rotating a DKIM key:"))
exn)))
(lambda ()
(match key
@@ -140,7 +143,7 @@
(make-exception-with-origin 'write-current-selector)
(make-exception-with-irritants (list key port))
(make-exception-with-message
- "when writing the DKIM selector to file:")
+ (G_ "when writing the DKIM selector to file:"))
exn)))
(lambda ()
(seek port 0 SEEK_SET)
@@ -155,7 +158,7 @@
(make-exception-with-origin 'write-private-key)
(make-exception-with-irritants (list key port))
(make-exception-with-message
- "when saving a private DKIM key:")
+ (G_ "when saving a private DKIM key:"))
exn)))
(lambda ()
(unless (port? port)
@@ -163,7 +166,7 @@
(make-exception
(make-error)
(make-exception-with-message
- "the port to write must be a port object."))))
+ (G_ "the port to write must be a port object.")))))
(when (file-port? port)
(chmod port #o600))
(seek port 0 SEEK_SET)
@@ -207,7 +210,7 @@
(make-exception-with-origin 'dns-records)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "when computing the DKIM DNS records:")
+ (G_ "when computing the DKIM DNS records:"))
exn)))
(lambda ()
(match key
diff --git a/guile/email-key-rotation/dns.scm b/guile/email-key-rotation/dns.scm
index 620a916..145c8a2 100644
--- a/guile/email-key-rotation/dns.scm
+++ b/guile/email-key-rotation/dns.scm
@@ -5,6 +5,7 @@
#:use-module (ice-9 match)
#:use-module (ice-9 optargs)
#:use-module (ice-9 receive)
+ #:use-module (ice-9 i18n)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-9 gnu)
#:use-module (rnrs bytevectors)
@@ -22,6 +23,8 @@
publish-gandi-livedns)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define-immutable-record-type <dns-record>
(make-dns-record name type value)
dns-record?
@@ -40,12 +43,13 @@
(make-exception-with-origin 'publish-gandi-livedns)
(make-exception-with-irritants (list gandi-configuration record))
(make-exception-with-message
- "cannot update the Gandi livedns.")
+ (G_ "cannot update the Gandi livedns."))
exn)))
(lambda ()
(match record
(($ <dns-record> name type value)
- (format (current-error-port) "Publishing record on Gandi LiveDNS: ~s ~s ~s...\n"
+ (format (current-error-port)
+ (G_ "Publishing record on Gandi LiveDNS: ~s ~s ~s...\n")
name type value)
(let ((path-under-domain `("records" ,name ,type))
(headers `((content-type . (application/json))))
@@ -82,10 +86,11 @@
(make-exception
(make-exception-with-irritants (list response))
(make-exception-with-message
- (format #f "the request failed with ~a ~a."
+ (format #f (G_ "the request failed with ~a ~a.")
(response-code response)
(response-reason-phrase response))))))
- (format (current-error-port) "Publishing record on Gandi LiveDNS: ~s ~s ~s: ~s ~s\n"
+ (format (current-error-port)
+ (G_ "Publishing record on Gandi LiveDNS: ~s ~s ~s: ~s ~s\n")
name type value
(response-code response)
(response-reason-phrase response)))))))))
diff --git a/guile/email-key-rotation/gandi.scm b/guile/email-key-rotation/gandi.scm
index ae9cc84..0c41955 100644
--- a/guile/email-key-rotation/gandi.scm
+++ b/guile/email-key-rotation/gandi.scm
@@ -4,6 +4,7 @@
#:use-module (ice-9 optargs)
#:use-module (ice-9 exceptions)
#:use-module (ice-9 match)
+ #:use-module (ice-9 i18n)
#:use-module (sxml match)
#:use-module (web client)
#:use-module (web uri)
@@ -17,6 +18,8 @@
gandi-livedns-request)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define-immutable-record-type <gandi-configuration>
(make-gandi-configuration api-key domain)
gandi-configuration?
@@ -41,7 +44,7 @@
headers
body))
(make-exception-with-message
- "cannot request Gandi livedns.")
+ (G_ "cannot request Gandi livedns."))
exn)))
(lambda ()
(unless (list? path-under-domain)
@@ -50,7 +53,7 @@
(make-error)
(make-exception-with-irritants (list path-under-domain))
(make-exception-with-message
- "the PATH-UNDER-DOMAIN argument must be a list of path items."))))
+ (G_ "the PATH-UNDER-DOMAIN argument must be a list of path items.")))))
(let ((uri (build-uri
'https
#:host "api.gandi.net"
@@ -81,7 +84,7 @@
(make-exception-with-origin 'sxml->configuration)
(make-exception-with-irritants (list sxml))
(make-exception-with-message
- "cannot read the XML fragment as a gandi configuration.")
+ (G_ "cannot read the XML fragment as a gandi configuration."))
exn)))
(lambda ()
(sxml-match
@@ -99,7 +102,7 @@
(make-exception-with-origin 'configuration->sxml)
(make-exception-with-irritants (list gandi))
(make-exception-with-message
- "when converting a gandi configuration to SXML:")
+ (G_ "when converting a gandi configuration to SXML:"))
exn)))
(lambda ()
(match gandi
diff --git a/guile/email-key-rotation/openssl.scm b/guile/email-key-rotation/openssl.scm
index 418056b..5c0d6ad 100644
--- a/guile/email-key-rotation/openssl.scm
+++ b/guile/email-key-rotation/openssl.scm
@@ -3,6 +3,7 @@
#:use-module (ice-9 rdelim)
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 match)
+ #:use-module (ice-9 i18n)
#:export (current-openssl-binary
generate-key
private-key->public-key
@@ -10,6 +11,8 @@
#:declarative? #t
#:duplicates (merge-generics))
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define current-openssl-binary
(make-parameter
"/usr/bin/openssl"
@@ -22,7 +25,7 @@
(make-exception
(make-exception-with-irritants (list interpreter arguments))
(make-exception-with-message
- "cannot run openssl:")
+ (G_ "cannot run openssl:"))
exn)))
(lambda ()
(let ((ret (apply system* interpreter arguments)))
@@ -32,7 +35,7 @@
(make-error)
(make-exception-with-irritants (list (status:exit-val ret)))
(make-exception-with-message
- (format #f "openssl failed with exit code ~s."
+ (format #f (G_ "openssl failed with exit code ~s.")
(status:exit-val ret)))))))))))
((? procedure? p)
p))))
@@ -48,7 +51,7 @@
(make-exception-with-origin 'generate-key)
(make-exception-with-irritants (list rsa-strength))
(make-exception-with-message
- "cannot generate a private key.")
+ (G_ "cannot generate a private key."))
exn)))
(lambda ()
(let ((port (mkstemp "/tmp/generate-openssl-key-XXXXXX"))
@@ -74,7 +77,7 @@
(make-exception-with-origin 'private-key->public-key)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "cannot convert the private key to public key.")
+ (G_ "cannot convert the private key to public key."))
exn)))
(lambda ()
(let ((input-port (mkstemp "/tmp/openssl-private-key-XXXXXX"))
@@ -107,7 +110,7 @@
(make-exception-with-origin 'random-hex)
(make-exception-with-irritants (list nbytes))
(make-exception-with-message
- (format #f "cannot generate ~a random bytes."
+ (format #f (G_ "cannot generate ~a random bytes.")
nbytes))
exn)))
(lambda ()
diff --git a/guile/email-key-rotation/srs.scm b/guile/email-key-rotation/srs.scm
index aadfc7d..d9d2f64 100644
--- a/guile/email-key-rotation/srs.scm
+++ b/guile/email-key-rotation/srs.scm
@@ -2,6 +2,7 @@
#:use-module ((email-key-rotation openssl) #:prefix openssl:)
#:use-module (ice-9 exceptions)
#:use-module (ice-9 match)
+ #:use-module (ice-9 i18n)
#:use-module (srfi srfi-9 gnu)
#:use-module (sxml match)
#:export (<key>
@@ -15,6 +16,8 @@
write-private-opensmtpd-config)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define-immutable-record-type <key>
(make-key current-secret expired-secret)
key?
@@ -30,7 +33,7 @@
(make-exception-with-origin 'sxml->key)
(make-exception-with-irritants (list sxml))
(make-exception-with-message
- "cannot read the XML fragment as a SRS key.")
+ (G_ "cannot read the XML fragment as a SRS key."))
exn)))
(lambda ()
(sxml-match
@@ -51,7 +54,7 @@
(make-exception-with-origin 'key->sxml)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "when converting a SRS key to SXML:")
+ (G_ "when converting a SRS key to SXML:"))
exn)))
(lambda ()
(match key
@@ -68,7 +71,7 @@
(make-exception
(make-exception-with-origin 'initialize)
(make-exception-with-message
- "when initializing a new SRS key:")
+ (G_ "when initializing a new SRS key:"))
exn)))
(lambda ()
(make-key (openssl:random-hex 32)
@@ -82,7 +85,7 @@
(make-exception-with-origin 'rotate)
(make-exception-with-irritants (list key))
(make-exception-with-message
- "when rotating a SRS key:")
+ (G_ "when rotating a SRS key:"))
exn)))
(lambda ()
(match key
@@ -98,7 +101,7 @@
(make-exception-with-origin 'write-private-opensmtpd-config)
(make-exception-with-irritants (list key port))
(make-exception-with-message
- "when saving a private SRS key:")
+ (G_ "when saving a private SRS key:"))
exn)))
(lambda ()
(unless (port? port)
@@ -106,15 +109,15 @@
(make-exception
(make-error)
(make-exception-with-message
- "the port to write must be a port object."))))
+ (G_ "the port to write must be a port object.")))))
(when (file-port? port)
(chmod port #o600))
(seek port 0 SEEK_SET)
(match key
(($ <key> current expired)
(begin
- (format port "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n
-srs key ~s\n"
+ (format port (G_ "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n"))
+ (format port "srs key ~s\n"
current)
(when expired
(format port "srs key backup ~s\n"
diff --git a/guile/email-key-rotation/tests.scm b/guile/email-key-rotation/tests.scm
index f4eedd7..12dc729 100644
--- a/guile/email-key-rotation/tests.scm
+++ b/guile/email-key-rotation/tests.scm
@@ -7,6 +7,7 @@
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 optargs)
#:use-module (ice-9 exceptions)
+ #:use-module (ice-9 i18n)
#:use-module (srfi srfi-26)
#:use-module (rnrs bytevectors)
#:use-module (sxml simple)
@@ -15,6 +16,8 @@
#:export (run-tests)
#:declarative? #t)
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define (reload config)
(let* ((sxml (configuration->sxml config))
(xml (call-with-output-string
@@ -30,7 +33,7 @@
(make-exception-with-origin 'reload)
(make-exception-with-irritants (list config xml config-back))
(make-exception-with-message
- "cannot serialize and deserialize the configuration"))))
+ (G_ "cannot serialize and deserialize the configuration")))))
config-back))
(define (run-tests)
@@ -41,7 +44,7 @@
(make-error)
(make-exception-with-origin 'run-tests)
(make-exception-with-message
- "the tests failed:")
+ (G_ "the tests failed:"))
exn)))
(lambda ()
;; The process is:
@@ -57,7 +60,7 @@
(raise-exception
(make-exception
(make-exception-with-message
- "during the initialization phase:")
+ (G_ "during the initialization phase:"))
exn)))
(lambda ()
(set! current-config
@@ -92,18 +95,19 @@ Change \"dkimB._domainkey\" TXT record to value \"v=DKIM1; k=rsa; t=s; p=deleted
(make-exception-with-irritants
(list materialize-log-0 expected-log-0))
(make-exception-with-message
- "incorrect gandi livedns requests."))))
+ (G_ "incorrect gandi livedns requests.")))))
(unless (equal?
(call-with-input-file "srs-secrets.conf" get-string-all)
- "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n
-srs key \"hexdatawithseed0\"\n")
+ (string-append
+ (G_ "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n")
+ "srs key \"hexdatawithseed0\"\n"))
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants
(list "srs-secrets.conf"))
(make-exception-with-message
- "incorrect srs-secrets.conf content."))))
+ (G_ "incorrect srs-secrets.conf content.")))))
(unless (equal?
(call-with-input-file "current-dkim-selector.txt"
read-line)
@@ -114,7 +118,7 @@ srs key \"hexdatawithseed0\"\n")
(make-exception-with-irritants
(list "current-dkim-selector.txt"))
(make-exception-with-message
- "incorrect current-dkim-selector.txt content."))))
+ (G_ "incorrect current-dkim-selector.txt content.")))))
(unless (equal?
(call-with-input-file "current-dkim-key.key"
get-string-all)
@@ -125,13 +129,13 @@ srs key \"hexdatawithseed0\"\n")
(make-exception-with-irritants
(list "current-dkim-key.key"))
(make-exception-with-message
- "incorrect current-dkim-key.key content.")))))))
+ (G_ "incorrect current-dkim-key.key content."))))))))
(with-exception-handler
(lambda (exn)
(raise-exception
(make-exception
(make-exception-with-message
- "during the first rotation:")
+ (G_ "during the first rotation:"))
exn)))
(lambda ()
(set! current-config
@@ -161,19 +165,20 @@ Change \"dkimA._domainkey\" TXT record to value \"v=DKIM1; k=rsa; t=s; p=blah bl
(make-exception-with-irritants
(list materialize-log-1 expected-log-1))
(make-exception-with-message
- "incorrect gandi livedns requests."))))
+ (G_ "incorrect gandi livedns requests.")))))
(unless (equal?
(call-with-input-file "srs-secrets.conf" get-string-all)
- "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n
-srs key \"hexdatawithseed1\"
-srs key backup \"hexdatawithseed0\"\n")
+ (string-append
+ (G_ "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n")
+ "srs key \"hexdatawithseed1\"
+srs key backup \"hexdatawithseed0\"\n"))
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants
(list "srs-secrets.conf"))
(make-exception-with-message
- "incorrect srs-secrets.conf content."))))
+ (G_ "incorrect srs-secrets.conf content.")))))
(unless (equal?
(call-with-input-file "current-dkim-selector.txt"
read-line)
@@ -184,7 +189,7 @@ srs key backup \"hexdatawithseed0\"\n")
(make-exception-with-irritants
(list "current-dkim-selector.txt"))
(make-exception-with-message
- "incorrect current-dkim-selector.txt content."))))
+ (G_ "incorrect current-dkim-selector.txt content.")))))
(unless (equal?
(call-with-input-file "current-dkim-key.key"
get-string-all)
@@ -195,13 +200,13 @@ srs key backup \"hexdatawithseed0\"\n")
(make-exception-with-irritants
(list "current-dkim-key.key"))
(make-exception-with-message
- "incorrect current-dkim-key.key content.")))))))
+ (G_ "incorrect current-dkim-key.key content."))))))))
(with-exception-handler
(lambda (exn)
(raise-exception
(make-exception
(make-exception-with-message
- "during the second rotation:")
+ (G_ "during the second rotation:"))
exn)))
(lambda ()
(set! current-config
@@ -231,19 +236,20 @@ Change \"dkimB._domainkey\" TXT record to value \"v=DKIM1; k=rsa; t=s; p=blah bl
(make-exception-with-irritants
(list materialize-log-2 expected-log-2))
(make-exception-with-message
- "incorrect gandi livedns requests."))))
+ (G_ "incorrect gandi livedns requests.")))))
(unless (equal?
(call-with-input-file "srs-secrets.conf" get-string-all)
- "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n
-srs key \"hexdatawithseed2\"
-srs key backup \"hexdatawithseed1\"\n")
+ (string-append
+ (G_ "# GENERATED AUTOMATICALLY, DO NOT EDIT!\n")
+ "srs key \"hexdatawithseed2\"
+srs key backup \"hexdatawithseed1\"\n"))
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants
(list "srs-secrets.conf"))
(make-exception-with-message
- "incorrect srs-secrets.conf content."))))
+ (G_ "incorrect srs-secrets.conf content.")))))
(unless (equal?
(call-with-input-file "current-dkim-selector.txt"
read-line)
@@ -254,7 +260,7 @@ srs key backup \"hexdatawithseed1\"\n")
(make-exception-with-irritants
(list "current-dkim-selector.txt"))
(make-exception-with-message
- "incorrect current-dkim-selector.txt content."))))
+ (G_ "incorrect current-dkim-selector.txt content.")))))
(unless (equal?
(call-with-input-file "current-dkim-key.key"
get-string-all)
@@ -265,4 +271,4 @@ srs key backup \"hexdatawithseed1\"\n")
(make-exception-with-irritants
(list "current-dkim-key.key"))
(make-exception-with-message
- "incorrect current-dkim-key.key content."))))))))))
+ (G_ "incorrect current-dkim-key.key content.")))))))))))
diff --git a/guile/email-key-rotation/tests/fake-gandi-livedns.scm b/guile/email-key-rotation/tests/fake-gandi-livedns.scm
index 4a183ce..79bfcf0 100644
--- a/guile/email-key-rotation/tests/fake-gandi-livedns.scm
+++ b/guile/email-key-rotation/tests/fake-gandi-livedns.scm
@@ -5,6 +5,7 @@
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 match)
#:use-module (ice-9 optargs)
+ #:use-module (ice-9 i18n)
#:use-module (json)
#:use-module (rnrs bytevectors)
#:use-module (web uri)
@@ -14,6 +15,8 @@
#:declarative? #t
#:duplicates (merge-generics))
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define (fake-http-request expected-domain expected-api-key log-port)
(lambda* (uri #:key method headers body)
(unless (or (equal? method 'POST)
@@ -23,42 +26,42 @@
(make-error)
(make-exception-with-irritants (list method))
(make-exception-with-message
- "Gandi method is neither POST nor PUT"))))
+ (G_ "Gandi method is neither POST nor PUT")))))
(unless (equal? (uri-scheme uri) 'https)
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants (list uri))
(make-exception-with-message
- "Gandi URI is not HTTPS."))))
+ (G_ "Gandi URI is not HTTPS.")))))
(unless (equal? (uri-host uri) "api.gandi.net")
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants (list uri))
(make-exception-with-message
- "Wrong Gandi URI host."))))
+ (G_ "Wrong Gandi URI host.")))))
(when (uri-port uri)
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants (list uri))
(make-exception-with-message
- "Custom Gandi URI port."))))
+ (G_ "Custom Gandi URI port.")))))
(when (uri-userinfo uri)
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants (list uri))
(make-exception-with-message
- "Custom Gandi URI userinfo."))))
+ (G_ "Custom Gandi URI userinfo.")))))
(unless (string-prefix? "/" (uri-path uri))
(raise-exception
(make-exception
(make-error)
(make-exception-with-irritants (list uri))
(make-exception-with-message
- "Gandi URI path not absolute."))))
+ (G_ "Gandi URI path not absolute.")))))
(let ((path-components
(split-and-decode-uri-path (uri-path uri))))
(match path-components
@@ -71,7 +74,7 @@
(make-error)
(make-exception-with-irritants (list domain))
(make-exception-with-message
- "wrong domain in Gandi URI path."))))
+ (G_ "wrong domain in Gandi URI path.")))))
(unless (equal? (assoc-ref headers 'content-type)
'(application/json))
(raise-exception
@@ -79,7 +82,7 @@
(make-error)
(make-exception-with-irritants (list headers))
(make-exception-with-message
- "wrong content-type header."))))
+ (G_ "wrong content-type header.")))))
(unless (equal? (assoc-ref headers 'Authorization)
(string-append
"ApiKey " expected-api-key))
@@ -88,7 +91,7 @@
(make-error)
(make-exception-with-irritants (list headers))
(make-exception-with-message
- "wrong Authorization header."))))
+ (G_ "wrong Authorization header.")))))
(when (bytevector? body)
(set! body (utf8->string body)))
(match (json-string->scm body)
@@ -107,7 +110,7 @@
(raise-exception
(make-exception
(make-exception-with-origin 'call-with-fake-gandi-livedns)
- (make-exception-with-message "with fake gandi livedns:")
+ (make-exception-with-message (G_ "with fake gandi livedns:"))
exn)))
(lambda ()
(call-with-output-string
diff --git a/guile/email-key-rotation/tests/fake-openssl.scm b/guile/email-key-rotation/tests/fake-openssl.scm
index e23e148..2feef0d 100644
--- a/guile/email-key-rotation/tests/fake-openssl.scm
+++ b/guile/email-key-rotation/tests/fake-openssl.scm
@@ -4,10 +4,13 @@
#:use-module (ice-9 rdelim)
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 match)
+ #:use-module (ice-9 i18n)
#:export (call-with-fake-openssl)
#:declarative? #t
#:duplicates (merge-generics))
+(define (G_ msg) (gettext msg "email-key-rotation"))
+
(define (call-with-fake-openssl seed thunk)
(parameterize
((current-openssl-binary
@@ -37,7 +40,7 @@ END OF FAKE PUBLIC KEY"
(make-exception-with-origin 'call-with-fake-openssl)
(make-exception-with-irritants (list otherwise))
(make-exception-with-message
- "the private key has not been generated by the fake openssl.")))))))
+ (G_ "the private key has not been generated by the fake openssl."))))))))
(("rand" "-out" file "-hex" (= string->number n-bytes))
(call-with-output-file file
(lambda (port)
@@ -49,5 +52,5 @@ END OF FAKE PUBLIC KEY"
(make-exception-with-origin 'call-with-fake-openssl)
(make-exception-with-irritants (list otherwise))
(make-exception-with-message
- "invalid use of openssl.")))))))
+ (G_ "invalid use of openssl."))))))))
(thunk)))