summaryrefslogtreecommitdiff
path: root/doc/ref/api-i18n.texi
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2019-09-12 21:45:26 +0200
committerAndy Wingo <wingo@pobox.com>2019-09-12 21:50:35 +0200
commit4e89d0c061c585ca56a96ef8410dad17979ca5eb (patch)
treee0ab410bed78b2140020f089f7aed2a6ced1b255 /doc/ref/api-i18n.texi
parentd1cf8928802843a14c53f2a2de55bf01e75e2662 (diff)
downloadguile-4e89d0c061c585ca56a96ef8410dad17979ca5eb.tar.gz
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 _.
Diffstat (limited to 'doc/ref/api-i18n.texi')
-rw-r--r--doc/ref/api-i18n.texi19
1 files changed, 12 insertions, 7 deletions
diff --git a/doc/ref/api-i18n.texi b/doc/ref/api-i18n.texi
index 0a27285b1..7c49b0a23 100644
--- a/doc/ref/api-i18n.texi
+++ b/doc/ref/api-i18n.texi
@@ -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}.