ui: Make diagnostic message prefix translatable.
* guix/ui.scm (define-diagnostic): Expect PREFIX to be enclosed in 'G_'. Emit call to 'gettext' on PREFIX. (warning, info, report-error): Wrap prefix in 'G_'.
This commit is contained in:
parent
32813e8440
commit
26a2021a1f
23
guix/ui.scm
23
guix/ui.scm
|
@ -124,9 +124,11 @@
|
|||
;;;
|
||||
;;; Code:
|
||||
|
||||
(define-syntax-rule (define-diagnostic name prefix)
|
||||
(define-syntax define-diagnostic
|
||||
(syntax-rules ()
|
||||
"Create a diagnostic macro (i.e., NAME), which will prepend PREFIX to all
|
||||
messages."
|
||||
((_ name (G_ prefix))
|
||||
(define-syntax name
|
||||
(lambda (x)
|
||||
(syntax-case x ()
|
||||
|
@ -135,8 +137,9 @@ messages."
|
|||
(free-identifier=? #'underscore #'G_))
|
||||
#'(begin
|
||||
(format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
|
||||
(program-name) (program-name) prefix)
|
||||
(format (guix-warning-port) (gettext fmt)
|
||||
(program-name) (program-name)
|
||||
(gettext prefix %gettext-domain))
|
||||
(format (guix-warning-port) (gettext fmt %gettext-domain)
|
||||
args (... ...))))
|
||||
((name (N-underscore singular plural n) args (... ...))
|
||||
(and (string? (syntax->datum #'singular))
|
||||
|
@ -144,15 +147,19 @@ messages."
|
|||
(free-identifier=? #'N-underscore #'N_))
|
||||
#'(begin
|
||||
(format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
|
||||
(program-name) (program-name) prefix)
|
||||
(program-name) (program-name)
|
||||
(gettext prefix %gettext-domain))
|
||||
(format (guix-warning-port)
|
||||
(ngettext singular plural n %gettext-domain)
|
||||
args (... ...))))))))
|
||||
args (... ...))))))))))
|
||||
|
||||
(define-diagnostic warning "warning: ") ; emit a warning
|
||||
(define-diagnostic info "")
|
||||
;; XXX: This doesn't work well for right-to-left languages.
|
||||
;; TRANSLATORS: The goal is to emit "warning:" followed by a short phrase;
|
||||
;; "~a" is a placeholder for that phrase.
|
||||
(define-diagnostic warning (G_ "warning: ")) ;emit a warning
|
||||
(define-diagnostic info (G_ ""))
|
||||
|
||||
(define-diagnostic report-error "error: ")
|
||||
(define-diagnostic report-error (G_ "error: "))
|
||||
(define-syntax-rule (leave args ...)
|
||||
"Emit an error message and exit."
|
||||
(begin
|
||||
|
|
Loading…
Reference in New Issue