From f9483379a8dc140145e3759be5f5f568dfba9391 Mon Sep 17 00:00:00 2001 From: HackettYam Date: Sat, 14 Apr 2018 01:11:05 -0500 Subject: [PATCH] Adding lang support for pipe monthName --- src/calendar/calendar.html | 2 +- src/calendar/calendar.ts | 1 + src/calendar/pipes/month-name.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calendar/calendar.html b/src/calendar/calendar.html index c8e0e2c..8556172 100644 --- a/src/calendar/calendar.html +++ b/src/calendar/calendar.html @@ -4,7 +4,7 @@ -
{{displayYear}} - {{displayMonth + 1 | monthName:'es'}}
+
{{displayYear}} - {{displayMonth + 1 | monthName:lang}}
diff --git a/src/calendar/calendar.ts b/src/calendar/calendar.ts index 7ff4b60..02a3f0b 100644 --- a/src/calendar/calendar.ts +++ b/src/calendar/calendar.ts @@ -57,6 +57,7 @@ export class Calendar { weekHead: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; constructor() { + console.info(this.lang); if (!this.lang) { this.lang = 'en'; } if (this.lang === 'es') { this.weekHead = ['Dom', 'Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab']; diff --git a/src/calendar/pipes/month-name.ts b/src/calendar/pipes/month-name.ts index 450f1d6..9ec1e25 100644 --- a/src/calendar/pipes/month-name.ts +++ b/src/calendar/pipes/month-name.ts @@ -4,9 +4,9 @@ import {Pipe} from '@angular/core'; name: 'monthName' }) export class monthName { - private lang: string = 'es'; // (es or en) + private lang: string; // (es or en) transform(value, args) { - console.info(args); + if (args === 'es') { this.lang = 'es'; } let monthNames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; if (this.lang === 'es') { monthNames = [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ];