Django

Code

Changeset 1412

Show
Ignore:
Timestamp:
11/24/05 19:03:58 (3 years ago)
Author:
adrian
Message:

Tiny formatting changes to templatetags/i18n.py

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/templatetags/i18n.py

    r1241 r1412  
    1 "Default tags used by the template system, available to all templates." 
    2  
    31from django.core.template import Node, NodeList, Template, Context, resolve_variable, resolve_variable_with_filters, registered_filters 
    42from django.core.template import TemplateSyntaxError, register_tag, TokenParser 
    53from django.core.template import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR 
    64from django.utils import translation 
    7  
    8 import sys 
    9 import re 
     5import re, sys 
    106 
    117class GetAvailableLanguagesNode(Node): 
    12  
    138    def __init__(self, variable): 
    149        self.variable = variable 
     
    2015 
    2116class GetCurrentLanguageNode(Node): 
    22  
    2317    def __init__(self, variable): 
    2418        self.variable = variable 
     
    2923 
    3024class TranslateNode(Node): 
    31  
    3225    def __init__(self, value, noop): 
    3326        self.value = value 
     
    4235 
    4336class BlockTranslateNode(Node): 
    44  
    4537    def __init__(self, extra_context, singular, plural=None, countervar=None, counter=None): 
    4638        self.extra_context = extra_context 
     
    7971    in the context. 
    8072 
    81     Usage is as follows:: 
     73    Usage:: 
    8274 
    8375        {% get_available_languages as languages %} 
     
    9082    put it into the named variable. 
    9183    """ 
    92  
    9384    args = token.contents.split() 
    9485    if len(args) != 3 or args[1] != 'as': 
     
    9889def do_get_current_language(parser, token): 
    9990    """ 
    100     This will store the current language in 
    101     the context. 
    102  
    103     Usage is as follows:: 
     91    This will store the current language in the context. 
     92 
     93    Usage:: 
    10494 
    10595        {% get_current_language as language %} 
     
    10999    variable. 
    110100    """ 
    111  
    112101    args = token.contents.split() 
    113102    if len(args) != 3 or args[1] != 'as': 
     
    120109    translate the string for the current language. 
    121110 
    122     Usage is like this:: 
     111    Usage:: 
    123112 
    124113        {% trans "this is a test" %} 
     
    145134    in there is something that is in the .po file. 
    146135    """ 
    147  
    148136    class TranslateParser(TokenParser): 
    149  
    150137        def top(self): 
    151138            value = self.value() 
     
    158145                noop = False 
    159146            return (value, noop) 
    160  
    161147    (value, noop) = TranslateParser(token.contents).top() 
    162148    return TranslateNode(value, noop) 
     
    166152    This will translate a block of text with parameters. 
    167153 
    168     Format is like this:: 
     154    Usage:: 
    169155 
    170156        {% blocktrans with foo|filter as bar and baz|filter as boo %} 
     
    172158        {% endblocktrans %} 
    173159 
    174     Additionally this supports pluralization:: 
     160    Additionally, this supports pluralization:: 
    175161 
    176162        {% blocktrans count var|length as count %} 
     
    232218register_tag('trans', do_translate) 
    233219register_tag('blocktrans', do_block_translate) 
    234