(function($){

  'use strict';

  function initializeChosen(){

    'use strict';

    let chosen_elements = [];

    for(let i=1;i<=100;i++){

      if( $('#language' + i).length && $('#locale' + i).length ){

        chosen_elements.push('#language' + i);
        chosen_elements.push('#script' + i);
        chosen_elements.push('#locale' + i);

      }

    }

    $(chosen_elements.join(',')).chosen();

  }

  $(document).ready(function(){

    'use strict';

    initializeChosen();

  });

})(jQuery);