]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
More doc about shell scripts.
authorBruno Haible <bruno@clisp.org>
Mon, 15 Nov 2004 11:11:26 +0000 (11:11 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:11:56 +0000 (12:11 +0200)
gettext-tools/doc/ChangeLog
gettext-tools/doc/gettext.texi

index 77b1aae4b9563d168e558e275824504030d3bd50..5ad7f0d09b47a2a16fa02df1b36052a77a12a8c0 100644 (file)
@@ -1,3 +1,7 @@
+2004-11-13  Bruno Haible  <bruno@clisp.org>
+
+       * gettext.texi (Preparing Shell Scripts): Document extra backslashing.
+
 2004-09-08  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.am (EXTRA_DIST): Add FAQ.html.
index 24165e3f0c13b993f0c1a89a67e41c37185f2b3d..11d27bb40d4eeb36ee31f9a88cf3a1f7f3bd782e 100644 (file)
@@ -7928,6 +7928,43 @@ followed by a no-argument @samp{echo} command (to account for the terminating
 newline). Similarly, for cases with plural handling, replace a conditional
 @samp{echo} command with an invocation of @samp{ngettext} or
 @samp{eval_ngettext}, followed by a no-argument @samp{echo} command.
+
+When doing this, you also need to add an extra backslash before the dollar
+sign in references to shell variables, so that the @samp{eval_gettext}
+function receives the translatable string before the variable values are
+substituted into it. For example,
+
+@smallexample
+echo "Remaining files: $filecount"
+@end smallexample
+
+becomes
+
+@smallexample
+eval_gettext "Remaining files: \$filecount"; echo
+@end smallexample
+
+If the output command is not @samp{echo}, you can make it use @samp{echo}
+nevertheless, through the use of backquotes. However, note that inside
+backquotes, backslashes must be doubled to be effective (because the
+backquoting eats one level of backslashes). For example, assuming that
+@samp{error} is a shell function that signals an error,
+
+@smallexample
+error "file not found: $filename"
+@end smallexample
+
+is first transformed into
+
+@smallexample
+error "`echo \"file not found: \$filename\"`"
+@end smallexample
+
+which then becomes
+
+@smallexample
+error "`eval_gettext \"file not found: \\\$filename\"`"
+@end smallexample
 @end enumerate
 
 @node gettext.sh, gettext Invocation, Preparing Shell Scripts, sh