Merge pull request #1986 from dpalou/MOBILE-2991

MOBILE-2991 settings: Sort languages by name
main
Juan Leyva 2019-07-18 11:40:18 +02:00 committed by GitHub
commit c19542c055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -7,7 +7,7 @@
<ion-item text-wrap>
<ion-label><h2>{{ 'core.settings.language' | translate }}</h2></ion-label>
<ion-select [(ngModel)]="selectedLanguage" (ngModelChange)="languageChanged()" interface="action-sheet">
<ion-option *ngFor="let code of languageCodes" [value]="code">{{ languages[code] }}</ion-option>
<ion-option *ngFor="let entry of languages" [value]="entry.code">{{ entry.name }}</ion-option>
</ion-select>
</ion-item>
<ion-item text-wrap *ngIf="rteSupported">

View File

@ -34,8 +34,7 @@ import { CoreConfigConstants } from '../../../../configconstants';
})
export class CoreSettingsGeneralPage {
languages = {};
languageCodes = [];
languages = [];
selectedLanguage: string;
rteSupported: boolean;
richTextEditor: boolean;
@ -46,8 +45,20 @@ export class CoreSettingsGeneralPage {
private domUtils: CoreDomUtilsProvider,
localNotificationsProvider: CoreLocalNotificationsProvider) {
this.languages = CoreConfigConstants.languages;
this.languageCodes = Object.keys(this.languages);
// Get the supported languages.
const languages = CoreConfigConstants.languages;
for (const code in languages) {
this.languages.push({
code: code,
name: languages[code]
});
}
// Sort them by name.
this.languages.sort((a, b) => {
return a.name.localeCompare(b.name);
});
langProvider.getCurrentLanguage().then((currentLanguage) => {
this.selectedLanguage = currentLanguage;
});