Patchwork [7,of,7] debugignore: make messages translatable

login
register
mail settings
Submitter Katsunori FUJIWARA
Date May 25, 2016, 5:01 p.m.
Message ID <d240fc2f3dcb60ca11fa.1464195706@feefifofum>
Download mbox | patch
Permalink /patch/15201/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - May 25, 2016, 5:01 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1464195454 -32400
#      Thu May 26 01:57:34 2016 +0900
# Node ID d240fc2f3dcb60ca11faea0e5242de0cf5f8c81d
# Parent  02018ce3e14c00d4699f6a4c8987dc61dd365f23
debugignore: make messages translatable

These messages have been overlooked by check-code, because they start
with non-alphabet character ('%' or '(').

Making these messages translatable seems reasonable, because messages
for ui.note(), ui.status(), ui.progress() and descriptive messages for
ui.write() in "debug" commands are already translatable in many cases.

This is also a part of preparation for making "missing _() in ui
message" detection of check-code more exact.
timeless - May 25, 2016, 5:19 p.m.
series looks good to me.

it also makes our HGUNICODEPEDANTRY (and thus py3) story easier to
manage since all strings being sent via ui.* should go through _().

On Wed, May 25, 2016 at 1:01 PM, FUJIWARA Katsunori
<foozy@lares.dti.ne.jp> wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1464195454 -32400
> #      Thu May 26 01:57:34 2016 +0900
> # Node ID d240fc2f3dcb60ca11faea0e5242de0cf5f8c81d
> # Parent  02018ce3e14c00d4699f6a4c8987dc61dd365f23
> debugignore: make messages translatable
>
> These messages have been overlooked by check-code, because they start
> with non-alphabet character ('%' or '(').
>
> Making these messages translatable seems reasonable, because messages
> for ui.note(), ui.status(), ui.progress() and descriptive messages for
> ui.write() in "debug" commands are already translatable in many cases.
>
> This is also a part of preparation for making "missing _() in ui
> message" detection of check-code more exact.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2521,15 +2521,16 @@ def debugignore(ui, repo, *files, **opts
>                              break
>              if ignored:
>                  if ignored == nf:
> -                    ui.write("%s is ignored\n" % f)
> +                    ui.write(_("%s is ignored\n") % f)
>                  else:
> -                    ui.write("%s is ignored because of containing folder %s\n"
> +                    ui.write(_("%s is ignored because of "
> +                               "containing folder %s\n")
>                               % (f, ignored))
>                  ignorefile, lineno, line = ignoredata
> -                ui.write("(ignore rule in %s, line %d: '%s')\n"
> +                ui.write(_("(ignore rule in %s, line %d: '%s')\n")
>                           % (ignorefile, lineno, line))
>              else:
> -                ui.write("%s is not ignored\n" % f)
> +                ui.write(_("%s is not ignored\n") % f)
>
>  @command('debugindex', debugrevlogopts +
>      [('f', 'format', 0, _('revlog format'), _('FORMAT'))],
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Yuya Nishihara - May 26, 2016, 1:24 p.m.
On Wed, 25 May 2016 13:19:17 -0400, timeless wrote:
> On Wed, May 25, 2016 at 1:01 PM, FUJIWARA Katsunori
> <foozy@lares.dti.ne.jp> wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> > # Date 1464195454 -32400
> > #      Thu May 26 01:57:34 2016 +0900
> > # Node ID d240fc2f3dcb60ca11faea0e5242de0cf5f8c81d
> > # Parent  02018ce3e14c00d4699f6a4c8987dc61dd365f23
> > debugignore: make messages translatable
> >
> series looks good to me.

LGTM, too. Pushing to the committed repo, thanks.

> it also makes our HGUNICODEPEDANTRY (and thus py3) story easier to
> manage since all strings being sent via ui.* should go through _().

I don't know the detail, but ui.debug() will never be through _().
Pierre-Yves David - May 27, 2016, 2:20 p.m.
If I remember correctly, the policy is to not translate debug output and
debug command. They do not aim to be exposed to normal user so I think
the idea is to avoid increasing the translater load for minor output
meant for english-able devs.

Do we have a way to mark these output and untranslated instead?

On 05/26/2016 03:24 PM, Yuya Nishihara wrote:
> On Wed, 25 May 2016 13:19:17 -0400, timeless wrote:
>> On Wed, May 25, 2016 at 1:01 PM, FUJIWARA Katsunori
>> <foozy@lares.dti.ne.jp> wrote:
>>> # HG changeset patch
>>> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
>>> # Date 1464195454 -32400
>>> #      Thu May 26 01:57:34 2016 +0900
>>> # Node ID d240fc2f3dcb60ca11faea0e5242de0cf5f8c81d
>>> # Parent  02018ce3e14c00d4699f6a4c8987dc61dd365f23
>>> debugignore: make messages translatable
>>>
>> series looks good to me.
> 
> LGTM, too. Pushing to the committed repo, thanks.
> 
>> it also makes our HGUNICODEPEDANTRY (and thus py3) story easier to
>> manage since all strings being sent via ui.* should go through _().
> 
> I don't know the detail, but ui.debug() will never be through _().
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Katsunori FUJIWARA - May 30, 2016, 10:46 p.m.
At Fri, 27 May 2016 16:20:25 +0200,
Pierre-Yves David wrote:
> 
> If I remember correctly, the policy is to not translate debug output and
> debug command. They do not aim to be exposed to normal user so I think
> the idea is to avoid increasing the translater load for minor output
> meant for english-able devs.

I've thought that the policy is to not translate debug output and
debug command, too. In fact, I am surprised that there are many
translatable messages in debug* commands than I expected, even though
I translated many of them :-)

> Do we have a way to mark these output and untranslated instead?

Would I send a patch for bulk changes, which replaces all "_()" in
debug* commands to disable translation ?


> On 05/26/2016 03:24 PM, Yuya Nishihara wrote:
> > On Wed, 25 May 2016 13:19:17 -0400, timeless wrote:
> >> On Wed, May 25, 2016 at 1:01 PM, FUJIWARA Katsunori
> >> <foozy@lares.dti.ne.jp> wrote:
> >>> # HG changeset patch
> >>> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> >>> # Date 1464195454 -32400
> >>> #      Thu May 26 01:57:34 2016 +0900
> >>> # Node ID d240fc2f3dcb60ca11faea0e5242de0cf5f8c81d
> >>> # Parent  02018ce3e14c00d4699f6a4c8987dc61dd365f23
> >>> debugignore: make messages translatable
> >>>
> >> series looks good to me.
> > 
> > LGTM, too. Pushing to the committed repo, thanks.
> > 
> >> it also makes our HGUNICODEPEDANTRY (and thus py3) story easier to
> >> manage since all strings being sent via ui.* should go through _().
> > 
> > I don't know the detail, but ui.debug() will never be through _().
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> > 
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
timeless - May 31, 2016, 5 a.m.
FUJIWARA Katsunori <foozy@lares.dti.ne.jp> wrote:
>> Do we have a way to mark these output and untranslated instead?
>
> Would I send a patch for bulk changes, which replaces all "_()" in
> debug* commands to disable translation ?

I'd rather it not be just removing _(), we should at least have something,
perhaps untranslated("").
Katsunori FUJIWARA - May 31, 2016, 7:25 a.m.
At Tue, 31 May 2016 01:00:35 -0400,
timeless wrote:
> 
> FUJIWARA Katsunori <foozy@lares.dti.ne.jp> wrote:
> >> Do we have a way to mark these output and untranslated instead?
> >
> > Would I send a patch for bulk changes, which replaces all "_()" in
> > debug* commands to disable translation ?
> 
> I'd rather it not be just removing _(), we should at least have something,
> perhaps untranslated("").
> 

Oh, sorry. I just omitted 'with "()"' for 'replaces all "_()"' :-)

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
Yuya Nishihara - May 31, 2016, 11:46 a.m.
On Tue, 31 May 2016 16:25:17 +0900, FUJIWARA Katsunori wrote:
> At Tue, 31 May 2016 01:00:35 -0400,
> timeless wrote:
> > FUJIWARA Katsunori <foozy@lares.dti.ne.jp> wrote:  
> > >> Do we have a way to mark these output and untranslated instead?  
> > >
> > > Would I send a patch for bulk changes, which replaces all "_()" in
> > > debug* commands to disable translation ?  
> > 
> > I'd rather it not be just removing _(), we should at least have something,
> > perhaps untranslated("").
> 
> Oh, sorry. I just omitted 'with "()"' for 'replaces all "_()"' :-)

