mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
760 B
30 lines
760 B
/*
|
|
* Squidex Headless CMS
|
|
*
|
|
* @license
|
|
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
|
|
*/
|
|
|
|
import { Pipe, PipeTransform } from '@angular/core';
|
|
import { LocalizerService, Types } from '@app/framework/internal';
|
|
|
|
@Pipe({
|
|
name: 'sqxTranslate',
|
|
pure: true
|
|
})
|
|
export class TranslatePipe implements PipeTransform {
|
|
constructor(
|
|
private readonly localizer: LocalizerService
|
|
) {
|
|
}
|
|
|
|
public transform(value: any, args?: any): string {
|
|
if (Types.isString(value)) {
|
|
return this.localizer.getOrKey(value, args);
|
|
} else if (value && Types.isFunction(value['translate'])) {
|
|
return value['translate'](this.localizer);
|
|
} else {
|
|
return '';
|
|
}
|
|
}
|
|
}
|