Fixed #3410 -- Edited a few i18n markups for completeness and to remove 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
This commit is contained in:
parent
a5e9f508ce
commit
b1eea1af40
|
@ -81,7 +81,7 @@ def make_messages():
|
||||||
src = pythonize_re.sub('\n#', src)
|
src = pythonize_re.sub('\n#', src)
|
||||||
open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
|
open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
|
||||||
thefile = '%s.py' % file
|
thefile = '%s.py' % file
|
||||||
cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
|
cmd = 'xgettext %s -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % (
|
||||||
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
|
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
|
||||||
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
|
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
|
||||||
msgs = stdout.read()
|
msgs = stdout.read()
|
||||||
|
@ -103,7 +103,7 @@ def make_messages():
|
||||||
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
|
open(os.path.join(dirpath, '%s.py' % file), "wb").write(templatize(src))
|
||||||
thefile = '%s.py' % file
|
thefile = '%s.py' % file
|
||||||
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
|
if verbose: sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
|
||||||
cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy -o - "%s"' % (
|
cmd = 'xgettext %s -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy --from-code UTF-8 -o - "%s"' % (
|
||||||
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
|
os.path.exists(potfile) and '--omit-header' or '', domain, os.path.join(dirpath, thefile))
|
||||||
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
|
(stdin, stdout, stderr) = os.popen3(cmd, 'b')
|
||||||
msgs = stdout.read()
|
msgs = stdout.read()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -168,7 +168,7 @@ def model_detail(request, app_label, model_name):
|
||||||
model = m
|
model = m
|
||||||
break
|
break
|
||||||
if model is None:
|
if model is None:
|
||||||
raise Http404, _("Model %r not found in app %r") % (model_name, app_label)
|
raise Http404, _("Model %(name)r not found in app %(label)r") % {'name': model_name, 'label': app_label}
|
||||||
|
|
||||||
opts = model._meta
|
opts = model._meta
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ def model_detail(request, app_label, model_name):
|
||||||
if isinstance(field, models.ForeignKey):
|
if isinstance(field, models.ForeignKey):
|
||||||
data_type = related_object_name = field.rel.to.__name__
|
data_type = related_object_name = field.rel.to.__name__
|
||||||
app_label = field.rel.to._meta.app_label
|
app_label = field.rel.to._meta.app_label
|
||||||
verbose = utils.parse_rst((_("the related `%s.%s` object") % (app_label, data_type)), 'model', _('model:') + data_type)
|
verbose = utils.parse_rst((_("the related `%(label)s.%(type)s` object") % {'label': app_label, 'type': data_type}), 'model', _('model:') + data_type)
|
||||||
else:
|
else:
|
||||||
data_type = get_readable_field_data_type(field)
|
data_type = get_readable_field_data_type(field)
|
||||||
verbose = field.verbose_name
|
verbose = field.verbose_name
|
||||||
|
@ -211,7 +211,7 @@ def model_detail(request, app_label, model_name):
|
||||||
|
|
||||||
# Gather related objects
|
# Gather related objects
|
||||||
for rel in opts.get_all_related_objects():
|
for rel in opts.get_all_related_objects():
|
||||||
verbose = _("related `%s.%s` objects") % (rel.opts.app_label, rel.opts.object_name)
|
verbose = _("related `%(label)s.%(name)s` objects") % {'label': rel.opts.app_label, 'name': rel.opts.object_name}
|
||||||
accessor = rel.get_accessor_name()
|
accessor = rel.get_accessor_name()
|
||||||
fields.append({
|
fields.append({
|
||||||
'name' : "%s.all" % accessor,
|
'name' : "%s.all" % accessor,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.utils.translation import ngettext
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django import template
|
from django import template
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -12,9 +14,9 @@ def ordinal(value):
|
||||||
value = int(value)
|
value = int(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return value
|
return value
|
||||||
t = ('th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th')
|
t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th'))
|
||||||
if value % 100 in (11, 12, 13): # special case
|
if value % 100 in (11, 12, 13): # special case
|
||||||
return '%dth' % value
|
return "%d%s" % (value, t[0])
|
||||||
return '%d%s' % (value, t[value % 10])
|
return '%d%s' % (value, t[value % 10])
|
||||||
register.filter(ordinal)
|
register.filter(ordinal)
|
||||||
|
|
||||||
|
@ -41,11 +43,14 @@ def intword(value):
|
||||||
if value < 1000000:
|
if value < 1000000:
|
||||||
return value
|
return value
|
||||||
if value < 1000000000:
|
if value < 1000000000:
|
||||||
return '%.1f million' % (value / 1000000.0)
|
new_value = value / 1000000.0
|
||||||
|
return ngettext('%(value).1f million', '%(value).1f million', new_value) % {'value': new_value}
|
||||||
if value < 1000000000000:
|
if value < 1000000000000:
|
||||||
return '%.1f billion' % (value / 1000000000.0)
|
new_value = value / 1000000000.0
|
||||||
|
return ngettext('%(value).1f billion', '%(value).1f billion', new_value) % {'value': new_value}
|
||||||
if value < 1000000000000000:
|
if value < 1000000000000000:
|
||||||
return '%.1f trillion' % (value / 1000000000000.0)
|
new_value = value / 1000000000000.0
|
||||||
|
return ngettext('%(value).1f trillion', '%(value).1f trillion', new_value) % {'value': new_value}
|
||||||
return value
|
return value
|
||||||
register.filter(intword)
|
register.filter(intword)
|
||||||
|
|
||||||
|
@ -60,5 +65,5 @@ def apnumber(value):
|
||||||
return value
|
return value
|
||||||
if not 0 < value < 10:
|
if not 0 < value < 10:
|
||||||
return value
|
return value
|
||||||
return ('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine')[value-1]
|
return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1]
|
||||||
register.filter(apnumber)
|
register.filter(apnumber)
|
||||||
|
|
|
@ -364,7 +364,7 @@ class NumberIsInRange(object):
|
||||||
self.lower, self.upper = lower, upper
|
self.lower, self.upper = lower, upper
|
||||||
if not error_message:
|
if not error_message:
|
||||||
if lower and upper:
|
if lower and upper:
|
||||||
self.error_message = gettext("This value must be between %s and %s.") % (lower, upper)
|
self.error_message = gettext("This value must be between %(lower)s and %(upper)s.") % {'lower': lower, 'upper': upper}
|
||||||
elif lower:
|
elif lower:
|
||||||
self.error_message = gettext("This value must be at least %s.") % lower
|
self.error_message = gettext("This value must be at least %s.") % lower
|
||||||
elif upper:
|
elif upper:
|
||||||
|
|
Loading…
Reference in New Issue