1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 09:10:22 +02:00

Use "G_" as the conventional alias for gettext

Since the change in 2.2 noted in the NEWS as "Fix literal matching for
module-bound literals", defining `_' makes `syntax-rules' and `match'
fail to recognize `_' as the catch-all literal.  This change adapts the
recommendations to current practice in 2.2, as users have had to adapt
to this change.

* doc/ref/api-i18n.texi (Gettext Support): Update documentation.
* module/language/tree-il/analyze.scm (proc-ref?, gettext?): G_ is the
  conventional abbreviation, not _.
* test-suite/tests/tree-il.test: Adapt.
* module/ice-9/command-line.scm: Use G_ instead of _.
This commit is contained in:
Andy Wingo 2019-09-12 21:45:26 +02:00
parent d1cf892880
commit 4e89d0c061
4 changed files with 32 additions and 27 deletions

View file

@ -40,15 +40,15 @@
emit-bug-reporting-address))
;; An initial stab at i18n.
(define _ gettext)
(define G_ gettext)
(define *GPLv3+*
(_ "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
(G_ "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."))
(define *LGPLv3+*
(_ "License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
(G_ "License LGPLv3+: GNU LGPL 3 or later <http://gnu.org/licenses/lgpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."))
@ -79,8 +79,8 @@ There is NO WARRANTY, to the extent permitted by law."))
(if packager
(if packager-version
(format port (_ "Packaged by ~a (~a)\n") packager packager-version)
(format port (_ "Packaged by ~a\n") packager)))
(format port (G_ "Packaged by ~a (~a)\n") packager packager-version)
(format port (G_ "Packaged by ~a\n") packager)))
(display copyright port)
(newline port)
@ -98,15 +98,15 @@ There is NO WARRANTY, to the extent permitted by law."))
package
"/"))
packager packager-bug-address)
(format port (_ "\nReport bugs to: ~a\n") bug-address)
(format port (G_ "\nReport bugs to: ~a\n") bug-address)
(if (and packager packager-bug-address)
(format port (_ "Report ~a bugs to: ~a\n") packager packager-bug-address))
(format port (_ "~a home page: <~a>\n") package url)
(format port (G_ "Report ~a bugs to: ~a\n") packager packager-bug-address))
(format port (G_ "~a home page: <~a>\n") package url)
(format port
(_ "General help using GNU software: <http://www.gnu.org/gethelp/>\n")))
(G_ "General help using GNU software: <http://www.gnu.org/gethelp/>\n")))
(define *usage*
(_ "Evaluate code with Guile, interactively or from a script.
(G_ "Evaluate code with Guile, interactively or from a script.
[-s] FILE load source code from FILE, and exit
-c EXPR evalute expression EXPR, and exit
@ -151,7 +151,7 @@ If FILE begins with `-' the -s switch is mandatory.
(apply format port fmt args)
(newline port))
(format port (_ "Usage: ~a [OPTION]... [FILE]...\n") name)
(format port (G_ "Usage: ~a [OPTION]... [FILE]...\n") name)
(display *usage* port)
(newline port)

View file

@ -1,6 +1,6 @@
;;; TREE-IL -> GLIL compiler
;; Copyright (C) 2001, 2008-2014, 2018 Free Software Foundation, Inc.
;; Copyright (C) 2001,2008-2014,2016,2018-2019 Free Software Foundation, Inc.
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
@ -1422,7 +1422,7 @@ resort, return #t when EXP refers to the global variable SPECIAL-NAME."
(match exp
(($ <toplevel-ref> _ _ (? special?))
;; Allow top-levels like: (define _ (cut gettext <> "my-domain")).
;; Allow top-levels like: (define G_ (cut gettext <> "my-domain")).
#t)
(($ <toplevel-ref> _ _ name)
(let ((var (module-variable env name)))
@ -1440,7 +1440,7 @@ resort, return #t when EXP refers to the global variable SPECIAL-NAME."
#t)
(_ #f)))
(define gettext? (cut proc-ref? <> gettext '_ <>))
(define gettext? (cut proc-ref? <> gettext 'G_ <>))
(define ngettext? (cut proc-ref? <> ngettext 'N_ <>))
(define (const-fmt x env)
@ -1450,7 +1450,7 @@ resort, return #t when EXP refers to the global variable SPECIAL-NAME."
exp)
(($ <call> _ (? (cut gettext? <> env))
(($ <const> _ (? string? fmt))))
;; Gettexted literals, like `(_ "foo")'.
;; Gettexted literals, like `(G_ "foo")'.
fmt)
(($ <call> _ (? (cut ngettext? <> env))
(($ <const> _ (? string? fmt)) ($ <const> _ (? string?)) _ ..1))