Django

Code

Changeset 7356

Show
Ignore:
Timestamp:
03/24/08 08:27:19 (7 months ago)
Author:
mtredinnick
Message:

Fixed #6864 -- Handle Javascript i18n when the plural form expression returns
True or False (so both booleans and integers are allowed). Thanks, Ramiro Morales.

Files:

Legend:

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

    r7185 r7356  
    8383""" 
    8484 
     85PluralIdx = r""" 
     86function pluralidx(n) { 
     87  var v=%s; 
     88  if (typeof(v) == 'boolean') { 
     89    return v ? 1 : 0; 
     90  } else { 
     91    return v; 
     92  } 
     93} 
     94""" 
     95 
    8596def null_javascript_catalog(request, domain=None, packages=None): 
    8697    """ 
     
    155166        # Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2; 
    156167        plural = [el.strip() for el in plural.split(';') if el.strip().startswith('plural=')][0].split('=',1)[1] 
    157         src.append('function pluralidx(n) {\n    return %s;\n}\n' % plural) 
     168        src.append(PluralIdx % plural) 
    158169    else: 
    159170        src.append(SimplePlural)