Code

Ticket #4137: django.util.timesince.i18n.patch.diff

File django.util.timesince.i18n.patch.diff, 919 bytes (added by Sung-Jin Hong <serialx.net@…>, 7 years ago)

django.util.timesince i18n patch

Line 
1Index: django/utils/timesince.py
2===================================================================
3--- django/utils/timesince.py   (revision 5063)
4+++ django/utils/timesince.py   (working copy)
5@@ -37,14 +37,14 @@
6         if count != 0:
7             break
8     if count < 0:
9-        return '%d milliseconds' % math.floor((now - d).microseconds / 1000)
10-    s = '%d %s' % (count, name(count))
11+        return _('%d milliseconds') % math.floor((now - d).microseconds / 1000)
12+    s = _('%(number)d %(type)s') % {'number':count, 'type':name(count)}
13     if i + 1 < len(chunks):
14         # Now get the second item
15         seconds2, name2 = chunks[i + 1]
16         count2 = (since - (seconds * count)) / seconds2
17         if count2 != 0:
18-            s += ', %d %s' % (count2, name2(count2))
19+            s += _(', %(number)d %(type)s') % {'number':count2, 'type':name2(count2)}
20     return s
21 
22 def timeuntil(d, now=None):