feat: add about module

This commit is contained in:
Jovan Krunić
2021-10-27 08:25:41 +00:00
committed by Rainer Killinger
parent 7d449b43d0
commit d420008926
32 changed files with 999 additions and 65 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 StApps
* Copyright (C) 2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -31,6 +31,7 @@ import {
import {
ThingPropertyNameTranslatePipe,
ThingTranslatePipe,
TranslateSimplePipe,
} from './thing-translate.pipe';
import {ThingTranslateService} from './thing-translate.service';
@@ -47,6 +48,7 @@ export interface ThingTranslateModuleConfig {
StringSplitPipe,
ThingPropertyNameTranslatePipe,
ThingTranslatePipe,
TranslateSimplePipe,
DateLocalizedFormatPipe,
OpeningHoursPipe,
SentenceCasePipe,
@@ -59,6 +61,7 @@ export interface ThingTranslateModuleConfig {
StringSplitPipe,
ThingPropertyNameTranslatePipe,
ThingTranslatePipe,
TranslateSimplePipe,
DateLocalizedFormatPipe,
OpeningHoursPipe,
SentenceCasePipe,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 StApps
* Copyright (C) 2021 StApps
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version 3.
@@ -18,6 +18,7 @@ import {TranslateService} from '@ngx-translate/core';
import {isThing, SCThings, SCThingType} from '@openstapps/core';
import {Subscription} from 'rxjs';
import {ThingTranslateService} from './thing-translate.service';
import {get} from 'lodash-es';
@Injectable()
@Pipe({
@@ -92,6 +93,32 @@ export class ThingTranslatePipe implements PipeTransform, OnDestroy {
}
}
@Injectable()
@Pipe({
name: 'translateSimple',
pure: true,
})
export class TranslateSimplePipe implements PipeTransform {
constructor(private readonly translate: TranslateService) {}
// eslint-disable-next-line @typescript-eslint/ban-types
transform(query: string, value: object | unknown): unknown {
try {
return (
get(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(value as any).translations[this.translate.currentLang] ?? value,
query,
) ?? value
);
} catch (error) {
console.warn(`${query}: ${error}`);
return value;
}
}
}
@Injectable()
@Pipe({
name: 'propertyNameTranslate',