MOBILE-2991 settings: Sort languages by name
parent
6557793227
commit
5ed9ac0e3e
|
@ -7,7 +7,7 @@
|
||||||
<ion-item text-wrap>
|
<ion-item text-wrap>
|
||||||
<ion-label><h2>{{ 'core.settings.language' | translate }}</h2></ion-label>
|
<ion-label><h2>{{ 'core.settings.language' | translate }}</h2></ion-label>
|
||||||
<ion-select [(ngModel)]="selectedLanguage" (ngModelChange)="languageChanged()" interface="action-sheet">
|
<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-select>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
<ion-item text-wrap *ngIf="rteSupported">
|
<ion-item text-wrap *ngIf="rteSupported">
|
||||||
|
|
|
@ -34,8 +34,7 @@ import { CoreConfigConstants } from '../../../../configconstants';
|
||||||
})
|
})
|
||||||
export class CoreSettingsGeneralPage {
|
export class CoreSettingsGeneralPage {
|
||||||
|
|
||||||
languages = {};
|
languages = [];
|
||||||
languageCodes = [];
|
|
||||||
selectedLanguage: string;
|
selectedLanguage: string;
|
||||||
rteSupported: boolean;
|
rteSupported: boolean;
|
||||||
richTextEditor: boolean;
|
richTextEditor: boolean;
|
||||||
|
@ -46,8 +45,20 @@ export class CoreSettingsGeneralPage {
|
||||||
private domUtils: CoreDomUtilsProvider,
|
private domUtils: CoreDomUtilsProvider,
|
||||||
localNotificationsProvider: CoreLocalNotificationsProvider) {
|
localNotificationsProvider: CoreLocalNotificationsProvider) {
|
||||||
|
|
||||||
this.languages = CoreConfigConstants.languages;
|
// Get the supported languages.
|
||||||
this.languageCodes = Object.keys(this.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) => {
|
langProvider.getCurrentLanguage().then((currentLanguage) => {
|
||||||
this.selectedLanguage = currentLanguage;
|
this.selectedLanguage = currentLanguage;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue