From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git Mailing List <git@vger.kernel.org>,
Alex Riesen <raa.lkml@gmail.com>
Subject: Re: [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts
Date: Tue, 24 Jan 2012 01:39:26 +0100 [thread overview]
Message-ID: <CACBZZX66-JsS4zZXwv2squcjYUS8v+9cN0hv23t5nMHA+1k9XQ@mail.gmail.com> (raw)
In-Reply-To: <20120123221256.GG20833@burratino>
On Mon, Jan 23, 2012 at 23:12, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Junio C Hamano wrote:
>
>> make USE_GETTEXT_SCHEME=fallthrough
>>
>> This will replace the translation routines with fallthrough versions,
>> that does not use gettext from the platform.
>
> Nice implementation. I still don't understand why NO_GETTEXT=YesPlease
> should not imply this. Is it to ensure the GETTEXT_SCHEME=gnu mode
> gets more testing?
I was the only one with an objection to doing that. The main (and I
admit, at least slightly irrational) reason being that I simply don't
like using fallback functions when the system supplies us with
perfectly good functions we can use instead.
It means we're less likely to share code / fixes / eyeballs / cache
with other programs. I.e. by using envsubst(1) instead of
git-sh-i18n--envsubst--variables(1).
Ironically this is all my fault by naming the option for turning off
translations NO_GETTEXT. What it should be called is
DO_NOT_TRANSLATE_OUTPUT, but since we *need* shell functions to output
anything it might have used a system gettext library to do that,
NO_GETTEXT should have been "I don't have any gettext library, please
supply some fallbacks".
Which would have meant that for people who simply don't want
translated output we'd be using the maintained by upstream envsubst(1)
instead of the doomed to bitrot forever hack I ripped out of some old
GPL2 version of GNU gettext.
Anyway in the grand scheme of things none of this really matters,
these patches can all go in as far as I'm concerned. I can submit
patches to improve it once the dust has settled if I still care
enough.
Aside from this I think not having the ability to run a pre-processor
on the shellscripts results in some really ugly workarounds. This
stuff would be much nicer if we could just generate git-sh-i18n.sh at
compile time depending on some autoconf tests or Makefile options.
And by hacking up a pre-processor that just searches/replaces all the
gettext/eval_gettext calls out of the shell code we could sidestep
this whole issue and there wouldn't be any need for fallback
functions, ever. This would also result in a real improvement on
Windows where exec overhead is much larger.
Like this hack, which doesn't even work, but gives you some idea of
what we could do:
#!/usr/bin/env perl
BEGIN { $^I = ""; }
sub unescape {
my $str = shift;
$str =~ s/\\\$/\$/gs;
$str;
}
LINE: while (defined($_ = <ARGV>)) {
s["\$\(gettext "([^"]+?)"\)"]["$1"]g;
s["\$\(eval_gettext "([^"]+?)"\)"]['"' . unescape($1) . '"']eg;
s[eval_gettextln "([^"]+?)"]['echo "' . unescape($1) . '"']eg;
s[gettext "([^"]+?)"][printf "%s" "$1"]g;
s[gettextln "([^"]+?)"][echo "$1"]g;
# s[gettextln "([^"]+?)"][echo "$1"]g;
# s/foo/bar/;
print;
}
When run:
for f in $(git grep -l gettext -- *.sh); do perl replace-gettext.pl $f; done
Produces output like:
@@ -351 +351 @@ split_patches () {
- clean_abort "$(eval_gettext "Patch format
\$patch_format is not supported.")"
+ clean_abort "Patch format $patch_format is
not supported."
@@ -353 +353 @@ split_patches () {
- clean_abort "$(gettext "Patch format
detection failed.")"
+ clean_abort "Patch format detection failed."
@@ -403 +403 @@ do
- die "$(gettext "-d option is no longer supported.
Do not use.")"
+ die "-d option is no longer supported. Do not use."
@@ -466 +466 @@ then
- die "$(eval_gettext "previous rebase directory \$dotest
still exists but mbox given.")"
+ die "previous rebase directory $dotest still exists but mbox given."
It would be relatively easy to hack up a basic POSIX shell
pre-processor like this that would work on our *.sh files, thus
eliminating the need for all of this fallback business.
next prev parent reply other threads:[~2012-01-24 0:39 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 13:42 [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined Alex Riesen
2012-01-17 19:08 ` Junio C Hamano
2012-01-18 14:25 ` Alex Riesen
2012-01-18 19:54 ` Alex Riesen
2012-01-19 0:12 ` Jonathan Nieder
2012-01-19 9:15 ` Alex Riesen
2012-01-18 15:22 ` Ævar Arnfjörð Bjarmason
2012-01-18 18:57 ` Alex Riesen
2012-01-18 23:18 ` Ævar Arnfjörð Bjarmason
2012-01-19 0:15 ` Jonathan Nieder
2012-01-19 0:17 ` Junio C Hamano
2012-01-19 7:13 ` Johannes Sixt
2012-01-19 18:30 ` Junio C Hamano
2012-01-20 9:50 ` Ævar Arnfjörð Bjarmason
2012-01-20 10:40 ` Alex Riesen
2012-01-20 12:49 ` [PATCH] git-sh-i18n: detect and avoid broken gettext(1) implementation Ævar Arnfjörð Bjarmason
2012-01-20 14:02 ` Alex Riesen
2012-01-20 20:00 ` Junio C Hamano
2012-01-20 20:13 ` Alex Riesen
2012-01-20 20:21 ` Junio C Hamano
2012-01-20 20:24 ` Alex Riesen
2012-01-20 20:26 ` Junio C Hamano
2012-01-20 20:33 ` Alex Riesen
2012-01-20 19:35 ` [PATCH] i18n: disable i18n for shell scripts if NO_GETTEXT defined Junio C Hamano
2012-01-20 19:45 ` Alex Riesen
2012-01-19 9:24 ` Alex Riesen
2012-01-19 9:13 ` Alex Riesen
2012-01-19 19:52 ` [PATCH] add a Makefile switch to avoid gettext translation in shell scripts Alex Riesen
2012-01-23 22:01 ` Junio C Hamano
2012-01-23 22:02 ` [PATCH 1/2] git-sh-i18n: restructure the logic to compute gettext.sh scheme Junio C Hamano
2012-01-23 22:04 ` [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts Junio C Hamano
2012-01-23 22:12 ` Jonathan Nieder
2012-01-23 22:23 ` Junio C Hamano
2012-01-23 22:40 ` Jonathan Nieder
2012-01-24 0:31 ` [PATCH/RFC 3/2] i18n: do not use gettext.sh by default when NO_GETTEXT is set Jonathan Nieder
2012-01-24 20:06 ` Alex Riesen
2012-01-24 0:39 ` Ævar Arnfjörð Bjarmason [this message]
2012-01-24 19:59 ` [PATCH 2/2] add a Makefile switch to avoid gettext translation in shell scripts Alex Riesen
2012-01-24 20:00 ` Alex Riesen
2012-01-24 20:13 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACBZZX66-JsS4zZXwv2squcjYUS8v+9cN0hv23t5nMHA+1k9XQ@mail.gmail.com \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=raa.lkml@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).