(function($) {
  $(document).ready(function() {
    // add handlers to the delete buttons:
    $('a.kvPairDeleteButton').click(function() {
        var liToRemove = $(this).parent();
        liToRemove.nextAll().find('input,textarea').each(function(){
            $(this).attr('name', $(this).attr('name').replace(
                /(\d+)$/, function(s, n) {return parseInt(n) - 1;}));
          });
        var remainingLis = liToRemove.siblings();
        if (remainingLis.length == 2
            && remainingLis.parent('.pairsRequired').length) {
          remainingLis.first().find('a.kvPairDeleteButton')
            .addClass('kvPairDeleteButtonHidden');
        }
        liToRemove.remove();
      });
    // hide all delete buttons of dictionaries with required key/value pairs
    // that only have one key/value pair:
    $('ul.keyValuePairs.pairsRequired').each(function(){
        var pairs = $(this).children();
        if (pairs.length == 2) {
          pairs.first().find('a.kvPairDeleteButton')
            .addClass('kvPairDeleteButtonHidden');
        }
      });
    // add a handler to the button for adding further key value pairs:
    $('a.kvPairAddButton').click(function() {
        var successor = $(this).parent();
        var list = successor.parent();
        var newEntry = $('<li/>').append(list.next().contents().clone(true));
        newEntry.find('input,textarea').each(function() {
            $(this).attr('name',
              $(this).attr('name') + (list.children().length - 1));
          });
        newEntry.find('input.lang_autocomplete').each(function(){
        	var elem = autocomp_jquery(this);
        	autocomp_my_string(elem);
        });
        successor.before(newEntry);
        list.find('a.kvPairDeleteButton').removeClass('kvPairDeleteButtonHidden');
      });
  });
})(django.jQuery);

@@ -1378,24 +1378,48 @@
 ne(true));%0D%0A
+        var fieldName;%0D%0A
         newE
@@ -1426,32 +1426,48 @@
 ntry.find('input
+:not(.lang_name)
 ,textarea').each
@@ -1497,43 +1497,19 @@
     
-$(this).attr('name',%0D%0A             
+fieldName =
  $(t
@@ -1556,16 +1556,58 @@
 gth - 1)
+;%0D%0A        %09$(this).attr('name', fieldName
 );%0D%0A    
@@ -1769,32 +1769,187 @@
 ;%0D%0A        %7D);%0D%0A
+        newEntry.find('input.lang_name').each(function()%7B%0D%0A        %09var elem = autocomp_jquery(this);%0D%0A        %09elem.attr('for', fieldName);%0D%0A        %7D);%0D%0A
         successo

Fix a bug in dynamically adding a language field.