Re: [RFC PATCH 0/5] Localise error headers

2017-04-01 Thread Junio C Hamano
Jeff King  writes:

> On Thu, Mar 30, 2017 at 05:18:59PM +0200, Michael J Gruber wrote:
>
>> I read back the whole thread, and I'm still not sure if there's
>> consensus and how to go forward. Should we let the topic die? I don't
>> care too much personally, I just thought the mixed tranlations look
>> "unprofessional".
>
> I don't have a strong preference either way. I also don't care
> personally about the output (as I do not localize at all). My main
> concern was keeping the code simple for developers. But if consistent
> translation is important for people in other languages, I'm OK with
> whatever we need to do.

 (0) I do not mind the status quo, and I do not mind telling an end
 user who comes here with a translated message from die() to try
 running it again in C locale, either.

 (1) I do not think messages (including prefix) from die(),
 warning(), and error() are sacred, even when they are given by
 plumbing commands.  If the list concensus is that we want to
 see all translated in the ideal endgame, I think it is OK not
 to special case the plumbing.

 (2) I found your

 vreportf(_("fatal: "), err, params);

 a reasonable approach, if the we all agree with (1) as our
 goal, and want a way to gradually get us closer to the
 "everything translated" endgame.

I do not know what is professional and what is not in this context,
though ;-).

Michael, thanks for pinging the thread.


Re: [RFC PATCH 0/5] Localise error headers

2017-04-01 Thread Jeff King
On Thu, Mar 30, 2017 at 05:18:59PM +0200, Michael J Gruber wrote:

> Jeff King venit, vidit, dixit 21.01.2017 15:20:
> > On Wed, Jan 11, 2017 at 10:08:46AM -0800, Junio C Hamano wrote:
> > 
> >> Jeff King  writes:
> >>
> >>> Yes, I would think die_errno() is a no-brainer for translation, since
> >>> the strerror() will be translated.
> >>>
>  apply.c:die(_("internal error"));
> 
>  That is funny, too. I think we should substitute that with
> 
>  die("BUG: untranslated, but what went wrong instead")
> >>>
> >>> Yep. We did not consistently use "BUG:" in the early days. I would say
> >>> that "BUG" lines do not need to be translated. The point is that nobody
> >>> should ever see them, so it seems like there is little point in giving
> >>> extra work to translators.
> >>
> >> In addition, "BUG: " is relatively recent introduction to our
> >> codebase.  Perhaps having a separate BUG() function help the
> >> distinction further?
> > 
> > Yes, I think so. I have often been tempted to dump core on BUGs for
> > further analysis. You can do that by string-matching "BUG:" from the
> > beginning of a die message, but it's kind of gross. :)
> > 
> > -Peff
> 
> I read back the whole thread, and I'm still not sure if there's
> consensus and how to go forward. Should we let the topic die? I don't
> care too much personally, I just thought the mixed tranlations look
> "unprofessional".

I don't have a strong preference either way. I also don't care
personally about the output (as I do not localize at all). My main
concern was keeping the code simple for developers. But if consistent
translation is important for people in other languages, I'm OK with
whatever we need to do.

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-03-30 Thread Michael J Gruber
Jeff King venit, vidit, dixit 21.01.2017 15:20:
> On Wed, Jan 11, 2017 at 10:08:46AM -0800, Junio C Hamano wrote:
> 
>> Jeff King  writes:
>>
>>> Yes, I would think die_errno() is a no-brainer for translation, since
>>> the strerror() will be translated.
>>>
 apply.c:die(_("internal error"));

 That is funny, too. I think we should substitute that with

 die("BUG: untranslated, but what went wrong instead")
>>>
>>> Yep. We did not consistently use "BUG:" in the early days. I would say
>>> that "BUG" lines do not need to be translated. The point is that nobody
>>> should ever see them, so it seems like there is little point in giving
>>> extra work to translators.
>>
>> In addition, "BUG: " is relatively recent introduction to our
>> codebase.  Perhaps having a separate BUG() function help the
>> distinction further?
> 
> Yes, I think so. I have often been tempted to dump core on BUGs for
> further analysis. You can do that by string-matching "BUG:" from the
> beginning of a die message, but it's kind of gross. :)
> 
> -Peff

