Ticket #17457: 17457-1.diff

File 17457-1.diff, 3.9 KB (added by Claude Paroz, 13 years ago)

Translate hasher keys in password widget

  • django/contrib/auth/forms.py

    diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
    index 50b2e2b..336e302 100644
    a b from django.template import loader  
    44from django.utils.encoding import smart_str
    55from django.utils.http import int_to_base36
    66from django.utils.safestring import mark_safe
    7 from django.utils.translation import ugettext_lazy as _
     7from django.utils.translation import ugettext, ugettext_lazy as _
    88
    99from django.contrib.auth import authenticate
    1010from django.contrib.auth.models import User
    class ReadOnlyPasswordHashWidget(forms.Widget):  
    3636
    3737        summary = ""
    3838        for key, value in hasher.safe_summary(encoded).iteritems():
    39             summary += "<strong>%(key)s</strong>: %(value)s " % {"key": key, "value": value}
     39            summary += "<strong>%(key)s</strong>: %(value)s " % {"key": ugettext(key), "value": value}
    4040
    4141        return mark_safe("<div%(attrs)s>%(summary)s</div>" % {"attrs": flatatt(final_attrs), "summary": summary})
    4242
  • django/contrib/auth/hashers.py

    diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
    index 0b3b6c3..d133bcb 100644
    a b from django.utils.encoding import smart_str  
    77from django.core.exceptions import ImproperlyConfigured
    88from django.utils.crypto import (
    99    pbkdf2, constant_time_compare, get_random_string)
     10from django.utils.translation import ugettext_noop as _
    1011
    1112
    1213UNUSABLE_PASSWORD = '!'  # This will never be a valid encoded hash
    class PBKDF2PasswordHasher(BasePasswordHasher):  
    212213        algorithm, iterations, salt, hash = encoded.split('$', 3)
    213214        assert algorithm == self.algorithm
    214215        return SortedDict([
    215             ('algorithm', algorithm),
    216             ('iterations', iterations),
    217             ('salt', mask_hash(salt)),
    218             ('hash', mask_hash(hash)),
     216            (_('algorithm'), algorithm),
     217            (_('iterations'), iterations),
     218            (_('salt'), mask_hash(salt)),
     219            (_('hash'), mask_hash(hash)),
    219220        ])
    220221
    221222
    class BCryptPasswordHasher(BasePasswordHasher):  
    263264        assert algorithm == self.algorithm
    264265        salt, checksum = data[:22], data[22:]
    265266        return SortedDict([
    266             ('algorithm', algorithm),
    267             ('work factor', work_factor),
    268             ('salt', mask_hash(salt)),
    269             ('checksum', mask_hash(checksum)),
     267            (_('algorithm'), algorithm),
     268            (_('work factor'), work_factor),
     269            (_('salt'), mask_hash(salt)),
     270            (_('checksum'), mask_hash(checksum)),
    270271        ])
    271272
    272273
    class SHA1PasswordHasher(BasePasswordHasher):  
    292293        algorithm, salt, hash = encoded.split('$', 2)
    293294        assert algorithm == self.algorithm
    294295        return SortedDict([
    295             ('algorithm', algorithm),
    296             ('salt', mask_hash(salt, show=2)),
    297             ('hash', mask_hash(hash)),
     296            (_('algorithm'), algorithm),
     297            (_('salt'), mask_hash(salt, show=2)),
     298            (_('hash'), mask_hash(hash)),
    298299        ])
    299300
    300301
    class MD5PasswordHasher(BasePasswordHasher):  
    321322
    322323    def safe_summary(self, encoded):
    323324        return SortedDict([
    324             ('algorithm', self.algorithm),
    325             ('hash', mask_hash(encoded, show=3)),
     325            (_('algorithm'), self.algorithm),
     326            (_('hash'), mask_hash(encoded, show=3)),
    326327        ])
    327328
    328329
    class CryptPasswordHasher(BasePasswordHasher):  
    355356        algorithm, salt, data = encoded.split('$', 2)
    356357        assert algorithm == self.algorithm
    357358        return SortedDict([
    358             ('algorithm', algorithm),
    359             ('salt', salt),
    360             ('hash', mask_hash(data, show=3)),
     359            (_('algorithm'), algorithm),
     360            (_('salt'), salt),
     361            (_('hash'), mask_hash(data, show=3)),
    361362        ])
    362363
Back to Top