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
commit 4e89d0c061
4 changed files with 32 additions and 27 deletions

View file

@ -508,17 +508,22 @@ utilities}).
(display (gettext "You are in a maze of twisty passages."))
@end example
@code{_} is a commonly used shorthand, an application can make that an
alias for @code{gettext}. Or a library can make a definition that
uses its specific @var{domain} (so an application can change the
default without affecting the library).
It is conventional to use @code{G_} as a shorthand for
@code{gettext}.@footnote{Users of @code{gettext} might be a bit
surprised that @code{G_} is the conventional abbreviation for
@code{gettext}. In most other languages, the conventional shorthand is
@code{_}. Guile uses @code{G_} because @code{_} is already taken, as it
is bound to a syntactic keyword used by @code{syntax-rules},
@code{match}, and other macros.} Libraries can define @code{G_} in such
a way to look up translations using its specific @var{domain}, allowing
different parts of a program to have different translation sources.
@example
(define (_ msg) (gettext msg "mylibrary"))
(display (_ "File not found."))
(define (G_ msg) (gettext msg "mylibrary"))
(display (G_ "File not found."))
@end example
@code{_} is also a good place to perhaps strip disambiguating extra
@code{G_} is also a good place to perhaps strip disambiguating extra
text from the message string, as for instance in @ref{GUI program
problems,, How to use @code{gettext} in GUI programs, gettext, GNU
@code{gettext} utilities}.