I read back the whole thread, and I'm still not sure if there's
consensus and how to go forward. Should we let the topic die? I don't
care too much personally, I just thought the mixed tranlations look
"unprofessional".

Michael



Re: [RFC PATCH 0/5] Localise error headers

2017-01-21 Thread Jeff King
On Wed, Jan 11, 2017 at 09:15:22AM -0800, Stefan Beller wrote:

> > That's the assumption I'm challenging. Certainly the behavior and
> > certain aspects of the output of a plumbing command should remain the
> > same over time. But error messages to stderr?
> 
> In an ideal world that assumption would hold true and any machine
> readable information from the plumbing commands are on stdout and
> nobody in their sane mind would ever try to parse stderr.
> 
> There is no easy way to check though except auditing all the code.
> Having pointed out some string handling mistakes in the prior email,
> my confidence is not high that plumbing commands are that strict about
> separating useful machine output and errors for human consumption.

I think it's impossible to audit all the code, because "all the code"
includes things not in git itself. It would really take a willingness to
declare "if you are parsing stderr you're doing it wrong".

I suppose the unpack-trees example speaks against that. I'm not sure
that is sane overall, but it is something we tried to account for in the
past.

If we are just talking about translation, though, it seems like the
right action for a script that really wants to parse stderr is to run
the sub-command with LC_MESSAGES=C. I know that's a breaking change, but
I wonder if it's a reasonable path forward.

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-21 Thread Jeff King
On Wed, Jan 11, 2017 at 10:08:46AM -0800, Junio C Hamano wrote:

> Jeff King  writes:
> 
> > Yes, I would think die_errno() is a no-brainer for translation, since
> > the strerror() will be translated.
> >
> >> apply.c:die(_("internal error"));
> >> 
> >> That is funny, too. I think we should substitute that with
> >> 
> >> die("BUG: untranslated, but what went wrong instead")
> >
> > Yep. We did not consistently use "BUG:" in the early days. I would say
> > that "BUG" lines do not need to be translated. The point is that nobody
> > should ever see them, so it seems like there is little point in giving
> > extra work to translators.
> 
> In addition, "BUG: " is relatively recent introduction to our
> codebase.  Perhaps having a separate BUG() function help the
> distinction further?

Yes, I think so. I have often been tempted to dump core on BUGs for
further analysis. You can do that by string-matching "BUG:" from the
beginning of a die message, but it's kind of gross. :)

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-21 Thread Jeff King
On Fri, Jan 20, 2017 at 08:08:43PM +0700, Duy Nguyen wrote:

> > In addition, "BUG: " is relatively recent introduction to our
> > codebase.  Perhaps having a separate BUG() function help the
> > distinction further?
> 
> I was going to write the same thing. On top of that I wonder if have
> enough "if (something) die("BUG:")" to justify stealing BUG_ON() from
> kernel (better than assert since the condition will always be
> evaluated).

I don't mind BUG_ON() as an improvement over assert(). However, one of
the things I really like about our current die("BUG") is that you
actually write a human-readable message. Quite often that serves as a
comment to the reader of the code as to what is going on, or you can
give additional context in the error message (e.g., which sha1 triggered
the bug).

Still, there are many cases where there's not much to say in the
message. Doing:

  if (!foo)
BUG("foo is NULL in this function");

is just wasting everybody's time. Something like:

  #define BUG_ON(code) do {
