Skip to content

Commit

Permalink
Sort after localize
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Jun 24, 2018
1 parent 86ead8e commit 9e39ba9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Type: `Object` Default: `{}`
Allows to translate the countries by its given iso code e.g.:

```js
{'de':'Deutschland'}
{ 'de': 'Deutschland' }
```


Expand Down
13 changes: 8 additions & 5 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
hiddenInput: "",
// initial country
initialCountry: "",
// localized country names e.g. { 'de': 'Deutschland' }
localizedCountries: null,
// don't insert international dial codes
nationalMode: true,
// display only these countries
Expand All @@ -51,9 +53,7 @@
// display the country dial code next to the selected flag so it's not part of the typed number
separateDialCode: false,
// specify the path to the libphonenumber script to enable validation/formatting
utilsScript: "",
// default locale eg.: {'de':'Deutschland'}
localizedCountries: null
utilsScript: ""
}, keys = {
UP: 38,
DOWN: 40,
Expand Down Expand Up @@ -132,10 +132,14 @@
this._processCountryCodes();
// process the preferredCountries
this._processPreferredCountries();
// translate countries according to locale object literal
// translate countries according to localizedCountries option
if (this.options.localizedCountries) {
this._translateCountriesByLocale();
}
// sort countries by name
if (this.options.onlyCountries.length || this.options.localizedCountries) {
this.countries.sort(this._countryNameSort);
}
},
// add a country code to this.countryCodes
_addCountryCode: function(iso2, dialCode, priority) {
Expand All @@ -154,7 +158,6 @@
this.countries = allCountries.filter(function(country) {
return lowerCaseOnlyCountries.indexOf(country.iso2) > -1;
});
this.countries.sort(this._countryNameSort);
} else if (this.options.excludeCountries.length) {
var lowerCaseExcludeCountries = this.options.excludeCountries.map(function(country) {
return country.toLowerCase();
Expand Down
Loading

0 comments on commit 9e39ba9

Please sign in to comment.