Initial commit
This commit is contained in:
32
src/app/translate-pipe.ts
Normal file
32
src/app/translate-pipe.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
|
||||
@Pipe({ name: 'translate' })
|
||||
export class TranslatePipe implements PipeTransform {
|
||||
private readonly translations: Map<string, string> = new Map([
|
||||
// wspólne
|
||||
["tooLong", "Numer jest zbyt długi."],
|
||||
["tooShort", "Numer jest zbyt krótki."],
|
||||
["invalidPattern", "Wprowadzono znak niebędący cyfrą."],
|
||||
["invalidControlDigit", "Cyfra kontrolna jest niepoprawna."],
|
||||
|
||||
// PESEL
|
||||
["peselInvalidBirthMonth", "Miesiąc w dacie urodzenia jest niepoprawny."],
|
||||
["peselInvalidBirthDay", "Dzień w dacie urodzenia jest niepoprawny."],
|
||||
|
||||
// NIP
|
||||
["nipInvalidOfficeCode", "Kod urzędu skarbowego jest niepoprawny."],
|
||||
|
||||
// REGON
|
||||
["regonInvalidProvinceCode", "Kod województwa jest nieprawidłowy."]
|
||||
]);
|
||||
|
||||
transform(code: string): string {
|
||||
const translated: string | undefined = this.translations.get(code);
|
||||
|
||||
if (translated === undefined) {
|
||||
return 'Translation undefined for code: ' + code;
|
||||
}
|
||||
|
||||
return translated;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user