if (code)
BUG("%s", #code);
  while(0)

is probably fine. One complication is that BUG() would ideally show the
file/line number. That has to happen in a macro, but we don't assume
variadic macros work everywhere, which we need for the printf-like
behavior. So either we have to loosen that restriction[1], or we end up
with two "tiers": a BUG(fmt, ...) for human-readable messages, and a
more boring version for BUG_ON() which just prints "file:line: BUG:
".

-Peff

[1] I think avoiding variadic macros was reasonable in 2005; C99 was
only 6 years old then. Now it's turning 18. Maybe it's time?


Re: [RFC PATCH 0/5] Localise error headers

2017-01-20 Thread Duy Nguyen
On Fri, Jan 20, 2017 at 8:23 PM, Duy Nguyen  wrote:
> I've tested it a bit. Seems to work ok.

Oops. Didn't notice that the "fatal:" bit is still untranslated but
Micheal's patch can handle that.
-- 
Duy


Re: [RFC PATCH 0/5] Localise error headers

2017-01-20 Thread Duy Nguyen
On Wed, Jan 11, 2017 at 06:37:25AM -0500, Jeff King wrote:
> > To find a good example, "git grep die" giving me some food of though:
> > 
> > die_errno(..) should always take a string marked up for translation,
> > because the errno string is translated?
> 
> Yes, I would think die_errno() is a no-brainer for translation, since
> the strerror() will be translated.

I agree. And the main (*) changes are relative simple too. I've tested
it a bit. Seems to work ok.

-- 8< --
diff --git a/Makefile b/Makefile
index d861bd9985..6f88c6cac5 100644
--- a/Makefile
+++ b/Makefile
@@ -2102,7 +2102,7 @@ XGETTEXT_FLAGS = \
--msgid-bugs-address="Git Mailing List " \
--from-code=UTF-8
 XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
-   --keyword=_ --keyword=N_ --keyword="Q_:1,2"
+   --keyword=_ --keyword=N_ --keyword="Q_:1,2" --keyword=die_errno
 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
--keyword=gettextln --keyword=eval_gettextln
 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --language=Perl \
diff --git a/usage.c b/usage.c
index 17f52c1b5c..c022726f9c 100644
--- a/usage.c
+++ b/usage.c
@@ -159,7 +159,7 @@ void NORETURN die_errno(const char *fmt, ...)
}
 
va_start(params, fmt);
-   die_routine(fmt_with_err(buf, sizeof(buf), fmt), params);
+   die_routine(fmt_with_err(buf, sizeof(buf), _(fmt)), params);
va_end(params);
 }
 
-- 8< --

(*) We would need another patch to remove _() from die_errno(_(..)).
But that's something I expect coccinelle to be excel at.
--
Duy


Re: [RFC PATCH 0/5] Localise error headers

2017-01-20 Thread Duy Nguyen
On Thu, Jan 12, 2017 at 1:08 AM, Junio C Hamano  wrote:
> Jeff King  writes:
>
>> Yes, I would think die_errno() is a no-brainer for translation, since
>> the strerror() will be translated.
>>
>>> apply.c:die(_("internal error"));
>>>
>>> That is funny, too. I think we should substitute that with
>>>
>>> die("BUG: untranslated, but what went wrong instead")
>>
>> Yep. We did not consistently use "BUG:" in the early days. I would say
>> that "BUG" lines do not need to be translated. The point is that nobody
>> should ever see them, so it seems like there is little point in giving
>> extra work to translators.
>
> In addition, "BUG: " is relatively recent introduction to our
> codebase.  Perhaps having a separate BUG() function help the
> distinction further?

I was going to write the same thing. On top of that I wonder if have
enough "if (something) die("BUG:")" to justify stealing BUG_ON() from
kernel (better than assert since the condition will always be
evaluated).
-- 
Duy


Re: [RFC PATCH 0/5] Localise error headers

2017-01-11 Thread Junio C Hamano
Jeff King  writes:

> Yes, I would think die_errno() is a no-brainer for translation, since
> the strerror() will be translated.
>
>> apply.c:die(_("internal error"));
>> 
>> That is funny, too. I think we should substitute that with
>> 
>> die("BUG: untranslated, but what went wrong instead")
>
> Yep. We did not consistently use "BUG:" in the early days. I would say
> that "BUG" lines do not need to be translated. The point is that nobody
> should ever see them, so it seems like there is little point in giving
> extra work to translators.

In addition, "BUG: " is relatively recent introduction to our
codebase.  Perhaps having a separate BUG() function help the
distinction further?


Re: [RFC PATCH 0/5] Localise error headers

