Skip to content

Commit

Permalink
Adding lang support for pipe monthName
Browse files Browse the repository at this point in the history
  • Loading branch information
yammusic committed Apr 14, 2018
1 parent 741c066 commit f948337
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/calendar/calendar.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ion-icon ios="ios-arrow-back" md="md-arrow-back"></ion-icon>
</ion-col>
<ion-col col-auto>
<div>{{displayYear}} - {{displayMonth + 1 | monthName:'es'}}</div>
<div>{{displayYear}} - {{displayMonth + 1 | monthName:lang}}</div>
</ion-col>
<ion-col col-auto (click)="forward()">
<ion-icon ios="ios-arrow-forward" md="md-arrow-forward"></ion-icon>
Expand Down
1 change: 1 addition & 0 deletions src/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/pipes/month-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' ];
Expand Down

0 comments on commit f948337

Please sign in to comment.