Changeset 726
- Timestamp:
- 09/29/05 12:01:05 (3 years ago)
- Files:
-
- django/branches/i18n/django/bin/compile-messages.py (added)
- django/branches/i18n/django/bin/make-messages.py (added)
- django/branches/i18n/django/conf/admin_templates/index.html (modified) (3 diffs)
- django/branches/i18n/django/conf/locale (added)
- django/branches/i18n/django/conf/locale/de (added)
- django/branches/i18n/django/conf/locale/de/LC_MESSAGES (added)
- django/branches/i18n/django/conf/locale/de/LC_MESSAGES/django.mo (added)
- django/branches/i18n/django/conf/locale/de/LC_MESSAGES/django.po (added)
- django/branches/i18n/django/conf/settings.py (modified) (1 diff)
- django/branches/i18n/django/core/defaulttags.py (modified) (4 diffs)
- django/branches/i18n/django/core/validators.py (modified) (1 diff)
- django/branches/i18n/django/middleware/locale.py (added)
- django/branches/i18n/django/utils/translation.py (added)
- django/branches/i18n/setup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/conf/admin_templates/index.html
r684 r726 24 24 25 25 {% if model.perms.add %} 26 <td class="x50"><a href="{{ model.admin_url }}add/" class="addlink"> Add</a></td>26 <td class="x50"><a href="{{ model.admin_url }}add/" class="addlink">{% i18n _('Add') %}</a></td> 27 27 {% else %} 28 28 <td class="x50"> </td> … … 30 30 31 31 {% if model.perms.change %} 32 <td class="x75"><a href="{{ model.admin_url }}" class="changelink"> Change</a></td>32 <td class="x75"><a href="{{ model.admin_url }}" class="changelink">{% i18n _('Change') %}</a></td> 33 33 {% else %} 34 34 <td class="x75"> </td> … … 48 48 <div id="content-related"> 49 49 <div class="module" id="recent-actions-module"> 50 <h2> Recent Actions</h2>51 <h3> My Actions</h3>50 <h2>{% i18n _('Recent Actions') %}</h2> 51 <h3>{% i18n _('My Actions') %}</h3> 52 52 {% load auth.log %} 53 53 {% get_admin_log 10 as admin_log for_user user %} 54 54 {% if not admin_log %} 55 <p> None available</p>55 <p>{% i18n _('None available') %}</p> 56 56 {% else %} 57 57 <ul class="actionlist"> django/branches/i18n/django/conf/settings.py
r239 r726 56 56 delattr(me, k) 57 57 del me, k 58 59 # as the last step, install the translation machinery and 60 # remove the module again to not clutter the namespace. 61 from django.utils import translation 62 translation.install() 63 del translation 64 django/branches/i18n/django/core/defaulttags.py
r574 r726 1 1 "Default tags used by the template system, available to all templates." 2 2 3 import re 3 4 import sys 4 5 import template 6 7 from django.utils import translation 5 8 6 9 class CommentNode(template.Node): … … 284 287 return str(int(round(ratio))) 285 288 289 class I18NNode(template.Node): 290 291 def __init__(self, cmd): 292 self.cmd = cmd 293 self.i18n_re = re.compile(r'^\s*_\((.*)\)\s*$') 294 295 def render(self, context): 296 m = self.i18n_re.match(self.cmd) 297 if m: 298 s = m.group(1) 299 if s.startswith("'") and s.endswith("'"): 300 s = s[1:-1] 301 elif s.startswith('"""') and s.endswith('"""'): 302 s = s[3:-3] 303 elif s.startswith('"') and s.endswith('"'): 304 s = s[1:-1] 305 else: 306 raise template.TemplateSyntaxError("i18n must be called as {% i18n _('some message') %}") 307 return translation.gettext(s) % context 308 else: 309 raise template.TemplateSyntaxError("i18n must be called as {% i18n _('some message') %}") 310 286 311 def do_comment(parser, token): 287 312 """ … … 746 771 return WidthRatioNode(this_value_var, max_value_var, max_width) 747 772 773 def do_i18n(parser, token): 774 """ 775 translate a given string with the current 776 translation object. 777 778 For example:: 779 780 {% i18n _('test') %} 781 782 """ 783 args = token.contents.split(' ', 1) 784 if len(args) != 2: 785 raise template.TemplateSyntaxError("'i18n' requires one argument (got %r)" % args) 786 787 return I18NNode(args[1].strip()) 788 748 789 template.register_tag('comment', do_comment) 749 790 template.register_tag('cycle', do_cycle) … … 762 803 template.register_tag('templatetag', do_templatetag) 763 804 template.register_tag('widthratio', do_widthratio) 805 template.register_tag('i18n', do_i18n) 806 django/branches/i18n/django/core/validators.py
r712 r726 54 54 def isAlphaNumeric(field_data, all_data): 55 55 if not alnum_re.search(field_data): 56 raise ValidationError, "This value must contain only letters, numbers and underscores."56 raise ValidationError, _("This value must contain only letters, numbers and underscores.") 57 57 58 58 def isAlphaNumericURL(field_data, all_data): django/branches/i18n/setup.py
r662 r726 18 18 'admin_media/css/*.css', 'admin_media/img/admin/*.gif', 19 19 'admin_media/img/admin/*.png', 'admin_media/js/*.js', 20 'admin_media/js/admin/*js' ],20 'admin_media/js/admin/*js', 'locale/*/*/*.mo'], 21 21 }, 22 22 scripts = ['django/bin/django-admin.py'],