2017-01-11 Thread Stefan Beller
On Wed, Jan 11, 2017 at 3:37 AM, Jeff King  wrote:
> On Tue, Jan 10, 2017 at 10:28:42AM -0800, Stefan Beller wrote:
>
>> > And then presumably that mix would gradually move to 100% consistency as
>> > more messages are translated. But the implicit question is: are there
>> > die() messages that should never be translated? I'm not sure.
>>
>> I would assume any plumbing command is not localizing?
>> Because in plumbing land, (easily scriptable) you may find
>> a grep on the output/stderr for a certain condition?
>
> That's the assumption I'm challenging. Certainly the behavior and
> certain aspects of the output of a plumbing command should remain the
> same over time. But error messages to stderr?

In an ideal world that assumption would hold true and any machine
readable information from the plumbing commands are on stdout and
nobody in their sane mind would ever try to parse stderr.

There is no easy way to check though except auditing all the code.
Having pointed out some string handling mistakes in the prior email,
my confidence is not high that plumbing commands are that strict about
separating useful machine output and errors for human consumption.

>
> It seems like they should be translated, because plumbing invoked on
> behalf of porcelain scripts is going to send its stderr directly to the
> user.

Well that could be solved, c.f. unpack-trees.c lines 15-55.

As another data point (coming from that area of strings):
If you grep for these plumbing strings in the project,
i.e.
$ git grep "would be overwritten by merge. Cannot merge"
$ git grep "not uptodate. Cannot merge."
...

you only find the occurrence in the  unpack-trees.c lines 15-55,
which means our test suite at least doesn't grep for error messages
but relies on the exit code of plumbing commands(?!)

>
>> To find a good example, "git grep die" giving me some food of though:
>>
>> die_errno(..) should always take a string marked up for translation,
>> because the errno string is translated?
>
> Yes, I would think die_errno() is a no-brainer for translation, since
> the strerror() will be translated.
>
>> apply.c:die(_("internal error"));
>>
>> That is funny, too. I think we should substitute that with
>>
>> die("BUG: untranslated, but what went wrong instead")
>
> Yep. We did not consistently use "BUG:" in the early days. I would say
> that "BUG" lines do not need to be translated. The point is that nobody
> should ever see them, so it seems like there is little point in giving
> extra work to translators.
>
> -Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-11 Thread Jeff King
On Tue, Jan 10, 2017 at 10:28:42AM -0800, Stefan Beller wrote:

> > And then presumably that mix would gradually move to 100% consistency as
> > more messages are translated. But the implicit question is: are there
> > die() messages that should never be translated? I'm not sure.
> 
> I would assume any plumbing command is not localizing?
> Because in plumbing land, (easily scriptable) you may find
> a grep on the output/stderr for a certain condition?

That's the assumption I'm challenging. Certainly the behavior and
certain aspects of the output of a plumbing command should remain the
same over time. But error messages to stderr?

It seems like they should be translated, because plumbing invoked on
behalf of porcelain scripts is going to send its stderr directly to the
user.

> To find a good example, "git grep die" giving me some food of though:
> 
> die_errno(..) should always take a string marked up for translation,
> because the errno string is translated?

Yes, I would think die_errno() is a no-brainer for translation, since
the strerror() will be translated.

> apply.c:die(_("internal error"));
> 
> That is funny, too. I think we should substitute that with
> 
> die("BUG: untranslated, but what went wrong instead")

Yep. We did not consistently use "BUG:" in the early days. I would say
that "BUG" lines do not need to be translated. The point is that nobody
should ever see them, so it seems like there is little point in giving
extra work to translators.

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-10 Thread Stefan Beller
On Tue, Jan 10, 2017 at 1:04 AM, Jeff King  wrote:
> On Mon, Jan 09, 2017 at 01:43:15PM +0100, Michael J Gruber wrote:
>
>> > I can't say I'm excited about having matching "_" variants for each
>> > function. Are we sure that they are necessary? I.e., would it be
>> > acceptable to just translate them always?
>>
>> We would still need to mark the strings, e.g.
>>
>> die(N_("oopsie"));
>>
>> and would not be able to opt out of translating in the code (only in the
>> po file, by not providing a translation).
>
> I meant more along the lines of: would it be OK to just always translate
> the prefix, even if the message itself is not translated? I.e.,
>
> diff --git a/usage.c b/usage.c
> index 82ff13163..8e5400f57 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -32,7 +32,7 @@ static NORETURN void usage_builtin(const char *err, va_list 
> params)
>
>  static NORETURN void die_builtin(const char *err, va_list params)
>  {
> -   vreportf("fatal: ", err, params);
> +   vreportf(_("fatal: "), err, params);
> exit(128);
>  }
>
>> In any case, the question is whether we want to tell the user
>>
>> A: B
>>
>> where A is in English and B is localised, or rather localise both A and
>> B (for A in "error", "fatal", "warning"...).
>>
>> For localising A and B, we'd need this series or something similar. For
>> keeping the mix, we don't need to do anything ;)
>
> What I wrote above would keep the mix, but switch it in the other
> direction.
>
> And then presumably that mix would gradually move to 100% consistency as
> more messages are translated. But the implicit question is: are there
> die() messages that should never be translated? I'm not sure.

