auto rename: best matches and speed improvement UPDATE2

Martin Geisler mg at daimi.au.dk
Fri Aug 15 17:42:14 CDT 2008


Herbert Griebel <herbertg at gmx.at> writes:

Hi,

> +    if addedfirst:
> +        l1, l2 = added, removed
> +        s = _('%d') % len(added)
> +    else:
> +        l1, l2 = removed, added
> +        s = _('%d') % len(removed)
> +    fmt = _('[%%%dd/%s] checking rename with %%s\n') % (len(s), s)

I don't know about the rest of your patch, but if I were a translator
and were asked to translate "%d" into Danish, then I wouldn't know
what to do! :-)

So it is not useful to translate such pieces. From the translators
point of view, you should always present them with meaningful
sentences, not just bits and pieces.

So instead of defining fmt piece-wise like above, the future
translators would have an easier job with something like:

> +    if addedfirst:
> +        l1, l2 = added, removed
> +    else:
> +        l1, l2 = removed, added
> +    total = len(removed)
> +    len_total = len(str(total))
> +    fmt = _('[%*d/%d] checking rename with %s\n')

(if I got it right...!)

> +    bestmatches = []
> +    t0 = time.clock()
> +    for i, x1 in enumerate(l1):
> +        repo.ui.status(fmt % (i+1, len_total, total, x1))

Here I used the %*d form of string interpolation, which means that the
next argument is used to specify the width of the %d conversion.

[...]

> -        for old, new, score in findrenames(repo, add, remove, similarity):
> +        renames, rmax, amax = findrenames(repo, add, remove, similarity)
> +        fmt = _('recording removal of %%-%ds as rename to %%-%ds '
> +                                 '%%3d%%%% similar\n') % (rmax, amax)

The same probably applied here... translating the formatting of a
formatting string is tough work for a translator.

-- 
Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20080816/4a1f9a7d/attachment.pgp 


More information about the Mercurial-devel mailing list