[PATCH 1 of 2] templating: fix age() function to return 1 minute, 1 hour, 1 day etc

Andrei Polushin polushin at gmail.com
Sat Jan 7 17:04:22 CST 2012


05.01.2012 22:30, Martin Geisler wrote:
> Matt Mackall <mpm at selenic.com> writes:
>> Note that only a witless moron could ever actually be confused (rather
>> than simply annoyed) by "1 files". Unfortunately, we actually deal
>> with these witless morons on a daily basis: they're called computers.
>> And as it happens, they're actually much more likely to be confused by
>> the difference between "1 file" and "2 files", especially if we were
>> to switch to using the latter 6 years in.
> 
> Maybe we could let the English translation use the plural form always
> (like today) when HGPLAIN is set? That makes it easy for computers to
> parse the output, while providing nice output for humans.
> 
> I'm not sure if that was what Andrei already suggested in his ngettext
> patch, but it would be something like:
> 
>   if os.environ.get('HGPLAIN'):
>       def ngettext(singular, plural, count):
>           # always use English plural text for easy parsing by witless
>           # morons (computers).
>           return plural
>   else:
>       def ngettext(singular, plural, count):
>           # call tungettext, encode as necessary

Actually, I've already modified the patch as follows:

-------%<--------

-def ngettext(singular, plural, n):
+def _ngettext(singular, plural, n):

@@ -59,5 +74,7 @@

 if _plain():
     _ = lambda message: message
+    ngettext = lambda singular, plural, n: plural
 else:
     _ = gettext
+    ngettext = _ngettext

-------%<--------

It works well for both witless morons et homines sapientes.

I'm compelled to use personally, though.

Then, I think that was not the main reason of rejection. I am still in the
dark about the exact reason, and I guess I need to ask Matt directly: how on
Earth the support for plural forms should look like to be acceptable? Should
it require absolutely zero changes in code or something like that?

I'm not just curious. Maybe, we'll find a solution better than ngettext.

-- 
Andrei Polushin


More information about the Mercurial-devel mailing list