I would assume any plumbing command is not localizing?
Because in plumbing land, (easily scriptable) you may find
a grep on the output/stderr for a certain condition?

To find a good example, "git grep die" giving me some food of though:

die_errno(..) should always take a string marked up for translation,
because the errno string is translated?
(-> we'd have to fix up any occurrence of git grep "die_errno(\"")

apply.c:die(_("internal error"));

That is funny, too. I think we should substitute that with

die("BUG: untranslated, but what went wrong instead")


>
> -Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-10 Thread Jeff King
On Mon, Jan 09, 2017 at 01:43:15PM +0100, Michael J Gruber wrote:

> > I can't say I'm excited about having matching "_" variants for each
> > function. Are we sure that they are necessary? I.e., would it be
> > acceptable to just translate them always?
> 
> We would still need to mark the strings, e.g.
> 
> die(N_("oopsie"));
> 
> and would not be able to opt out of translating in the code (only in the
> po file, by not providing a translation).

I meant more along the lines of: would it be OK to just always translate
the prefix, even if the message itself is not translated? I.e.,

diff --git a/usage.c b/usage.c
index 82ff13163..8e5400f57 100644
--- a/usage.c
+++ b/usage.c
@@ -32,7 +32,7 @@ static NORETURN void usage_builtin(const char *err, va_list 
params)
 
 static NORETURN void die_builtin(const char *err, va_list params)
 {
-   vreportf("fatal: ", err, params);
+   vreportf(_("fatal: "), err, params);
exit(128);
 }

> In any case, the question is whether we want to tell the user
> 
> A: B
> 
> where A is in English and B is localised, or rather localise both A and
> B (for A in "error", "fatal", "warning"...).
> 
> For localising A and B, we'd need this series or something similar. For
> keeping the mix, we don't need to do anything ;)

What I wrote above would keep the mix, but switch it in the other
direction.

And then presumably that mix would gradually move to 100% consistency as
more messages are translated. But the implicit question is: are there
die() messages that should never be translated? I'm not sure.

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-09 Thread Michael J Gruber
Jeff King venit, vidit, dixit 04.01.2017 08:05:
> On Mon, Jan 02, 2017 at 12:14:49PM +0100, Michael J Gruber wrote:
> 
>> Currently, the headers "error: ", "warning: " etc. - generated by die(),
>> warning() etc. - are not localized, but we feed many localized error messages
>> into these functions so that we produce error messages with mixed 
>> localisation.
>>
>> This series introduces variants of die() etc. that use localised variants of
>> the headers, i.e. _("error: ") etc., and are to be fed localized messages. 
>> So,
>> instead of die(_("not workee")), which would produce a mixed localisation 
>> (such
>> as "error: geht ned"), one should use die_(_("not workee")) (resulting in
>> "Fehler: geht ned").
> 
> I can't say I'm excited about having matching "_" variants for each
> function. Are we sure that they are necessary? I.e., would it be
> acceptable to just translate them always?

We would still need to mark the strings, e.g.

die(N_("oopsie"));

and would not be able to opt out of translating in the code (only in the
po file, by not providing a translation).


>> 1/5 prepares the error machinery
>> 2/5 provides new variants error_() etc.
>> 3/5 has coccinelli rules error(_(E)) -> error_(_(E)) etc.
>> 4/5 applies the coccinelli patches
>>
>> 5/5 is not to be applied to the main tree, but helps you try out the feature:
>> it has changes to de.po and git.pot so that e.g. "git branch" has fully 
>> localised
>> error messages (see the recipe in the commit message).
> 
> Your patches 4 and 5 don't seem to have made it to the list. Judging
> from the diffstat, I'd guess they broke the 100K limit.

Hmmpf, I didn't know about the limit. In any case, they were simple
results of applying the "make cocci" patches (4/5) resp. providing some
"de" strings to try this out.

In any case, the question is whether we want to tell the user

A: B

where A is in English and B is localised, or rather localise both A and
B (for A in "error", "fatal", "warning"...).

For localising A and B, we'd need this series or something similar. For
keeping the mix, we don't need to do anything ;)

Michael



Re: [RFC PATCH 0/5] Localise error headers

2017-01-07 Thread Duy Nguyen
On Wed, Jan 4, 2017 at 8:25 PM, Duy Nguyen  wrote:
> On Wed, Jan 4, 2017 at 2:45 AM, Stefan Beller  wrote:
>>> In this implementation, the gettext call for the header and the body are 
>>> done
>>> in different places (error function vs. caller) but this call pattern seems 
>>> to
>>> be the easiest variant for the caller, because the message body has to be 
>>> marked
>>> for localisation in any case, and N_() requires more letters than _(), an 
>>> extra
>>> argument to die() etc. even more than the extra "_" in the function name.
>>
>> I see. We have to markup the strings to be translatable such that the .po 
>> files
>> are complete. It would be really handy if there was a way to say "anything 
>> that
>> is fed to this function (die_) needs to be marked for translation.
>>
>> Looking through
>> https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html
>> such a thing doesn't seem to exist.
>
> I think --keyword is exactly for that purpose: marking more text for
> translations besides standard markers like _() or N_(). Yes we need to
> call gettext() explicitly in die_() later on. We already do that for
> parse-options. We just need to N_() the strings, without actually
> spelling it out.
>
>>
>> So in that case die_(_(...)) seems to be the easiest way forward.
>
> I still prefer changing the die_routine though since die() in many
> cases could be used in both plumbing and porcelain contexts. And we
> have tried to keep plumbing output (and behavior) as stable as
> possible. The approach has some similarity to unpack_trees() which
> shares the same porcelain/plumbing problem.

On the other hand, making die(), not die_(), translatable means the
translators will have to translate them _all_ even if only some will
end up being displayed. That's 2000+ strings according to git-grep.
And some of them, like die("BUG:..") should definitely not be
translated. So +1 to die_(), unless we decide all strings are safe to
translate.
-- 
Duy


Re: [RFC PATCH 0/5] Localise error headers

2017-01-04 Thread Duy Nguyen
On Wed, Jan 4, 2017 at 2:45 AM, Stefan Beller  wrote:
>> In this implementation, the gettext call for the header and the body are done
>> in different places (error function vs. caller) but this call pattern seems 
>> to
>> be the easiest variant for the caller, because the message body has to be 
>> marked
>> for localisation in any case, and N_() requires more letters than _(), an 
>> extra
>> argument to die() etc. even more than the extra "_" in the function name.
>
> I see. We have to markup the strings to be translatable such that the .po 
> files
> are complete. It would be really handy if there was a way to say "anything 
> that
> is fed to this function (die_) needs to be marked for translation.
>
> Looking through
> https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html
> such a thing doesn't seem to exist.

I think --keyword is exactly for that purpose: marking more text for
translations besides standard markers like _() or N_(). Yes we need to
call gettext() explicitly in die_() later on. We already do that for
parse-options. We just need to N_() the strings, without actually
spelling it out.

>
> So in that case die_(_(...)) seems to be the easiest way forward.

I still prefer changing the die_routine though since die() in many
cases could be used in both plumbing and porcelain contexts. And we
have tried to keep plumbing output (and behavior) as stable as
possible. The approach has some similarity to unpack_trees() which
shares the same porcelain/plumbing problem.
-- 
Duy


Re: [RFC PATCH 0/5] Localise error headers

2017-01-03 Thread Jeff King
On Mon, Jan 02, 2017 at 12:14:49PM +0100, Michael J Gruber wrote:

> Currently, the headers "error: ", "warning: " etc. - generated by die(),
> warning() etc. - are not localized, but we feed many localized error messages
> into these functions so that we produce error messages with mixed 
> localisation.
> 
> This series introduces variants of die() etc. that use localised variants of
> the headers, i.e. _("error: ") etc., and are to be fed localized messages. So,
> instead of die(_("not workee")), which would produce a mixed localisation 
> (such
> as "error: geht ned"), one should use die_(_("not workee")) (resulting in
> "Fehler: geht ned").

I can't say I'm excited about having matching "_" variants for each
function. Are we sure that they are necessary? I.e., would it be
acceptable to just translate them always?

> 1/5 prepares the error machinery
> 2/5 provides new variants error_() etc.
> 3/5 has coccinelli rules error(_(E)) -> error_(_(E)) etc.
> 4/5 applies the coccinelli patches
> 
> 5/5 is not to be applied to the main tree, but helps you try out the feature:
> it has changes to de.po and git.pot so that e.g. "git branch" has fully 
> localised
> error messages (see the recipe in the commit message).

Your patches 4 and 5 don't seem to have made it to the list. Judging
from the diffstat, I'd guess they broke the 100K limit.

-Peff


Re: [RFC PATCH 0/5] Localise error headers

2017-01-03 Thread Stefan Beller
On Mon, Jan 2, 2017 at 3:14 AM, Michael J Gruber
 wrote:
> Currently, the headers "error: ", "warning: " etc. - generated by die(),
> warning() etc. - are not localized, but we feed many localized error messages
> into these functions so that we produce error messages with mixed 
> localisation.
>
> This series introduces variants of die() etc. that use localised variants of
> the headers, i.e. _("error: ") etc., and are to be fed localized messages. So,
> instead of die(_("not workee")), which would produce a mixed localisation 
> (such
> as "error: geht ned"), one should use die_(_("not workee")) (resulting in
> "Fehler: geht ned").

Have you considered

die_("non localized error here")

to produce:

"Fehler: trotzdem uebersetzt hier"
("error: here it is translated")

>
> In this implementation, the gettext call for the header and the body are done
> in different places (error function vs. caller) but this call pattern seems to
> be the easiest variant for the caller, because the message body has to be 
> marked
> for localisation in any case, and N_() requires more letters than _(), an 
> extra
> argument to die() etc. even more than the extra "_" in the function name.

I see. We have to markup the strings to be translatable such that the .po files
are complete. It would be really handy if there was a way to say "anything that
is fed to this function (die_) needs to be marked for translation.

Looking through
https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html
such a thing doesn't seem to exist.

So in that case die_(_(...)) seems to be the easiest way forward.

Thanks,
Stefan


Re: [RFC PATCH 0/5] Localise error headers

2017-01-03 Thread Duy Nguyen
On Mon, Jan 2, 2017 at 6:14 PM, Michael J Gruber
 wrote:
> Currently, the headers "error: ", "warning: " etc. - generated by die(),
> warning() etc. - are not localized, but we feed many localized error messages
> into these functions so that we produce error messages with mixed 
> localisation.
>
> This series introduces variants of die() etc. that use localised variants of
> the headers, i.e. _("error: ") etc., and are to be fed localized messages. So,
> instead of die(_("not workee")), which would produce a mixed localisation 
> (such
> as "error: geht ned"), one should use die_(_("not workee")) (resulting in
> "Fehler: geht ned").

Another option, not as thorough, but less effort, is changing
die/err/warn default routines to the "porcelain" versions where we do
_("fatal:") internally _with_ die(), not die_(). We can set this for
porcelain commands that we know can be fully i18n-ized. Then maybe
die_() will fill in the gap if there's still need for it.
-- 
Duy


[RFC PATCH 0/5] Localise error headers

2017-01-02 Thread Michael J Gruber
Currently, the headers "error: ", "warning: " etc. - generated by die(),
warning() etc. - are not localized, but we feed many localized error messages
into these functions so that we produce error messages with mixed localisation.

This series introduces variants of die() etc. that use localised variants of
the headers, i.e. _("error: ") etc., and are to be fed localized messages. So,
instead of die(_("not workee")), which would produce a mixed localisation (such
as "error: geht ned"), one should use die_(_("not workee")) (resulting in
"Fehler: geht ned").

In this implementation, the gettext call for the header and the body are done
in different places (error function vs. caller) but this call pattern seems to
be the easiest variant for the caller, because the message body has to be marked
for localisation in any case, and N_() requires more letters than _(), an extra
argument to die() etc. even more than the extra "_" in the function name.

1/5 prepares the error machinery
2/5 provides new variants error_() etc.
3/5 has coccinelli rules error(_(E)) -> error_(_(E)) etc.
4/5 applies the coccinelli patches

5/5 is not to be applied to the main tree, but helps you try out the feature:
it has changes to de.po and git.pot so that e.g. "git branch" has fully 
localised
error messages (see the recipe in the commit message).

Michael J Gruber (5):
  error/warn framework: prepare for l10n
  error/warn framework: provide localized variants
  error/warn framework framework: coccinelli rules
  error/warn framework: localize
  WIP: Feature demonstration

 advice.c   |   16 +-
 apply.c|   10 +-
 apply.h|4 +-
 archive.c  |6 +-
 attr.c |3 +-
 bisect.c   |2 +-
 branch.c   |4 +-
 builtin/add.c  |   20 +-
 builtin/am.c   |   27 +-
 builtin/archive.c  |   10 +-
 builtin/blame.c|   12 +-
 builtin/branch.c   |   45 +-
 builtin/bundle.c   |4 +-
 builtin/check-ignore.c |   14 +-
 builtin/check-mailmap.c|2 +-
 builtin/checkout-index.c   |2 +-
 builtin/checkout.c |   27 +-
 builtin/clean.c|   10 +-
 builtin/clone.c|   39 +-
 builtin/column.c   |2 +-
 builtin/commit.c   |   87 +-
 builtin/config.c   |2 +-
 builtin/describe.c |6 +-
 builtin/diff.c |2 +-
 builtin/fetch.c|   21 +-
 builtin/gc.c   |3 +-
 builtin/grep.c |   14 +-
 builtin/help.c |4 +-
 builtin/index-pack.c   |   42 +-
 builtin/interpret-trailers.c   |2 +-
 builtin/log.c  |   48 +-
 builtin/merge-recursive.c  |2 +-
 builtin/merge.c|   53 +-
 builtin/mv.c   |6 +-
 builtin/notes.c|   40 +-
 builtin/pack-objects.c |4 +-
 builtin/prune.c|2 +-
 builtin/pull.c |   10 +-
 builtin/push.c |   22 +-
 builtin/remote.c   |   10 +-
 builtin/repack.c   |4 +-
 builtin/replace.c  |2 +-
 builtin/reset.c|   10 +-
 builtin/rev-list.c |2 +-
 builtin/rev-parse.c|2 +-
 builtin/revert.c   |4 +-
 builtin/rm.c   |6 +-
 builtin/shortlog.c |2 +-
 builtin/show-branch.c  |7 +-
 builtin/submodule--helper.c|9 +-
 builtin/tag.c  |   20 +-
 builtin/unpack-objects.c   |2 +-
 builtin/update-index.c |8 +-
 builtin/worktree.c |6 +-
 bundle.c   |4 +-
 config.c   |4 +-
 connect.c  |6 +-
 connected.c|2 +-
 contrib/coccinelle/errorl10n.cocci |   47 +
 daemon.c   |3 +-
 diff.c |8 +-
 dir.c  |4 +-
 fast-import.c  |4 +-
 fetch-pack.c   |   26 +-
 git-compat-util.h  |   18 +-
 help.c |2 +-
 http-backend.c |4 +-
 http.c |4 +-
 merge.c|2 +-
 notes-utils.c  |2 +-
 pathspec.c |   13 +-
 po/de.po   | 2922 
 po/git.pot | 2781 ++