Sounds good to me, maybe you know, except for "debuginstall".
Katsunori FUJIWARA - June 3, 2016, 2:03 p.m.
At Tue, 31 May 2016 20:46:21 +0900,
Yuya Nishihara wrote:
> 
> On Tue, 31 May 2016 16:25:17 +0900, FUJIWARA Katsunori wrote:
> > At Tue, 31 May 2016 01:00:35 -0400,
> > timeless wrote:
> > > FUJIWARA Katsunori <foozy@lares.dti.ne.jp> wrote:  
> > > >> Do we have a way to mark these output and untranslated instead?  
> > > >
> > > > Would I send a patch for bulk changes, which replaces all "_()" in
> > > > debug* commands to disable translation ?  
> > > 
> > > I'd rather it not be just removing _(), we should at least have something,
> > > perhaps untranslated("").
> > 
> > Oh, sorry. I just omitted 'with "()"' for 'replaces all "_()"' :-)
> 
> Sounds good to me, maybe you know, except for "debuginstall".

because "debuginstall" is referred by some messages/documents for end
users, isn't it ?

AFAIK, there are some other references to debug* commands below. We
should except also these commands from target of bulk change,
shouldn't we ? (even though only debugcreatestreamclonebundle has
actual translatable messages in commands.py :-))

  - "hg bundle" might show "use 'hg debugcreatestreamclonebundle'"
  - "hg unbundle" might show 'use "hg debugapplystreamclonebundle"'
  - "hg verify" might show 'run "hg debugrebuildfncache" to recover from corrupt fncache'

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy@lares.dti.ne.jp
timeless - June 3, 2016, 3:09 p.m.
On Fri, Jun 3, 2016 at 10:03 AM, FUJIWARA Katsunori
<foozy@lares.dti.ne.jp> wrote:
> At Tue, 31 May 2016 20:46:21 +0900,
> Yuya Nishihara wrote:
>>
>> On Tue, 31 May 2016 16:25:17 +0900, FUJIWARA Katsunori wrote:
>> > At Tue, 31 May 2016 01:00:35 -0400,
>> > timeless wrote:
>> > > FUJIWARA Katsunori <foozy@lares.dti.ne.jp> wrote:
>> > > >> Do we have a way to mark these output and untranslated instead?
>> > > >
>> > > > Would I send a patch for bulk changes, which replaces all "_()" in
>> > > > debug* commands to disable translation ?
>> > >
>> > > I'd rather it not be just removing _(), we should at least have something,
>> > > perhaps untranslated("").
>> >
>> > Oh, sorry. I just omitted 'with "()"' for 'replaces all "_()"' :-)
>>
>> Sounds good to me, maybe you know, except for "debuginstall".
>
> because "debuginstall" is referred by some messages/documents for end
> users, isn't it ?
>
> AFAIK, there are some other references to debug* commands below. We
> should except also these commands from target of bulk change,
> shouldn't we ? (even though only debugcreatestreamclonebundle has
> actual translatable messages in commands.py :-))
>
>   - "hg bundle" might show "use 'hg debugcreatestreamclonebundle'"
>   - "hg unbundle" might show 'use "hg debugapplystreamclonebundle"'
>   - "hg verify" might show 'run "hg debugrebuildfncache" to recover from corrupt fncache'

So. I think the real question we should ask is "why don't we want
debug messages translated?"

here are a couple of answers:
1. We want people sending English debugging to the list.
2. We don't want to waste the precious time of our localizers on
things that most users won't see.
3. Debug apis aren't part of our stable contract.

For #1, it's easy enough for people to be told to run the command
either w/ -T (if supported) or the env flag to get English output. (We
could even add a flag for this if we find it too hard to get people to
use the env var)
For #2, it should be easy enough to tell localizers that they don't
*have* to translate debug messages -- and if it isn't, I'm happy to
write scripts to split debug stuff into a separate .pot or something
to make it easier on them to decide what to prioritize.
For #3, that's ok, but why should that impact our choice about
translating the messages?

If you have a different answer to my "why" question, i'd like to hear it.
Yuya Nishihara - June 4, 2016, 4:06 a.m.
On Fri, 3 Jun 2016 11:09:26 -0400, timeless wrote:
> On Fri, Jun 3, 2016 at 10:03 AM, FUJIWARA Katsunori
> <foozy@lares.dti.ne.jp> wrote:
> >> Sounds good to me, maybe you know, except for "debuginstall".  
> >
> > because "debuginstall" is referred by some messages/documents for end
> > users, isn't it ?

Something like that. I heard "debuginstall" is a public command unlike the
other debug* commands.

