mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-02-06 11:00:19 +01:00
ui: Fix i18n for diagnostic messages.
Until now, we'd pass 'gettext' the "augmented" format string, which 'gettext' would not find in message catalogs. Now we pass it FMT as is, which is what catalogs contain. * guix/ui.scm (define-diagnostic)[augmented-format-string]: Remove. Emit one 'format' call to print the prefix, and a second one to print the actual message.
This commit is contained in:
parent
5d9f9ad631
commit
32813e8440
1 changed files with 9 additions and 13 deletions
22
guix/ui.scm
22
guix/ui.scm
|
@ -129,28 +129,24 @@
|
||||||
messages."
|
messages."
|
||||||
(define-syntax name
|
(define-syntax name
|
||||||
(lambda (x)
|
(lambda (x)
|
||||||
(define (augmented-format-string fmt)
|
|
||||||
(string-append "~:[~*~;guix ~a: ~]~a" (syntax->datum fmt)))
|
|
||||||
|
|
||||||
(syntax-case x ()
|
(syntax-case x ()
|
||||||
((name (underscore fmt) args (... ...))
|
((name (underscore fmt) args (... ...))
|
||||||
(and (string? (syntax->datum #'fmt))
|
(and (string? (syntax->datum #'fmt))
|
||||||
(free-identifier=? #'underscore #'G_))
|
(free-identifier=? #'underscore #'G_))
|
||||||
(with-syntax ((fmt* (augmented-format-string #'fmt))
|
#'(begin
|
||||||
(prefix (datum->syntax x prefix)))
|
(format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
|
||||||
#'(format (guix-warning-port) (gettext fmt*)
|
(program-name) (program-name) prefix)
|
||||||
(program-name) (program-name) prefix
|
(format (guix-warning-port) (gettext fmt)
|
||||||
args (... ...))))
|
args (... ...))))
|
||||||
((name (N-underscore singular plural n) args (... ...))
|
((name (N-underscore singular plural n) args (... ...))
|
||||||
(and (string? (syntax->datum #'singular))
|
(and (string? (syntax->datum #'singular))
|
||||||
(string? (syntax->datum #'plural))
|
(string? (syntax->datum #'plural))
|
||||||
(free-identifier=? #'N-underscore #'N_))
|
(free-identifier=? #'N-underscore #'N_))
|
||||||
(with-syntax ((s (augmented-format-string #'singular))
|
#'(begin
|
||||||
(p (augmented-format-string #'plural))
|
(format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
|
||||||
(prefix (datum->syntax x prefix)))
|
(program-name) (program-name) prefix)
|
||||||
#'(format (guix-warning-port)
|
(format (guix-warning-port)
|
||||||
(ngettext s p n %gettext-domain)
|
(ngettext singular plural n %gettext-domain)
|
||||||
(program-name) (program-name) prefix
|
|
||||||
args (... ...))))))))
|
args (... ...))))))))
|
||||||
|
|
||||||
(define-diagnostic warning "warning: ") ; emit a warning
|
(define-diagnostic warning "warning: ") ; emit a warning
|
||||||
|
|
Loading…
Add table
Reference in a new issue