Author: mtredinnick
Date: 2007-04-26 04:58:44 -0500 (Thu, 26 Apr 2007)
New Revision: 5082

Modified:
   django/branches/unicode/django/core/validators.py
   django/branches/unicode/django/db/models/fields/__init__.py
   django/branches/unicode/django/newforms/fields.py
   django/branches/unicode/django/oldforms/__init__.py
   django/branches/unicode/django/templatetags/i18n.py
   django/branches/unicode/tests/modeltests/manipulators/models.py
   django/branches/unicode/tests/modeltests/validation/models.py
Log:
unicode: Fixed #4152 -- Converted a lot of internal [n]gettext() calls into
u[n]gettext() calls. Thanks, Ivan Sagalaev.


Modified: django/branches/unicode/django/core/validators.py
===================================================================
--- django/branches/unicode/django/core/validators.py   2007-04-26 09:53:45 UTC 
(rev 5081)
+++ django/branches/unicode/django/core/validators.py   2007-04-26 09:58:44 UTC 
(rev 5082)
@@ -10,7 +10,7 @@
 
 import urllib2
 from django.conf import settings
-from django.utils.translation import gettext, gettext_lazy, ngettext
+from django.utils.translation import ugettext, ugettext_lazy, ungettext
 from django.utils.functional import Promise, lazy
 import re
 
@@ -61,30 +61,30 @@
 
 def isAlphaNumeric(field_data, all_data):
     if not alnum_re.search(field_data):
