diff --git a/src/core/login/pages/email-signup/email-signup.html b/src/core/login/pages/email-signup/email-signup.html index e00adbfca..30aa9cd58 100644 --- a/src/core/login/pages/email-signup/email-signup.html +++ b/src/core/login/pages/email-signup/email-signup.html @@ -31,7 +31,7 @@ {{ 'core.wheredoyoulive' | translate }} {{ 'core.login.selectacountry' | translate }} - {{countries[key]}} + {{country.name}} @@ -103,7 +103,7 @@ {{ 'core.user.country' | translate }} {{ 'core.login.selectacountry' | translate }} - {{countries[key]}} + {{country.name}} diff --git a/src/core/login/pages/email-signup/email-signup.ts b/src/core/login/pages/email-signup/email-signup.ts index 25ecd0e2e..cf25a4ab1 100644 --- a/src/core/login/pages/email-signup/email-signup.ts +++ b/src/core/login/pages/email-signup/email-signup.ts @@ -43,7 +43,6 @@ export class CoreLoginEmailSignupPage { authInstructions: string; settings: any; countries: any; - countriesKeys: any[]; categories: any[]; settingsLoaded = false; captcha = { @@ -177,9 +176,8 @@ export class CoreLoginEmailSignupPage { }); } - return this.utils.getCountryList().then((countries) => { + return this.utils.getCountryListSorted().then((countries) => { this.countries = countries; - this.countriesKeys = Object.keys(countries); }); }); } diff --git a/src/providers/utils/utils.ts b/src/providers/utils/utils.ts index 5b9d3b70f..736cf84cd 100644 --- a/src/providers/utils/utils.ts +++ b/src/providers/utils/utils.ts @@ -623,6 +623,25 @@ export class CoreUtilsProvider { }); } + /** + * Get list of countries with their code and translated name. Sorted by the name of the country. + * + * @return Promise resolved with the list of countries. + */ + getCountryListSorted(): Promise { + // Get the keys of the countries. + return this.getCountryList().then((countries) => { + // Sort translations. + const sortedCountries = []; + + Object.keys(countries).sort((a, b) => countries[a].localeCompare(countries[b])).forEach((key) => { + sortedCountries.push({code: key, name: countries[key]}); + }); + + return sortedCountries; + }); + } + /** * Get the list of language keys of the countries. *