MOBILE-2991 settings: Sort languages by name
parent
6557793227
commit
5ed9ac0e3e
|
@ -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">
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue