[PATCH] help: filter out deprecated options with untranslated descriptions

Simon Heimberg simohe at besonet.ch
Mon Mar 10 12:45:36 CDT 2014


On 22.02.2014 19:41, Mads Kiilerich wrote:
> On 02/17/2014 10:09 PM, Simon Heimberg wrote:
>> # HG changeset patch
>> # User Simon Heimberg <simohe at besonet.ch>
>> # Date 1392619193 -3600
>> #      Mon Feb 17 07:39:53 2014 +0100
>> # Node ID d4745c69913c70c0c7a42e1cf974faf9afb50985
>> # Parent  0e2877f8605dcaf4fdf2ab7e0046f1f6f80161dd
>> help: filter out deprecated options with untranslated descriptions
>>
>> When using a different language than English, deprecated options were
>> only
>> removed from the output of `hg help anycmd` when "DEPRECATED" in the
>> options
>> description was translated.
>>
>> diff -r 0e2877f8605d -r d4745c69913c mercurial/help.py
>> --- a/mercurial/help.py    Sat Feb 15 22:09:32 2014 -0600
>> +++ b/mercurial/help.py    Mon Feb 17 07:39:53 2014 +0100
>> @@ -38,7 +38,7 @@
>>               shortopt, longopt, default, desc = option
>>               optlabel = _("VALUE") # default label
>> -        if _("DEPRECATED") in desc and not verbose:
>> +        if not verbose and ("DEPRECATED" in desc or _("DEPRECATED")
>> in desc):
>
> It seems a bit fragile to put semantics in having totally consistent
> translation of DEPRECATED. (And even more so to base the test on having
> it translated in the Swedish translation.)
>
> BUT we do already check for the translated string elsewhere in help.py,
> so this is just making it consistent and not making it worse.

Do we want to go with this (and maybe create an issue) or do it better?

>
> Another observation is that it is inconsistent whether the magic string
> is "DEPRECATED" or "(DEPRECATED)".
>
> It seems like a better solution would be to only check for the magic
> word in the untranslated string - and either pass that or a flag around
> where it is needed. Alternatively, have a flag when defining an option
> and then add add the DEPRECATED string when relevant when the option
> description is shown to the user.

How can we get the untranslated string? The option description is inside of
_().

Do you have any suggestions about the testing?

Suggestions for implementing:
s1: Should we go with _('option description') + ' (%s)' % _('DEPRECATED')?
A check-code rule would be required to force this syntax in the code.
s2: Should we handle this in _() and split there in two separate
translations?
s3: This patch and check the correct translation by check-translation.py

The exact same shortcomings are there for deprecated commands (where I have
stole the idea from). My suggestion s1 will not work there.

>
> /Mads
>




More information about the Mercurial-devel mailing list