Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #3410 -- Edited a few i18n markups for completeness and to remo…

…ve some

warnings from recent gettext versions. Refs #3704. Thanks, Michael Radziej,
mirrorballu2@gmail.com and baptiste.goupil@gmail.com.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@4704 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b1eea1af4041989e40b9102d05e836c97f223409 1 parent a5e9f50
Malcolm Tredinnick authored March 12, 2007
4  django/bin/make-messages.py
@@ -81,7 +81,7 @@ def make_messages():
81 81
                     src = pythonize_re.sub('\n#', src)
82 82
                     open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
83 83
                     thefile = '%s.py' % file
84  
-                    cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
  84
+                    cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % (
85 85
                         os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
86 86
                     (stdin, stdout, stderr) = os.popen3(cmd, 'b')
87 87
                     msgs = stdout.read()
@@ -103,7 +103,7 @@ def make_messages():
103 103
                         open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
104 104
                         thefile = '%s.py' % file
105 105
                     if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
106  
-                    cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
  106
+                    cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % (
107 107
                         os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
108 108
                     (stdin, stdout, stderr) = os.popen3(cmd, 'b')
109 109
                     msgs = stdout.read()
3,100  django/conf/locale/cy/LC_MESSAGES/django.po
1800 additions, 1300 deletions not shown
6  django/contrib/admin/views/doc.py
@@ -168,7 +168,7 @@ def model_detail(request, app_label, model_name):
168 168
             model = m
169 169
             break
170 170
     if model is None:
171  
-        raise Http404, _("Model %r not found in app %r") % (model_name, app_label)
  171
+        raise Http404, _("Model %(name)r not found in app %(label)r") % {'name': model_name, 'label': app_label}
172 172
 
173 173
     opts = model._meta
174 174
 
@@ -180,7 +180,7 @@ def model_detail(request, app_label, model_name):
180 180
         if isinstance(field, models.ForeignKey):
181 181
             data_type = related_object_name = field.rel.to.__name__
182 182
             app_label = field.rel.to._meta.app_label
183  
-            verbose = utils.parse_rst((_("the related `%s.%s` object")  % (app_label, data_type)), 'model', _('model:') + data_type)
  183
+            verbose = utils.parse_rst((_("the related `%(label)s.%(type)s` object")  % {'label': app_label, 'type': data_type}), 'model', _('model:') + data_type)
184 184
         else:
185 185
             data_type = get_readable_field_data_type(field)
186 186
             verbose = field.verbose_name
@@ -211,7 +211,7 @@ def model_detail(request, app_label, model_name):
211 211
 
212 212
     # Gather related objects
213 213
     for rel in opts.get_all_related_objects():
214  
-        verbose = _("related `%s.%s` objects") % (rel.opts.app_label, rel.opts.object_name)
  214
+        verbose = _("related `%(label)s.%(name)s` objects") % {'label': rel.opts.app_label, 'name': rel.opts.object_name}
215 215
         accessor = rel.get_accessor_name()
216 216
         fields.append({
217 217
             'name'      : "%s.all" % accessor,
17  django/contrib/humanize/templatetags/humanize.py
... ...
@@ -1,3 +1,5 @@
  1
+from django.utils.translation import ngettext
  2
+from django.utils.translation import gettext_lazy as _
1 3
 from django import template
2 4
 import re
3 5
 
@@ -12,9 +14,9 @@ def ordinal(value):
12 14
         value = int(value)
13 15
     except ValueError:
14 16
         return value
15  
-    t = ('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th')
  17
+    t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
16 18
     if value % 100 in (11, 12, 13): # special case
17  
-        return '%dth' % value
  19
+        return "%d%s" % (value, t[0])
18 20
     return '%d%s' % (value, t[value % 10])
19 21
 register.filter(ordinal)
20 22
 
@@ -41,11 +43,14 @@ def intword(value):
41 43
     if value < 1000000:
42 44
         return value
43 45
     if value < 1000000000:
44  
-        return '%.1f million' % (value / 1000000.0)
  46
+    	new_value = value / 1000000.0
  47
+        return ngettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}
45 48
     if value < 1000000000000:
46  
-        return '%.1f billion' % (value / 1000000000.0)
  49
+        new_value = value / 1000000000.0
  50
+        return ngettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}
47 51
     if value < 1000000000000000:
48  
-        return '%.1f trillion' % (value / 1000000000000.0)
  52
+        new_value = value / 1000000000000.0
  53
+        return ngettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}
49 54
     return value
50 55
 register.filter(intword)
51 56
 
@@ -60,5 +65,5 @@ def apnumber(value):
60 65
         return value
61 66
     if not 0 < value < 10:
62 67
         return value
63  
-    return ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine')[value-1]
  68
+    return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1]
64 69
 register.filter(apnumber)
2  django/core/validators.py
@@ -364,7 +364,7 @@ def __init__(self, lower=None, upper=None, error_message=''):
364 364
         self.lower, self.upper = lower, upper
365 365
         if not error_message:
366 366
             if lower and upper:
367  
-                self.error_message = gettext("This value must be between %s and %s.") % (lower, upper)
  367
+                 self.error_message = gettext("This value must be between %(lower)s and %(upper)s.") % {'lower': lower, 'upper': upper}
368 368
             elif lower:
369 369
                 self.error_message = gettext("This value must be at least %s.") % lower
370 370
             elif upper:

0 notes on commit b1eea1a

Please sign in to comment.
Something went wrong with that request. Please try again.