Code

Ticket #4107: diff.2.diff

File diff.2.diff, 3.0 KB (added by Baptiste <baptiste.goupil@…>, 7 years ago)

a new string to translate in contrib/auth/models.py

Line 
1Index: contrib/auth/models.py
2===================================================================
3--- contrib/auth/models.py      (revision 5056)
4+++ contrib/auth/models.py      (copie de travail)
5@@ -258,7 +258,7 @@
6         pass
7 
8     def __str__(self):
9-        return 'AnonymousUser'
10+        return _('AnonymousUser')
11 
12     def __eq__(self, other):
13         return isinstance(other, self.__class__)
14Index: contrib/admindocs/views.py
15===================================================================
16--- contrib/admindocs/views.py  (revision 5056)
17+++ contrib/admindocs/views.py  (copie de travail)
18@@ -168,7 +168,7 @@
19             model = m
20             break
21     if model is None:
22-        raise Http404, _("Model %r not found in app %r") % (model_name, app_label)
23+        raise Http404, _("Model %(name)r not found in app %(app)r") % {'name': model_name, 'app': app_label}
24 
25     opts = model._meta
26 
27@@ -180,7 +180,7 @@
28         if isinstance(field, models.ForeignKey):
29             data_type = related_object_name = field.rel.to.__name__
30             app_label = field.rel.to._meta.app_label
31-            verbose = utils.parse_rst((_("the related `%s.%s` object")  % (app_label, data_type)), 'model', _('model:') + data_type)
32+            verbose = utils.parse_rst((_("the related `%(app)s.%(type)s` object")  % {'app': app_label, 'type': data_type}), 'model', _('model:') + data_type)
33         else:
34             data_type = get_readable_field_data_type(field)
35             verbose = field.verbose_name
36@@ -211,7 +211,7 @@
37 
38     # Gather related objects
39     for rel in opts.get_all_related_objects():
40-        verbose = _("related `%s.%s` objects") % (rel.opts.app_label, rel.opts.object_name)
41+        verbose = _("related `%(app)s.%(name)s` objects") % {'app': rel.opts.app_label, 'name': rel.opts.object_name}
42         accessor = rel.get_accessor_name()
43         fields.append({
44             'name'      : "%s.all" % accessor,
45Index: template/defaultfilters.py
46===================================================================
47--- template/defaultfilters.py  (revision 5056)
48+++ template/defaultfilters.py  (copie de travail)
49@@ -2,7 +2,7 @@
50 
51 from django.template import resolve_variable, Library
52 from django.conf import settings
53-from django.utils.translation import gettext
54+from django.utils.translation import gettext, ngettext
55 import re
56 import random as random_module
57 
58@@ -517,12 +517,12 @@
59         return "0 bytes"
60         
61     if bytes < 1024:
62-        return "%d byte%s" % (bytes, bytes != 1 and 's' or '')
63+        return ngettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes}
64     if bytes < 1024 * 1024:
65-        return "%.1f KB" % (bytes / 1024)
66+        return gettext("%.1f KB") % (bytes / 1024)
67     if bytes < 1024 * 1024 * 1024:
68-        return "%.1f MB" % (bytes / (1024 * 1024))
69-    return "%.1f GB" % (bytes / (1024 * 1024 * 1024))
70+        return gettext("%.1f MB") % (bytes / (1024 * 1024))
71+    return gettext("%.1f GB") % (bytes / (1024 * 1024 * 1024))
72 
73 def pluralize(value, arg='s'):
74     """