-        raise ValidationError, gettext("This value must contain only letters, 
numbers and underscores.")
+        raise ValidationError, ugettext("This value must contain only letters, 
numbers and underscores.")
 
 def isAlphaNumericURL(field_data, all_data):
     if not alnumurl_re.search(field_data):
-        raise ValidationError, gettext("This value must contain only letters, 
numbers, underscores, dashes or slashes.")
+        raise ValidationError, ugettext("This value must contain only letters, 
numbers, underscores, dashes or slashes.")
 
 def isSlug(field_data, all_data):
     if not slug_re.search(field_data):
-        raise ValidationError, gettext("This value must contain only letters, 
numbers, underscores or hyphens.")
+        raise ValidationError, ugettext("This value must contain only letters, 
numbers, underscores or hyphens.")
 
 def isLowerCase(field_data, all_data):
     if field_data.lower() != field_data:
-        raise ValidationError, gettext("Uppercase letters are not allowed 
here.")
+        raise ValidationError, ugettext("Uppercase letters are not allowed 
here.")
 
 def isUpperCase(field_data, all_data):
     if field_data.upper() != field_data:
-        raise ValidationError, gettext("Lowercase letters are not allowed 
here.")
+        raise ValidationError, ugettext("Lowercase letters are not allowed 
here.")
 
 def isCommaSeparatedIntegerList(field_data, all_data):
     for supposed_int in field_data.split(','):
         try:
             int(supposed_int)
         except ValueError:
-            raise ValidationError, gettext("Enter only digits separated by 
commas.")
+            raise ValidationError, ugettext("Enter only digits separated by 
commas.")
 
 def isCommaSeparatedEmailList(field_data, all_data):
     """
@@ -96,32 +96,32 @@
         try:
             isValidEmail(supposed_email.strip(), '')
         except ValidationError:
-            raise ValidationError, gettext("Enter valid e-mail addresses 
separated by commas.")
+            raise ValidationError, ugettext("Enter valid e-mail addresses 
separated by commas.")
 
 def isValidIPAddress4(field_data, all_data):
     if not ip4_re.search(field_data):
-        raise ValidationError, gettext("Please enter a valid IP address.")
+        raise ValidationError, ugettext("Please enter a valid IP address.")
 
 def isNotEmpty(field_data, all_data):
     if field_data.strip() == '':
-        raise ValidationError, gettext("Empty values are not allowed here.")
+        raise ValidationError, ugettext("Empty values are not allowed here.")
 
 def isOnlyDigits(field_data, all_data):
     if not field_data.isdigit():
-        raise ValidationError, gettext("Non-numeric characters aren't allowed 
here.")
+        raise ValidationError, ugettext("Non-numeric characters aren't allowed 
here.")
 
 def isNotOnlyDigits(field_data, all_data):
     if field_data.isdigit():
-        raise ValidationError, gettext("This value can't be comprised solely 
of digits.")
+        raise ValidationError, ugettext("This value can't be comprised solely 
of digits.")
 
 def isInteger(field_data, all_data):
     # This differs from isOnlyDigits because this accepts the negative sign
     if not integer_re.search(field_data):
-        raise ValidationError, gettext("Enter a whole number.")
+        raise ValidationError, ugettext("Enter a whole number.")
 
 def isOnlyLetters(field_data, all_data):
     if not field_data.isalpha():
-        raise ValidationError, gettext("Only alphabetical characters are 
allowed here.")
+        raise ValidationError, ugettext("Only alphabetical characters are 
allowed here.")
 
 def _isValidDate(date_string):
     """
@@ -136,30 +136,30 @@
     # This check is needed because strftime is used when saving the date
     # value to the database, and strftime requires that the year be >=1900.
     if year < 1900:
-        raise ValidationError, gettext('Year must be 1900 or later.')
+        raise ValidationError, ugettext('Year must be 1900 or later.')
     try:
         date(year, month, day)
     except ValueError, e:
-        msg = gettext('Invalid date: %s') % gettext(str(e))
+        msg = ugettext('Invalid date: %s') % ugettext(str(e))
         raise ValidationError, msg    
 
 def isValidANSIDate(field_data, all_data):
     if not ansi_date_re.search(field_data):
-        raise ValidationError, gettext('Enter a valid date in YYYY-MM-DD 
format.')
+        raise ValidationError, ugettext('Enter a valid date in YYYY-MM-DD 
format.')
     _isValidDate(field_data)
 
 def isValidANSITime(field_data, all_data):
     if not ansi_time_re.search(field_data):
-        raise ValidationError, gettext('Enter a valid time in HH:MM format.')
+        raise ValidationError, ugettext('Enter a valid time in HH:MM format.')
 
 def isValidANSIDatetime(field_data, all_data):
     if not ansi_datetime_re.search(field_data):
-        raise ValidationError, gettext('Enter a valid date/time in YYYY-MM-DD 
HH:MM format.')
+        raise ValidationError, ugettext('Enter a valid date/time in YYYY-MM-DD 
HH:MM format.')
     _isValidDate(field_data.split()[0])
 
 def isValidEmail(field_data, all_data):
     if not email_re.search(field_data):
-        raise ValidationError, gettext('Enter a valid e-mail address.')
+        raise ValidationError, ugettext('Enter a valid e-mail address.')
 
 def isValidImage(field_data, all_data):
     """
@@ -171,22 +171,22 @@
     try:
         content = field_data['content']
     except TypeError:
-        raise ValidationError, gettext("No file was submitted. Check the 
encoding type on the form.")
+        raise ValidationError, ugettext("No file was submitted. Check the 
encoding type on the form.")
     try:
         Image.open(StringIO(content))
     except IOError: # Python Imaging Library doesn't recognize it as an image
-        raise ValidationError, gettext("Upload a valid image. The file you 
uploaded was either not an image or a corrupted image.")
+        raise ValidationError, ugettext("Upload a valid image. The file you 
uploaded was either not an image or a corrupted image.")
 
 def isValidImageURL(field_data, all_data):
     uc = URLMimeTypeCheck(('image/jpeg', 'image/gif', 'image/png'))
     try:
         uc(field_data, all_data)
     except URLMimeTypeCheck.InvalidContentType:
-        raise ValidationError, gettext("The URL %s does not point to a valid 
image.") % field_data
+        raise ValidationError, ugettext("The URL %s does not point to a valid 
image.") % field_data
 
 def isValidPhone(field_data, all_data):
     if not phone_re.search(field_data):
-        raise ValidationError, gettext('Phone numbers must be in XXX-XXX-XXXX 
format. "%s" is invalid.') % field_data
+        raise ValidationError, ugettext('Phone numbers must be in XXX-XXX-XXXX 
format. "%s" is invalid.') % field_data
 
 def isValidQuicktimeVideoURL(field_data, all_data):
     "Checks that the given URL is a video that can be played by QuickTime (qt, 
mpeg)"
@@ -194,11 +194,11 @@
     try:
         uc(field_data, all_data)
     except URLMimeTypeCheck.InvalidContentType:
-        raise ValidationError, gettext("The URL %s does not point to a valid 
QuickTime video.") % field_data
+        raise ValidationError, ugettext("The URL %s does not point to a valid 
QuickTime video.") % field_data
 
 def isValidURL(field_data, all_data):
     if not url_re.search(field_data):
-        raise ValidationError, gettext("A valid URL is required.")
+        raise ValidationError, ugettext("A valid URL is required.")
 
 def isValidHTML(field_data, all_data):
     import urllib, urllib2
@@ -212,14 +212,14 @@
         return
     from xml.dom.minidom import parseString
     error_messages = [e.firstChild.wholeText for e in 
parseString(u.read()).getElementsByTagName('messages')[0].getElementsByTagName('msg')]
-    raise ValidationError, gettext("Valid HTML is required. Specific errors 
are:\n%s") % "\n".join(error_messages)
+    raise ValidationError, ugettext("Valid HTML is required. Specific errors 
are:\n%s") % "\n".join(error_messages)
 
 def isWellFormedXml(field_data, all_data):
     from xml.dom.minidom import parseString
     try:
         parseString(field_data)
     except Exception, e: # Naked except because we're not sure what will be 
thrown
-        raise ValidationError, gettext("Badly formed XML: %s") % str(e)
+        raise ValidationError, ugettext("Badly formed XML: %s") % str(e)
 
 def isWellFormedXmlFragment(field_data, all_data):
     isWellFormedXml('<root>%s</root>' % field_data, all_data)
@@ -249,7 +249,7 @@
     "Checks that the given string is a valid two-letter U.S. state 
abbreviation"
     states = ['AA', 'AE', 'AK', 'AL', 'AP', 'AR', 'AS', 'AZ', 'CA', 'CO', 
'CT', 'DC', 'DE', 'FL', 'FM', 'GA', 'GU', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 
'KY', 'LA', 'MA', 'MD', 'ME', 'MH', 'MI', 'MN', 'MO', 'MP', 'MS', 'MT', 'NC', 
'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'PW', 
'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VI', 'VT', 'WA', 'WI', 'WV', 'WY']
     if field_data.upper() not in states:
-        raise ValidationError, gettext("Enter a valid U.S. state 
abbreviation.")
+        raise ValidationError, ugettext("Enter a valid U.S. state 
abbreviation.")
 
 def hasNoProfanities(field_data, all_data):
     """
@@ -263,14 +263,14 @@
     if words_seen:
         from django.utils.text import get_text_list
         plural = len(words_seen) > 1
-        raise ValidationError, ngettext("Watch your mouth! The word %s is not 
allowed here.",
+        raise ValidationError, ungettext("Watch your mouth! The word %s is not 
allowed here.",
             "Watch your mouth! The words %s are not allowed here.", plural) % \
             get_text_list(['"%s%s%s"' % (i[0], '-'*(len(i)-2), i[-1]) for i in 
words_seen], 'and')
 
 class AlwaysMatchesOtherField(object):
     def __init__(self, other_field_name, error_message=None):
         self.other = other_field_name
-        self.error_message = error_message or lazy_inter(gettext_lazy("This 
field must match the '%s' field."), self.other)
+        self.error_message = error_message or lazy_inter(ugettext_lazy("This 
field must match the '%s' field."), self.other)
         self.always_test = True
 
     def __call__(self, field_data, all_data):
@@ -289,7 +289,7 @@
                 v(field_data, all_data)
 
 class RequiredIfOtherFieldNotGiven(object):
-    def __init__(self, other_field_name, error_message=gettext_lazy("Please 
enter something for at least one field.")):
+    def __init__(self, other_field_name, error_message=ugettext_lazy("Please 
enter something for at least one field.")):
         self.other, self.error_message = other_field_name, error_message
         self.always_test = True
 
@@ -298,7 +298,7 @@
             raise ValidationError, self.error_message
 
 class RequiredIfOtherFieldsGiven(object):
-    def __init__(self, other_field_names, error_message=gettext_lazy("Please 
enter both fields or leave them both empty.")):
+    def __init__(self, other_field_names, error_message=ugettext_lazy("Please 
enter both fields or leave them both empty.")):
         self.other, self.error_message = other_field_names, error_message
         self.always_test = True
 
@@ -309,7 +309,7 @@
 
 class RequiredIfOtherFieldGiven(RequiredIfOtherFieldsGiven):
     "Like RequiredIfOtherFieldsGiven, but takes a single field name instead of 
a list."
-    def __init__(self, other_field_name, error_message=gettext_lazy("Please 
enter both fields or leave them both empty.")):
+    def __init__(self, other_field_name, error_message=ugettext_lazy("Please 
enter both fields or leave them both empty.")):
         RequiredIfOtherFieldsGiven.__init__(self, [other_field_name], 
error_message)
 
 class RequiredIfOtherFieldEquals(object):
@@ -317,7 +317,7 @@
         self.other_field = other_field
         self.other_value = other_value
         other_label = other_label or other_value
-        self.error_message = error_message or lazy_inter(gettext_lazy("This 
field must be given if %(field)s is %(value)s"), {
+        self.error_message = error_message or lazy_inter(ugettext_lazy("This 
field must be given if %(field)s is %(value)s"), {
             'field': other_field, 'value': other_label})
         self.always_test = True
 
@@ -330,7 +330,7 @@
         self.other_field = other_field
         self.other_value = other_value
         other_label = other_label or other_value
-        self.error_message = error_message or lazy_inter(gettext_lazy("This 
field must be given if %(field)s is not %(value)s"), {
+        self.error_message = error_message or lazy_inter(ugettext_lazy("This 
field must be given if %(field)s is not %(value)s"), {
             'field': other_field, 'value': other_label})
         self.always_test = True
 
@@ -349,7 +349,7 @@
 class UniqueAmongstFieldsWithPrefix(object):
     def __init__(self, field_name, prefix, error_message):
         self.field_name, self.prefix = field_name, prefix
-        self.error_message = error_message or gettext_lazy("Duplicate values 
are not allowed.")
+        self.error_message = error_message or ugettext_lazy("Duplicate values 
are not allowed.")
 
     def __call__(self, field_data, all_data):
         for field_name, value in all_data.items():
@@ -364,11 +364,11 @@
         self.lower, self.upper = lower, upper
         if not error_message:
             if lower and upper:
-                 self.error_message = gettext("This value must be between 
%(lower)s and %(upper)s.") % {'lower': lower, 'upper': upper}
+                 self.error_message = ugettext("This value must be between 
%(lower)s and %(upper)s.") % {'lower': lower, 'upper': upper}
             elif lower:
-                self.error_message = gettext("This value must be at least 
%s.") % lower
+                self.error_message = ugettext("This value must be at least 
%s.") % lower
             elif upper:
-                self.error_message = gettext("This value must be no more than 
%s.") % upper
+                self.error_message = ugettext("This value must be no more than 
%s.") % upper
         else:
             self.error_message = error_message
 
@@ -404,7 +404,7 @@
         from math import log
         val = log(int(field_data)) / log(self.power_of)
         if val != int(val):
-            raise ValidationError, gettext("This value must be a power of 
%s.") % self.power_of
+            raise ValidationError, ugettext("This value must be a power of 
%s.") % self.power_of
 
 class IsValidFloat(object):
     def __init__(self, max_digits, decimal_places):
@@ -415,17 +415,17 @@
         try:
             float(data)
         except ValueError:
-            raise ValidationError, gettext("Please enter a valid decimal 
number.")
+            raise ValidationError, ugettext("Please enter a valid decimal 
number.")
         # Negative floats require more space to input.
         max_allowed_length = data.startswith('-') and (self.max_digits + 2) or 
(self.max_digits + 1)
         if len(data) > max_allowed_length:
-            raise ValidationError, ngettext("Please enter a valid decimal 
number with at most %s total digit.",
+            raise ValidationError, ungettext("Please enter a valid decimal 
number with at most %s total digit.",
                 "Please enter a valid decimal number with at most %s total 
digits.", self.max_digits) % self.max_digits
         if (not '.' in data and len(data) > (max_allowed_length - 
self.decimal_places - 1)) or ('.' in data and len(data) > (max_allowed_length - 
(self.decimal_places - len(data.split('.')[1])))):
-            raise ValidationError, ngettext( "Please enter a valid decimal 
number with a whole part of at most %s digit.",
+            raise ValidationError, ungettext( "Please enter a valid decimal 
number with a whole part of at most %s digit.",
                 "Please enter a valid decimal number with a whole part of at 
most %s digits.", str(self.max_digits-self.decimal_places)) % 
str(self.max_digits-self.decimal_places)
         if '.' in data and len(data.split('.')[1]) > self.decimal_places:
-            raise ValidationError, ngettext("Please enter a valid decimal 
number with at most %s decimal place.",
+            raise ValidationError, ungettext("Please enter a valid decimal 
number with at most %s decimal place.",
                 "Please enter a valid decimal number with at most %s decimal 
places.", self.decimal_places) % self.decimal_places
 
 class HasAllowableSize(object):
@@ -435,14 +435,14 @@
     """
     def __init__(self, min_size=None, max_size=None, min_error_message=None, 
max_error_message=None):
         self.min_size, self.max_size = min_size, max_size
-        self.min_error_message = min_error_message or 
lazy_inter(gettext_lazy("Make sure your uploaded file is at least %s bytes 
big."), min_size)
-        self.max_error_message = max_error_message or 
lazy_inter(gettext_lazy("Make sure your uploaded file is at most %s bytes 
big."), max_size)
+        self.min_error_message = min_error_message or 
lazy_inter(ugettext_lazy("Make sure your uploaded file is at least %s bytes 
big."), min_size)
+        self.max_error_message = max_error_message or 
lazy_inter(ugettext_lazy("Make sure your uploaded file is at most %s bytes 
big."), max_size)
 
     def __call__(self, field_data, all_data):
         try:
             content = field_data['content']
         except TypeError:
-            raise ValidationError, gettext_lazy("No file was submitted. Check 
the encoding type on the form.")
+            raise ValidationError, ugettext_lazy("No file was submitted. Check 
the encoding type on the form.")
         if self.min_size is not None and len(content) < self.min_size:
             raise ValidationError, self.min_error_message
         if self.max_size is not None and len(content) > self.max_size:
@@ -453,7 +453,7 @@
     Checks that the field matches the given regular-expression. The regex
     should be in string format, not already compiled.
     """
-    def __init__(self, regexp, error_message=gettext_lazy("The format for this 
field is wrong.")):
+    def __init__(self, regexp, error_message=ugettext_lazy("The format for 
this field is wrong.")):
         self.regexp = re.compile(regexp)
         self.error_message = error_message
 
@@ -468,7 +468,7 @@
     as a validation error. The message is rather unspecific, so it's best to
     specify one on instantiation.
     """
-    def __init__(self, validator_list=None, error_message=gettext_lazy("This 
field is invalid.")):
+    def __init__(self, validator_list=None, error_message=ugettext_lazy("This 
field is invalid.")):
         if validator_list is None: validator_list = []
         self.validator_list = validator_list
         self.error_message = error_message
@@ -504,10 +504,10 @@
         try:
             info = urllib2.urlopen(field_data).info()
         except (urllib2.HTTPError, urllib2.URLError):
-            raise URLMimeTypeCheck.CouldNotRetrieve, gettext("Could not 
retrieve anything from %s.") % field_data
+            raise URLMimeTypeCheck.CouldNotRetrieve, ugettext("Could not 
retrieve anything from %s.") % field_data
         content_type = info['content-type']
         if content_type not in self.mime_type_list:
-            raise URLMimeTypeCheck.InvalidContentType, gettext("The URL 
%(url)s returned the invalid Content-Type header '%(contenttype)s'.") % {
+            raise URLMimeTypeCheck.InvalidContentType, ugettext("The URL 
%(url)s returned the invalid Content-Type header '%(contenttype)s'.") % {
                 'url': field_data, 'contenttype': content_type}
 
 class RelaxNGCompact(object):

Modified: django/branches/unicode/django/db/models/fields/__init__.py
===================================================================
--- django/branches/unicode/django/db/models/fields/__init__.py 2007-04-26 
09:53:45 UTC (rev 5081)
+++ django/branches/unicode/django/db/models/fields/__init__.py 2007-04-26 
09:58:44 UTC (rev 5082)
@@ -8,7 +8,7 @@
 from django.utils.functional import curry
 from django.utils.itercompat import tee
 from django.utils.text import capfirst
-from django.utils.translation import gettext, gettext_lazy
+from django.utils.translation import ugettext, ugettext_lazy
 import datetime, os, time
 
 class NOT_PROVIDED:
@@ -39,7 +39,7 @@
         return
     if getattr(self, 'original_object', None) and 
self.original_object._get_pk_val() == old_obj._get_pk_val():
         return
-    raise validators.ValidationError, gettext("%(optname)s with this 
%(fieldname)s already exists.") % {'optname': capfirst(opts.verbose_name), 
'fieldname': f.verbose_name}
+    raise validators.ValidationError, ugettext("%(optname)s with this 
%(fieldname)s already exists.") % {'optname': capfirst(opts.verbose_name), 
'fieldname': f.verbose_name}
 
 # A guide to Field parameters:
 #
@@ -114,7 +114,7 @@
         Subclasses should implement validate(), not validate_full().
         """
         if not self.blank and not field_data:
-            return [gettext_lazy('This field is required.')]
+            return [ugettext_lazy('This field is required.')]
         try:
             self.validate(field_data, all_data)
         except validators.ValidationError, e:
@@ -271,7 +271,7 @@
                     
core_field_names.extend(f.get_manipulator_field_names(name_prefix))
             # Now, if there are any, add the validator to this FormField.
             if core_field_names:
-                
params['validator_list'].append(validators.RequiredIfOtherFieldsGiven(core_field_names,
 gettext_lazy("This field is required.")))
+                
params['validator_list'].append(validators.RequiredIfOtherFieldsGiven(core_field_names,
 ugettext_lazy("This field is required.")))
 
         # Finally, add the field_names.
         field_names = self.get_manipulator_field_names(name_prefix)
@@ -364,7 +364,7 @@
         try:
             return int(value)
         except (TypeError, ValueError):
-            raise validators.ValidationError, gettext("This value must be an 
integer.")
+            raise validators.ValidationError, ugettext("This value must be an 
integer.")
 
     def get_manipulator_fields(self, opts, manipulator, change, 
name_prefix='', rel=False, follow=True):
         if not rel:
@@ -399,7 +399,7 @@
         if value in (True, False): return value
         if value in ('t', 'True', '1'): return True
         if value in ('f', 'False', '0'): return False
-        raise validators.ValidationError, gettext("This value must be either 
True or False.")
+        raise validators.ValidationError, ugettext("This value must be either 
True or False.")
 
     def get_manipulator_field_objs(self):
         return [oldforms.CheckboxField]
@@ -420,7 +420,7 @@
             if self.null:
                 return value
             else:
-                raise validators.ValidationError, gettext_lazy("This field 
cannot be null.")
+                raise validators.ValidationError, ugettext_lazy("This field 
cannot be null.")
         return str(value)
 
     def formfield(self, **kwargs):
@@ -454,7 +454,7 @@
         try:
             return datetime.date(*time.strptime(value, '%Y-%m-%d')[:3])
         except ValueError:
-            raise validators.ValidationError, gettext('Enter a valid date in 
YYYY-MM-DD format.')
+            raise validators.ValidationError, ugettext('Enter a valid date in 
YYYY-MM-DD format.')
 
     def get_db_prep_lookup(self, lookup_type, value):
         if lookup_type == 'range':
@@ -523,7 +523,7 @@
                 try:
                     return datetime.datetime(*time.strptime(value, 
'%Y-%m-%d')[:3])
                 except ValueError:
-                    raise validators.ValidationError, gettext('Enter a valid 
date/time in YYYY-MM-DD HH:MM format.')
+                    raise validators.ValidationError, ugettext('Enter a valid 
date/time in YYYY-MM-DD HH:MM format.')
 
     def get_db_prep_save(self, value):
         # Casts dates into string format for entry into database.
@@ -607,7 +607,7 @@
                         self.always_test = True
                     def __call__(self, field_data, all_data):
                         if not all_data.get(self.other_file_field_name, False):
-                            c = 
validators.RequiredIfOtherFieldsGiven(self.other_field_names, 
gettext_lazy("This field is required."))
+                            c = 
validators.RequiredIfOtherFieldsGiven(self.other_field_names, 
ugettext_lazy("This field is required."))
                             c(field_data, all_data)
                 # First, get the core fields, if any.
                 core_field_names = []
@@ -618,7 +618,7 @@
                 if core_field_names:
                     
field_list[0].validator_list.append(RequiredFileField(core_field_names, 
field_list[1].field_name))
             else:
-                v = 
validators.RequiredIfOtherFieldNotGiven(field_list[1].field_name, 
gettext_lazy("This field is required."))
+                v = 
validators.RequiredIfOtherFieldNotGiven(field_list[1].field_name, 
ugettext_lazy("This field is required."))
                 v.always_test = True
                 field_list[0].validator_list.append(v)
                 field_list[0].is_required = field_list[1].is_required = False
@@ -748,7 +748,7 @@
         if value in ('None'): return None
         if value in ('t', 'True', '1'): return True
         if value in ('f', 'False', '0'): return False
-        raise validators.ValidationError, gettext("This value must be either 
None, True or False.")
+        raise validators.ValidationError, ugettext("This value must be either 
None, True or False.")
 
     def get_manipulator_field_objs(self):
         return [oldforms.NullBooleanField]

Modified: django/branches/unicode/django/newforms/fields.py
===================================================================
--- django/branches/unicode/django/newforms/fields.py   2007-04-26 09:53:45 UTC 
(rev 5081)
+++ django/branches/unicode/django/newforms/fields.py   2007-04-26 09:58:44 UTC 
(rev 5082)
@@ -2,7 +2,7 @@
 Field classes
 """
 
-from django.utils.translation import gettext
+from django.utils.translation import ugettext
 from django.utils.encoding import smart_unicode
 from util import ErrorList, ValidationError
 from widgets import TextInput, PasswordInput, HiddenInput, 
MultipleHiddenInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple
@@ -77,7 +77,7 @@
         Raises ValidationError for any errors.
         """
         if self.required and value in EMPTY_VALUES:
-            raise ValidationError(gettext(u'This field is required.'))
+            raise ValidationError(ugettext(u'This field is required.'))
         return value
 
     def widget_attrs(self, widget):
@@ -100,9 +100,9 @@
             return u''
         value = smart_unicode(value)
         if self.max_length is not None and len(value) > self.max_length:
-            raise ValidationError(gettext(u'Ensure this value has at most %d 
characters.') % self.max_length)
+            raise ValidationError(ugettext(u'Ensure this value has at most %d 
characters.') % self.max_length)
         if self.min_length is not None and len(value) < self.min_length:
-            raise ValidationError(gettext(u'Ensure this value has at least %d 
characters.') % self.min_length)
+            raise ValidationError(ugettext(u'Ensure this value has at least %d 
characters.') % self.min_length)
         return value
 
     def widget_attrs(self, widget):
@@ -125,11 +125,11 @@
         try:
             value = int(value)
         except (ValueError, TypeError):
-            raise ValidationError(gettext(u'Enter a whole number.'))
+            raise ValidationError(ugettext(u'Enter a whole number.'))
         if self.max_value is not None and value > self.max_value:
-            raise ValidationError(gettext(u'Ensure this value is less than or 
equal to %s.') % self.max_value)
+            raise ValidationError(ugettext(u'Ensure this value is less than or 
equal to %s.') % self.max_value)
         if self.min_value is not None and value < self.min_value:
-            raise ValidationError(gettext(u'Ensure this value is greater than 
or equal to %s.') % self.min_value)
+            raise ValidationError(ugettext(u'Ensure this value is greater than 
or equal to %s.') % self.min_value)
         return value
 
 DEFAULT_DATE_INPUT_FORMATS = (
@@ -162,7 +162,7 @@
                 return datetime.date(*time.strptime(value, format)[:3])
             except ValueError:
                 continue
-        raise ValidationError(gettext(u'Enter a valid date.'))
+        raise ValidationError(ugettext(u'Enter a valid date.'))
 
 DEFAULT_TIME_INPUT_FORMATS = (
     '%H:%M:%S',     # '14:30:59'
@@ -189,7 +189,7 @@
                 return datetime.time(*time.strptime(value, format)[3:6])
             except ValueError:
                 continue
-        raise ValidationError(gettext(u'Enter a valid time.'))
+        raise ValidationError(ugettext(u'Enter a valid time.'))
 
 DEFAULT_DATETIME_INPUT_FORMATS = (
     '%Y-%m-%d %H:%M:%S',     # '2006-10-25 14:30:59'
@@ -225,7 +225,7 @@
                 return datetime.datetime(*time.strptime(value, format)[:6])
             except ValueError:
                 continue
-        raise ValidationError(gettext(u'Enter a valid date/time.'))
+        raise ValidationError(ugettext(u'Enter a valid date/time.'))
 
 class RegexField(Field):
     def __init__(self, regex, max_length=None, min_length=None, 
error_message=None, *args, **kwargs):
@@ -239,7 +239,7 @@
             regex = re.compile(regex)
         self.regex = regex
         self.max_length, self.min_length = max_length, min_length
-        self.error_message = error_message or gettext(u'Enter a valid value.')
+        self.error_message = error_message or ugettext(u'Enter a valid value.')
 
     def clean(self, value):
         """
@@ -253,9 +253,9 @@
         if value == u'':
             return value
         if self.max_length is not None and len(value) > self.max_length:
-            raise ValidationError(gettext(u'Ensure this value has at most %d 
characters.') % self.max_length)
+            raise ValidationError(ugettext(u'Ensure this value has at most %d 
characters.') % self.max_length)
         if self.min_length is not None and len(value) < self.min_length:
-            raise ValidationError(gettext(u'Ensure this value has at least %d 
characters.') % self.min_length)
+            raise ValidationError(ugettext(u'Ensure this value has at least %d 
characters.') % self.min_length)
         if not self.regex.search(value):
             raise ValidationError(self.error_message)
         return value
@@ -268,7 +268,7 @@
 class EmailField(RegexField):
     def __init__(self, max_length=None, min_length=None, *args, **kwargs):
         RegexField.__init__(self, email_re, max_length, min_length,
-            gettext(u'Enter a valid e-mail address.'), *args, **kwargs)
+            ugettext(u'Enter a valid e-mail address.'), *args, **kwargs)
 
 url_re = re.compile(
     r'^https?://' # http:// or https://
@@ -286,7 +286,7 @@
 class URLField(RegexField):
     def __init__(self, max_length=None, min_length=None, verify_exists=False,
             validator_user_agent=URL_VALIDATOR_USER_AGENT, *args, **kwargs):
-        super(URLField, self).__init__(url_re, max_length, min_length, 
gettext(u'Enter a valid URL.'), *args, **kwargs)
+        super(URLField, self).__init__(url_re, max_length, min_length, 
ugettext(u'Enter a valid URL.'), *args, **kwargs)
         self.verify_exists = verify_exists
         self.user_agent = validator_user_agent
 
@@ -308,9 +308,9 @@
                 req = urllib2.Request(value, None, headers)
                 u = urllib2.urlopen(req)
             except ValueError:
-                raise ValidationError(gettext(u'Enter a valid URL.'))
+                raise ValidationError(ugettext(u'Enter a valid URL.'))
             except: # urllib2.URLError, httplib.InvalidURL, etc.
-                raise ValidationError(gettext(u'This URL appears to be a 
broken link.'))
+                raise ValidationError(ugettext(u'This URL appears to be a 
broken link.'))
         return value
 
 class BooleanField(Field):
@@ -361,7 +361,7 @@
             return value
         valid_values = set([str(k) for k, v in self.choices])
         if value not in valid_values:
-            raise ValidationError(gettext(u'Select a valid choice. That choice 
is not one of the available choices.'))
+            raise ValidationError(ugettext(u'Select a valid choice. That 
choice is not one of the available choices.'))
         return value
 
 class MultipleChoiceField(ChoiceField):
@@ -373,11 +373,11 @@
         Validates that the input is a list or tuple.
         """
         if self.required and not value:
-            raise ValidationError(gettext(u'This field is required.'))
+            raise ValidationError(ugettext(u'This field is required.'))
         elif not self.required and not value:
             return []
         if not isinstance(value, (list, tuple)):
-            raise ValidationError(gettext(u'Enter a list of values.'))
+            raise ValidationError(ugettext(u'Enter a list of values.'))
         new_value = []
         for val in value:
             val = smart_unicode(val)
@@ -386,7 +386,7 @@
         valid_values = set([smart_unicode(k) for k, v in self.choices])
         for val in new_value:
             if val not in valid_values:
-                raise ValidationError(gettext(u'Select a valid choice. %s is 
not one of the available choices.') % val)
+                raise ValidationError(ugettext(u'Select a valid choice. %s is 
not one of the available choices.') % val)
         return new_value
 
 class ComboField(Field):
@@ -449,18 +449,18 @@
         clean_data = []
         errors = ErrorList()
         if self.required and not value:
-            raise ValidationError(gettext(u'This field is required.'))
+            raise ValidationError(ugettext(u'This field is required.'))
         elif not self.required and not value:
             return self.compress([])
         if not isinstance(value, (list, tuple)):
-            raise ValidationError(gettext(u'Enter a list of values.'))
+            raise ValidationError(ugettext(u'Enter a list of values.'))
         for i, field in enumerate(self.fields):
             try:
                 field_value = value[i]
             except KeyError:
                 field_value = None
             if self.required and field_value in EMPTY_VALUES:
-                raise ValidationError(gettext(u'This field is required.'))
+                raise ValidationError(ugettext(u'This field is required.'))
             try:
                 clean_data.append(field.clean(field_value))
             except ValidationError, e:

Modified: django/branches/unicode/django/oldforms/__init__.py
===================================================================
--- django/branches/unicode/django/oldforms/__init__.py 2007-04-26 09:53:45 UTC 
(rev 5081)
+++ django/branches/unicode/django/oldforms/__init__.py 2007-04-26 09:58:44 UTC 
(rev 5082)
@@ -2,7 +2,7 @@
 from django.core.exceptions import PermissionDenied
 from django.utils.html import escape
 from django.conf import settings
-from django.utils.translation import gettext, ngettext
+from django.utils.translation import ugettext, ungettext
 
 FORM_FIELD_ID_PREFIX = 'id_'
 
@@ -66,7 +66,7 @@
                     errors.setdefault(field.field_name, []).extend(e.messages)
 
 #            if field.is_required and not new_data.get(field.field_name, 
False):
-#                errors.setdefault(field.field_name, 
[]).append(gettext_lazy('This field is required.'))
+#                errors.setdefault(field.field_name, 
[]).append(ugettext_lazy('This field is required.'))
 #                continue
 #            try:
 #                validator_list = field.validator_list
@@ -354,7 +354,7 @@
     def get_validation_errors(self, new_data):
         errors = {}
         if self.is_required and not new_data.get(self.field_name, False):
-            errors.setdefault(self.field_name, []).append(gettext('This field 
is required.'))
+            errors.setdefault(self.field_name, []).append(ugettext('This field 
is required.'))
             return errors
         try:
             for validator in self.validator_list:
@@ -389,12 +389,12 @@
 
     def isValidLength(self, data, form):
         if data and self.maxlength and 
len(data.decode(settings.DEFAULT_CHARSET)) > self.maxlength:
-            raise validators.ValidationError, ngettext("Ensure your text is 
less than %s character.",
+            raise validators.ValidationError, ungettext("Ensure your text is 
less than %s character.",
                 "Ensure your text is less than %s characters.", 
self.maxlength) % self.maxlength
 
     def hasNoNewlines(self, data, form):
         if data and '\n' in data:
-            raise validators.ValidationError, gettext("Line breaks are not 
allowed here.")
+            raise validators.ValidationError, ugettext("Line breaks are not 
allowed here.")
 
     def render(self, data):
         if data is None:
@@ -495,7 +495,7 @@
         str_data = str(data)
         str_choices = [str(item[0]) for item in self.choices]
         if str_data not in str_choices:
-            raise validators.ValidationError, gettext("Select a valid choice; 
'%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices}
+            raise validators.ValidationError, ugettext("Select a valid choice; 
'%(data)s' is not in %(choices)s.") % {'data': str_data, 'choices': str_choices}
 
 class NullSelectField(SelectField):
     "This SelectField converts blank fields to None"
@@ -568,7 +568,7 @@
         str_data = str(data)
         str_choices = [str(item[0]) for item in self.choices]
         if str_data not in str_choices:
-            raise validators.ValidationError, gettext("Select a valid choice; 
'%(data)s' is not in %(choices)s.") % {'data':str_data, 'choices':str_choices}
+            raise validators.ValidationError, ugettext("Select a valid choice; 
'%(data)s' is not in %(choices)s.") % {'data':str_data, 'choices':str_choices}
 
 class NullBooleanField(SelectField):
     "This SelectField provides 'Yes', 'No' and 'Unknown', mapping results to 
True, False or None"
@@ -607,7 +607,7 @@
         str_choices = [str(item[0]) for item in self.choices]
         for val in map(str, field_data):
             if val not in str_choices:
-                raise validators.ValidationError, gettext("Select a valid 
choice; '%(data)s' is not in %(choices)s.") % {'data':val, 
'choices':str_choices}
+                raise validators.ValidationError, ugettext("Select a valid 
choice; '%(data)s' is not in %(choices)s.") % {'data':val, 
'choices':str_choices}
 
     def html2python(data):
         if data is None:
@@ -669,9 +669,9 @@
         try:
             content = field_data['content']
         except TypeError:
-            raise validators.CriticalValidationError, gettext("No file was 
submitted. Check the encoding type on the form.")
+            raise validators.CriticalValidationError, ugettext("No file was 
submitted. Check the encoding type on the form.")
         if not content:
-            raise validators.CriticalValidationError, gettext("The submitted 
file is empty.")
+            raise validators.CriticalValidationError, ugettext("The submitted 
file is empty.")
 
     def render(self, data):
         return '<input type="file" id="%s" class="v%s" name="%s" />' % \
@@ -727,7 +727,7 @@
 
     def isSmallInteger(self, field_data, all_data):
         if not -32768 <= int(field_data) <= 32767:
-            raise validators.CriticalValidationError, gettext("Enter a whole 
number between -32,768 and 32,767.")
+            raise validators.CriticalValidationError, ugettext("Enter a whole 
number between -32,768 and 32,767.")
 
 class PositiveIntegerField(IntegerField):
     def __init__(self, field_name, length=10, maxlength=None, 
is_required=False, validator_list=None):
@@ -737,7 +737,7 @@
 
     def isPositive(self, field_data, all_data):
         if int(field_data) < 0:
-            raise validators.CriticalValidationError, gettext("Enter a 
positive number.")
+            raise validators.CriticalValidationError, ugettext("Enter a 
positive number.")
 
 class PositiveSmallIntegerField(IntegerField):
     def __init__(self, field_name, length=5, maxlength=None, 
is_required=False, validator_list=None):
@@ -747,7 +747,7 @@
 
     def isPositiveSmall(self, field_data, all_data):
         if not 0 <= int(field_data) <= 32767:
-            raise validators.CriticalValidationError, gettext("Enter a whole 
number between 0 and 32,767.")
+            raise validators.CriticalValidationError, ugettext("Enter a whole 
number between 0 and 32,767.")
 
 class FloatField(TextField):
     def __init__(self, field_name, max_digits, decimal_places, 
is_required=False, validator_list=None):

Modified: django/branches/unicode/django/templatetags/i18n.py
===================================================================
--- django/branches/unicode/django/templatetags/i18n.py 2007-04-26 09:53:45 UTC 
(rev 5081)
+++ django/branches/unicode/django/templatetags/i18n.py 2007-04-26 09:58:44 UTC 
(rev 5082)
@@ -40,7 +40,7 @@
         if self.noop:
             return value
         else:
-            return translation.gettext(value)
+            return translation.ugettext(value)
 
 class BlockTranslateNode(Node):
     def __init__(self, extra_context, singular, plural=None, countervar=None, 
counter=None):
@@ -68,9 +68,9 @@
             count = self.counter.resolve(context)
             context[self.countervar] = count
             plural = self.render_token_list(self.plural)
-            result = translation.ngettext(singular, plural, count) % context
+            result = translation.ungettext(singular, plural, count) % context
         else:
-            result = translation.gettext(singular) % context
+            result = translation.ugettext(singular) % context
         context.pop()
         return result
 

Modified: django/branches/unicode/tests/modeltests/manipulators/models.py
===================================================================
--- django/branches/unicode/tests/modeltests/manipulators/models.py     
2007-04-26 09:53:45 UTC (rev 5081)
+++ django/branches/unicode/tests/modeltests/manipulators/models.py     
2007-04-26 09:58:44 UTC (rev 5082)
@@ -41,24 +41,24 @@
 
 # Attempt to add a Musician without a first_name.
 >>> man.get_validation_errors(MultiValueDict({'last_name': ['Blakey']}))
-{'first_name': ['This field is required.']}
+{'first_name': [u'This field is required.']}
 
 # Attempt to add a Musician without a first_name and last_name.
 >>> man.get_validation_errors(MultiValueDict({}))
-{'first_name': ['This field is required.'], 'last_name': ['This field is 
required.']}
+{'first_name': [u'This field is required.'], 'last_name': [u'This field is 
required.']}
 
 # Attempt to create an Album without a name or musician.
 >>> man = Album.AddManipulator()
 >>> man.get_validation_errors(MultiValueDict({}))
-{'musician': ['This field is required.'], 'name': ['This field is required.']}
+{'musician': [u'This field is required.'], 'name': [u'This field is 
required.']}
 
 # Attempt to create an Album with an invalid musician.
 >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 
 >>> 'musician': ['foo']}))
-{'musician': ["Select a valid choice; 'foo' is not in ['', '1']."]}
+{'musician': [u"Select a valid choice; 'foo' is not in ['', '1']."]}
 
 # Attempt to create an Album with an invalid release_date.
 >>> man.get_validation_errors(MultiValueDict({'name': ['Sallies Fforth'], 
 >>> 'musician': ['1'], 'release_date': 'today'}))
-{'release_date': ['Enter a valid date in YYYY-MM-DD format.']}
+{'release_date': [u'Enter a valid date in YYYY-MM-DD format.']}
 
 # Create an Album without a release_date (because it's optional).
 >>> data = MultiValueDict({'name': ['Ella and Basie'], 'musician': ['1']})

Modified: django/branches/unicode/tests/modeltests/validation/models.py
===================================================================
--- django/branches/unicode/tests/modeltests/validation/models.py       
2007-04-26 09:53:45 UTC (rev 5081)
+++ django/branches/unicode/tests/modeltests/validation/models.py       
2007-04-26 09:58:44 UTC (rev 5082)
@@ -42,7 +42,7 @@
 
 >>> p = Person(**dict(valid_params, id='foo'))
 >>> p.validate()
-{'id': ['This value must be an integer.']}
+{'id': [u'This value must be an integer.']}
 
 >>> p = Person(**dict(valid_params, id=None))
 >>> p.validate()
@@ -76,7 +76,7 @@
 
 >>> p = Person(**dict(valid_params, is_child='foo'))
 >>> p.validate()
-{'is_child': ['This value must be either True or False.']}
+{'is_child': [u'This value must be either True or False.']}
 
 >>> p = Person(**dict(valid_params, name=u'Jose'))
 >>> p.validate()
@@ -116,7 +116,7 @@
 
 >>> p = Person(**dict(valid_params, birthdate='foo'))
 >>> p.validate()
-{'birthdate': ['Enter a valid date in YYYY-MM-DD format.']}
+{'birthdate': [u'Enter a valid date in YYYY-MM-DD format.']}
 
 >>> p = Person(**dict(valid_params, favorite_moment=datetime.datetime(2002, 4, 
 >>> 3, 13, 23)))
 >>> p.validate()
@@ -144,10 +144,10 @@
 
 >>> p = Person(**dict(valid_params, email=22))
 >>> p.validate()
-{'email': ['Enter a valid e-mail address.']}
+{'email': [u'Enter a valid e-mail address.']}
 
 # Make sure that Date and DateTime return validation errors and don't raise 
Python errors.
 >>> Person(name='John Doe', is_child=True, email='[EMAIL 
 >>> PROTECTED]').validate()
-{'favorite_moment': ['This field is required.'], 'birthdate': ['This field is 
required.']}
+{'favorite_moment': [u'This field is required.'], 'birthdate': [u'This field 
is required.']}
 
 """}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to