Skip to content

Commit

Permalink
Finished tr8n functions. Fixes #705
Browse files Browse the repository at this point in the history
  • Loading branch information
t0xicCode committed Aug 24, 2014
1 parent 6d825e5 commit 4913226
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 14 deletions.
9 changes: 6 additions & 3 deletions dist/js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
Selectpicker.DEFAULTS = {
noneSelectedText: 'Nothing selected',
noneResultsText: 'No results match',
countSelectedText: '{0} of {1} selected',
countSelectedText: function (numSelected, numTotal) {
return (numSelected == 1) ? "{0} item selected" : "{0} items selected";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down Expand Up @@ -374,8 +376,9 @@
var max = this.options.selectedTextFormat.split('>');
var notDisabled = this.options.hideDisabled ? ', [disabled]' : '';
if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) {
title = this.options.countSelectedText.replace('{0}', selectedItems.length.toString())
.replace('{1}', this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length.toString());
var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length,
tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText;
title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/js/bootstrap-select.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/bootstrap-select.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/js/i18n/defaults-en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
$.fn.selectpicker.defaults = {
noneSelectedText: 'Nothing selected',
noneResultsText: 'No results match',
countSelectedText: '{0} of {1} selected',
countSelectedText: function (numSelected, numTotal) {
return (numSelected == 1) ? "{0} item selected" : "{0} items selected";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down
2 changes: 1 addition & 1 deletion dist/js/i18n/defaults-en_US.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* Copyright 2013-2014 bootstrap-select
* Licensed under MIT (https://github.com/silviomoreto/bootstrap-select/blob/master/LICENSE)
*/
!function(a){a.fn.selectpicker.defaults={noneSelectedText:"Nothing selected",noneResultsText:"No results match",countSelectedText:"{0} of {1} selected",maxOptionsText:function(a,b){var c=[];return c[0]=1==a?"Limit reached ({n} item max)":"Limit reached ({n} items max)",c[1]=1==b?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)",c},selectAllText:"Select All",deselectAllText:"Deselect All",multipleSeparator:", "}}(jQuery);
!function(a){a.fn.selectpicker.defaults={noneSelectedText:"Nothing selected",noneResultsText:"No results match",countSelectedText:function(a){return 1==a?"{0} item selected":"{0} items selected"},maxOptionsText:function(a,b){var c=[];return c[0]=1==a?"Limit reached ({n} item max)":"Limit reached ({n} items max)",c[1]=1==b?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)",c},selectAllText:"Select All",deselectAllText:"Deselect All",multipleSeparator:", "}}(jQuery);
4 changes: 3 additions & 1 deletion dist/js/i18n/defaults-fr_FR.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
$.fn.selectpicker.defaults = {
noneSelectedText: 'Aucune sélection',
noneResultsText: 'Aucun résultat',
countSelectedText: '{0} sur {1} sélection(s)',
countSelectedText: function (numSelected, numTotal) {
return (numSelected > 1) ? "{0} éléments sélectionés" : "{0} élément sélectioné";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down
2 changes: 1 addition & 1 deletion dist/js/i18n/defaults-fr_FR.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions js/bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
Selectpicker.DEFAULTS = {
noneSelectedText: 'Nothing selected',
noneResultsText: 'No results match',
countSelectedText: '{0} of {1} selected',
countSelectedText: function (numSelected, numTotal) {
return (numSelected == 1) ? "{0} item selected" : "{0} items selected";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down Expand Up @@ -368,8 +370,9 @@
var max = this.options.selectedTextFormat.split('>');
var notDisabled = this.options.hideDisabled ? ', [disabled]' : '';
if ((max.length > 1 && selectedItems.length > max[1]) || (max.length == 1 && selectedItems.length >= 2)) {
title = this.options.countSelectedText.replace('{0}', selectedItems.length.toString())
.replace('{1}', this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length.toString());
var totalCount = this.$element.find('option').not('[data-divider="true"], [data-hidden="true"]' + notDisabled).length,
tr8nText = (typeof this.options.countSelectedText === 'function') ? this.options.countSelectedText(selectedItems.length, totalCount) : this.options.countSelectedText;
title = tr8nText.replace('{0}', selectedItems.length.toString()).replace('{1}', totalCount.toString());
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/i18n/defaults-en_US.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
$.fn.selectpicker.defaults = {
noneSelectedText: 'Nothing selected',
noneResultsText: 'No results match',
countSelectedText: '{0} of {1} selected',
countSelectedText: function (numSelected, numTotal) {
return (numSelected == 1) ? "{0} item selected" : "{0} items selected";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down
4 changes: 3 additions & 1 deletion js/i18n/defaults-fr_FR.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
$.fn.selectpicker.defaults = {
noneSelectedText: 'Aucune sélection',
noneResultsText: 'Aucun résultat',
countSelectedText: '{0} sur {1} sélection(s)',
countSelectedText: function (numSelected, numTotal) {
return (numSelected > 1) ? "{0} éléments sélectionés" : "{0} élément sélectioné";
},
maxOptionsText: function (numAll, numGroup) {
var arr = [];

Expand Down

0 comments on commit 4913226

Please sign in to comment.