mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
refactor: update to recent changes in translator
This commit is contained in:
@@ -21,6 +21,7 @@ import {IonicModule} from '@ionic/angular';
|
||||
import {TranslateModule} from '@ngx-translate/core';
|
||||
import {MarkdownModule} from 'ngx-markdown';
|
||||
import {MomentModule} from 'ngx-moment';
|
||||
import {ThingTranslateModule} from '../../translation/thing-translate.module';
|
||||
import {MenuModule} from '../menu/menu.module';
|
||||
import {StorageModule} from '../storage/storage.module';
|
||||
import {DataFacetsProvider} from './data-facets.provider';
|
||||
@@ -132,6 +133,7 @@ import {VideoListItem} from './types/video/video-list-item.component';
|
||||
}),
|
||||
StorageModule,
|
||||
TranslateModule.forChild(),
|
||||
ThingTranslateModule.forChild(),
|
||||
],
|
||||
providers: [
|
||||
DataProvider,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories()">
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories">
|
||||
</stapps-simple-card>
|
||||
<stapps-simple-card *ngIf="item.datePublished" [title]="'Published'"
|
||||
[content]="item.datePublished | amDateFormat:'ll'"></stapps-simple-card>
|
||||
<stapps-simple-card [title]="'Content'" [content]="translator.translate(item).articleBody()" [isMarkdown]="true">
|
||||
<stapps-simple-card [title]="'Content'" [content]="translator.translate(item).articleBody" [isMarkdown]="true">
|
||||
</stapps-simple-card>
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories()">
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories">
|
||||
</stapps-simple-card>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories()">
|
||||
<stapps-simple-card [title]="'Categories'" [content]="translator.translate(item).categories">
|
||||
</stapps-simple-card>
|
||||
<ion-card *ngIf="item.characteristics">
|
||||
<ion-card-header>Characteristics</ion-card-header>
|
||||
<ion-card-content *ngFor="let characteristic of translator.translate(item).characteristics()">
|
||||
<ion-card-content *ngFor="let characteristic of translator.translate(item).characteristics">
|
||||
<p>
|
||||
<img *ngIf="characteristic.image"
|
||||
[src]="characteristic.image" /><span> {{characteristic.name}}</span>
|
||||
@@ -10,7 +10,7 @@
|
||||
</ion-card-content>
|
||||
</ion-card>
|
||||
<stapps-offers-detail *ngIf="item.offers" [offers]="item.offers"></stapps-offers-detail>
|
||||
<stapps-simple-card *ngIf="item.additives" [title]="'Additives'" [content]="translator.translate(item).additives().join(', ')">
|
||||
<stapps-simple-card *ngIf="item.additives" [title]="'Additives'" [content]="translator.translate(item).additives.join(', ')">
|
||||
</stapps-simple-card>
|
||||
<ion-card *ngIf="item.nutrition">
|
||||
<ion-card-header>Average Nutrition Information</ion-card-header>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<ng-container *ngIf="item.type === 'academic event'">
|
||||
<stapps-simple-card *ngIf="item.categories" [title]="'Categories'" [content]="translator.translate(item).categories()">
|
||||
<stapps-simple-card *ngIf="item.categories" [title]="'Categories'" [content]="translator.translate(item).categories">
|
||||
</stapps-simple-card>
|
||||
<stapps-simple-card *ngIf="item.catalogs" [title]="'Catalogs'" [content]="item.catalogs"></stapps-simple-card>
|
||||
<stapps-simple-card *ngIf="item.performers" [title]="'Performers'" [content]="item.performers"></stapps-simple-card>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<stapps-place-mensa-detail-content [item]="item" [language]="language" *ngIf="isMensaThing(item)"></stapps-place-mensa-detail-content>
|
||||
<ng-container *ngIf="item.type !== 'floor'">
|
||||
<stapps-simple-card *ngIf="item.type !== 'floor' && item.categories" [title]="'Categories'" [content]="translator.translate(item).categories()"></stapps-simple-card>
|
||||
<stapps-simple-card *ngIf="item.type !== 'floor' && item.categories" [title]="'Categories'" [content]="translator.translate(item).categories"></stapps-simple-card>
|
||||
<stapps-address-detail *ngIf="item.type !== 'floor' && item.address" [address]="item.address"></stapps-address-detail>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="item.type !== 'building'">
|
||||
|
||||
@@ -116,14 +116,14 @@ export class ContextMenuComponent {
|
||||
getTranslatedPropertyName(property: string, onlyForType?: SCThingType): string {
|
||||
return (this.translator
|
||||
// tslint:disable-next-line:no-any
|
||||
.translatedPropertyNames(onlyForType ? onlyForType : SCThingType.AcademicEvent) as any)[property];
|
||||
.translatedPropertyNames(typeof onlyForType !== 'undefined' ? onlyForType : SCThingType.AcademicEvent) as any)[property];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns translated type of given SCThingType string
|
||||
* Returns translated property value
|
||||
*/
|
||||
getTranslatedType(scThingType: string) {
|
||||
return this.translator.translatedThingType(scThingType as SCThingType);
|
||||
getTranslatedPropertyValue(onlyForType: SCThingType, field: string, key?: string): string | undefined {
|
||||
return this.translator.translatedPropertyValue(onlyForType, field, key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,34 +38,34 @@
|
||||
<ion-list class="filter-group"
|
||||
*ngFor="let facet of !filterOption.compact ?
|
||||
filterOption.options.slice(0, compactFilterOptionCount) : filterOption.options">
|
||||
<ion-list-header class="h3">
|
||||
<ion-label>
|
||||
{{(facet.onlyOnType ?
|
||||
getTranslatedPropertyName(facet.field, facet.onlyOnType)
|
||||
: (getTranslatedPropertyName(facet.field))) | titlecase}}
|
||||
{{facet.onlyOnType? ' | ' + (getTranslatedType(facet.onlyOnType) | titlecase) : ''}}
|
||||
</ion-label>
|
||||
</ion-list-header>
|
||||
<div *ngIf="facet.buckets.length > 0">
|
||||
<ion-item
|
||||
*ngFor="let bucket of !facet.compact ?
|
||||
facet.buckets.slice(0, compactFilterOptionCount) : facet.buckets">
|
||||
<ion-label class="filter-item-label">
|
||||
({{bucket.count}}) {{facet.field === 'type' ? (getTranslatedType(bucket.key) | titlecase) : bucket.key | titlecase}}
|
||||
<div *ngIf="!facet.field.includes('.')">
|
||||
<ion-list-header class="h3">
|
||||
<ion-label>
|
||||
{{(facet.onlyOnType ? getTranslatedPropertyName(facet.field, facet.onlyOnType) : (getTranslatedPropertyName(facet.field))) | titlecase}}
|
||||
{{facet.onlyOnType ? ' | ' + (getTranslatedPropertyValue(facet.onlyOnType, 'type') | titlecase) : ''}}
|
||||
</ion-label>
|
||||
<ion-checkbox
|
||||
mode="ios"
|
||||
[(ngModel)]="bucket.checked"
|
||||
(ngModelChange)="filterChanged()"
|
||||
[value]="{field: facet.field, value: bucket.key, onlyOnType: facet.onlyOnType}">
|
||||
|
||||
</ion-checkbox>
|
||||
</ion-item>
|
||||
<ion-button fill="clear"
|
||||
*ngIf="!facet.compact && facet.buckets.length > compactFilterOptionCount"
|
||||
(click)="facet.compact = true">
|
||||
{{'menu.context.filter.showAll' | translate}}
|
||||
</ion-button>
|
||||
</ion-list-header>
|
||||
<div *ngIf="facet.buckets.length > 0">
|
||||
<ion-item
|
||||
*ngFor="let bucket of !facet.compact ?
|
||||
facet.buckets.slice(0, compactFilterOptionCount) : facet.buckets">
|
||||
<ion-label class="filter-item-label">
|
||||
({{bucket.count}}) {{facet.field === 'type' ? (getTranslatedPropertyValue(bucket.key, 'type') | titlecase) :
|
||||
getTranslatedPropertyValue(facet.onlyOnType, facet.field, bucket.key) | titlecase}}
|
||||
</ion-label>
|
||||
<ion-checkbox
|
||||
mode="ios"
|
||||
[(ngModel)]="bucket.checked"
|
||||
(ngModelChange)="filterChanged()"
|
||||
[value]="{field: facet.field, value: bucket.key, onlyOnType: facet.onlyOnType}">
|
||||
</ion-checkbox>
|
||||
</ion-item>
|
||||
<ion-button fill="clear"
|
||||
*ngIf="!facet.compact && facet.buckets.length > compactFilterOptionCount"
|
||||
(click)="facet.compact = true">
|
||||
{{'menu.context.filter.showAll' | translate}}
|
||||
</ion-button>
|
||||
</div>
|
||||
</div>
|
||||
</ion-list>
|
||||
<ion-button fill="clear"
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<ion-card *ngIf="setting">
|
||||
<ion-card-header>
|
||||
<span>
|
||||
{{ translatedSetting.name() | titlecase }}
|
||||
<ion-icon *ngIf="compactView" name="information-circle-outline" (click)="presentAlert(translator.translate(setting).name(), translator.translate(setting).description())"></ion-icon>
|
||||
{{ translatedSetting.name | titlecase }}
|
||||
<ion-icon *ngIf="compactView" name="information-circle-outline" (click)="presentAlert(translator.translate(setting).name, translator.translate(setting).description)"></ion-icon>
|
||||
</span>
|
||||
</ion-card-header>
|
||||
<ion-card-content>
|
||||
<ion-note *ngIf="!compactView">{{ translatedSetting.description() }}</ion-note>
|
||||
<ion-note *ngIf="!compactView">{{ translatedSetting.description }}</ion-note>
|
||||
|
||||
<div [ngSwitch]="setting.inputType" *ngIf="isVisible" >
|
||||
<ion-item *ngSwitchCase="'number'">
|
||||
@@ -31,7 +31,7 @@
|
||||
<!-- else show select input -->
|
||||
<ion-select *ngIf="typeOf(setting.defaultValue) !== 'boolean'" interface="popover" [(ngModel)]="setting.value" (ionChange)="settingChanged()">
|
||||
<ion-select-option *ngFor="let val of setting.values, index as i" [value]="val">
|
||||
<div *ngIf="typeOf(val) !== 'number'">{{ translatedSetting.values()[i] | titlecase }}</div>
|
||||
<div *ngIf="typeOf(val) !== 'number'">{{ translatedSetting.values[i] | titlecase }}</div>
|
||||
<div *ngIf="typeOf(val) === 'number'">{{ val }}</div>
|
||||
</ion-select-option>
|
||||
</ion-select>
|
||||
@@ -41,7 +41,7 @@
|
||||
<ion-label></ion-label>
|
||||
<ion-select [(ngModel)]="setting.value" multiple="true" (ionChange)="settingChanged()">
|
||||
<ion-select-option *ngFor="let val of setting.values, index as i" [value]="val">
|
||||
<div *ngIf="typeOf(val) !== 'number'">{{ translatedSetting.values()[i] }}</div>
|
||||
<div *ngIf="typeOf(val) !== 'number'">{{ translatedSetting.values[i] }}</div>
|
||||
<div *ngIf="typeOf(val) === 'number'">{{ val }}</div>
|
||||
</ion-select-option>
|
||||
</ion-select>
|
||||
|
||||
@@ -84,7 +84,8 @@ export class SettingsPageComponent {
|
||||
duration: 2000,
|
||||
message: this.translateService.instant('settings.resetToast.message'),
|
||||
});
|
||||
toast.present();
|
||||
|
||||
return toast.present();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,6 +166,7 @@ export class SettingsPageComponent {
|
||||
header: this.translateService.instant('settings.resetAlert.title'),
|
||||
message: this.translateService.instant('settings.resetAlert.message'),
|
||||
});
|
||||
|
||||
alert.present();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<ion-list *ngFor="let categoryKey of categoriesOrder ">
|
||||
<div *ngIf="objectKeys(settingsCache).includes(categoryKey)">
|
||||
<ion-item-divider>
|
||||
<h5>{{ translator.translate(settingsCache[categoryKey]?.settings[objectKeys(settingsCache[categoryKey]?.settings)[0]]).categories()[0] | titlecase}}</h5>
|
||||
<h5>{{ translator.translate(settingsCache[categoryKey]?.settings[objectKeys(settingsCache[categoryKey]?.settings)[0]]).categories[0] | titlecase}}</h5>
|
||||
</ion-item-divider>
|
||||
<stapps-settings-item *ngFor="let settingKeys of objectKeys(settingsCache[categoryKey].settings)" [setting]="settingsCache[categoryKey].settings[settingKeys]"></stapps-settings-item>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user