Edgewall Software

Changeset 467


Ignore:
Timestamp:
01/10/09 23:42:01 (3 years ago)
Author:
palgarvio
Message:

Fuzzy matching regarding plurals should *NOT* be checked against len(message.id) because this is always 2, instead, it's should be checked against catalog.num_plurals.

Location:
trunk/babel/messages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/babel/messages/catalog.py

    r464 r467  
    711711                        [message.string] + ([u''] * (len(message.id) - 1)) 
    712712                    ) 
    713                 elif len(message.string) != len(message.id): 
     713                elif len(message.string) != self.num_plurals: 
    714714                    fuzzy = True 
    715715                    message.string = tuple(message.string[:len(oldmsg.string)]) 
  • trunk/babel/messages/tests/catalog.py

    r464 r467  
    215215        cat.update(tmpl, no_fuzzy_matching=True) 
    216216        self.assertEqual(2, len(cat.obsolete)) 
     217 
     218    def test_fuzzy_matching_regarding_plurals(self): 
     219        cat = catalog.Catalog() 
     220        cat.add(('foo', 'foh'), ('foo', 'foh')) 
     221        ru = copy.copy(cat) 
     222        ru.locale = 'ru_RU' 
     223        ru.update(cat) 
     224        self.assertEqual(True, ru['foo'].fuzzy) 
     225        ru = copy.copy(cat) 
     226        ru.locale = 'ru_RU' 
     227        ru['foo'].string = ('foh', 'fohh', 'fohhh') 
     228        ru.update(cat) 
     229        self.assertEqual(False, ru['foo'].fuzzy) 
    217230 
    218231    def test_update_no_template_mutation(self): 
Note: See TracChangeset for help on using the changeset viewer.