From: Bruno Haible Date: Mon, 15 Nov 2004 11:11:26 +0000 (+0000) Subject: More doc about shell scripts. X-Git-Tag: v0.14.2~218 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f72aa0540a5b615acf64303c05be95230514bab;p=thirdparty%2Fgettext.git More doc about shell scripts. --- diff --git a/gettext-tools/doc/ChangeLog b/gettext-tools/doc/ChangeLog index 77b1aae4b..5ad7f0d09 100644 --- a/gettext-tools/doc/ChangeLog +++ b/gettext-tools/doc/ChangeLog @@ -1,3 +1,7 @@ +2004-11-13 Bruno Haible + + * gettext.texi (Preparing Shell Scripts): Document extra backslashing. + 2004-09-08 Bruno Haible * Makefile.am (EXTRA_DIST): Add FAQ.html. diff --git a/gettext-tools/doc/gettext.texi b/gettext-tools/doc/gettext.texi index 24165e3f0..11d27bb40 100644 --- a/gettext-tools/doc/gettext.texi +++ b/gettext-tools/doc/gettext.texi @@ -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