> > AFAIK, there are some other references to debug* commands below. We
> > should except also these commands from target of bulk change,
> > shouldn't we ? (even though only debugcreatestreamclonebundle has
> > actual translatable messages in commands.py :-))
> >
> >   - "hg bundle" might show "use 'hg debugcreatestreamclonebundle'"
> >   - "hg unbundle" might show 'use "hg debugapplystreamclonebundle"'
> >   - "hg verify" might show 'run "hg debugrebuildfncache" to recover from corrupt fncache'  
> 
> So. I think the real question we should ask is "why don't we want
> debug messages translated?"
> 
> here are a couple of answers:
> 1. We want people sending English debugging to the list.
> 2. We don't want to waste the precious time of our localizers on
> things that most users won't see.
> 3. Debug apis aren't part of our stable contract.
> 
> For #1, it's easy enough for people to be told to run the command
> either w/ -T (if supported) or the env flag to get English output. (We
> could even add a flag for this if we find it too hard to get people to
> use the env var)
> For #2, it should be easy enough to tell localizers that they don't
> *have* to translate debug messages -- and if it isn't, I'm happy to
> write scripts to split debug stuff into a separate .pot or something
> to make it easier on them to decide what to prioritize.
> For #3, that's ok, but why should that impact our choice about
> translating the messages?

I meant #2. But given that it's unclear to say which is real debug command,
I don't think it would worth trying to get rid of _() from debug* commands.

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2521,15 +2521,16 @@  def debugignore(ui, repo, *files, **opts
                             break
             if ignored:
                 if ignored == nf:
-                    ui.write("%s is ignored\n" % f)
+                    ui.write(_("%s is ignored\n") % f)
                 else:
-                    ui.write("%s is ignored because of containing folder %s\n"
+                    ui.write(_("%s is ignored because of "
+                               "containing folder %s\n")
                              % (f, ignored))
                 ignorefile, lineno, line = ignoredata
-                ui.write("(ignore rule in %s, line %d: '%s')\n"
+                ui.write(_("(ignore rule in %s, line %d: '%s')\n")
                          % (ignorefile, lineno, line))
             else:
-                ui.write("%s is not ignored\n" % f)
+                ui.write(_("%s is not ignored\n") % f)
 
 @command('debugindex', debugrevlogopts +
     [('f', 'format', 0, _('revlog format'), _('FORMAT'))],