aboutsummaryrefslogtreecommitdiffstats
path: root/webapp/src/app/@theme/pipes/plural.pipe.ts
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/src/app/@theme/pipes/plural.pipe.ts')
-rw-r--r--webapp/src/app/@theme/pipes/plural.pipe.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/webapp/src/app/@theme/pipes/plural.pipe.ts b/webapp/src/app/@theme/pipes/plural.pipe.ts
new file mode 100644
index 0000000..4c34096
--- /dev/null
+++ b/webapp/src/app/@theme/pipes/plural.pipe.ts
@@ -0,0 +1,14 @@
+import { Pipe, PipeTransform } from '@angular/core';
+
+@Pipe({ name: 'ngxPlural' })
+export class PluralPipe implements PipeTransform {
+
+ transform(input: number, label: string, pluralLabel: string = ''): string {
+ input = input || 0;
+ return input === 1
+ ? `${input} ${label}`
+ : pluralLabel
+ ? `${input} ${pluralLabel}`
+ : `${input} ${label}s`;
+ }
+}