first commit

This commit is contained in:
2025-09-14 23:05:30 -04:00
commit 2866d74b32
122 changed files with 95474 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { Pipe, PipeTransform } from '@angular/core';
import { I18nService } from '../services/i18n.service';
@Pipe({
name: 't',
standalone: true,
pure: false,
})
export class TranslatePipe implements PipeTransform {
constructor(private i18n: I18nService) {}
transform(key: string, paramsOrFallback?: any): string {
// If a string is passed as the second arg, treat it as a fallback text.
// Otherwise, assume it's a params object for interpolation.
const params = (paramsOrFallback && typeof paramsOrFallback === 'object') ? paramsOrFallback : undefined;
const fallback = (typeof paramsOrFallback === 'string') ? paramsOrFallback : undefined;
const val = this.i18n.t(key, params);
// When i18n returns the key unchanged, use the provided fallback if any
if (fallback && val === key) return fallback;
return val;
}
}