Sebastián Rojas
Sebastián Rojas

Reputation: 2891

How to use date DatePipe with ngx-translate

I have this translation defined:

"...has created {{param1}} ({{param2}}) on {{ param3 | date:'mediumDate' }}, {{ param3| date:'shortTime' }}"

param1 and param2 get replaced but param3 is not ({{ param3 | date:'mediumDate' }}, {{ param3| date:'shortTime' }} is printed)...how can I use the datepipe inside a translation?

Upvotes: 2

Views: 5671

Answers (1)

Bunyamin Coskuner
Bunyamin Coskuner

Reputation: 8859

When you define your translation like that, ngx-translate expects {{param3 | date:'mediumDate' }} as is.

Instead just try following

"...has created {{param1}} ({{param2}}) on {{ param3 }}, {{ param4}}"

When you want to get your message, use it as follows

{{'path.to.your.message' | translate: {param3: yourDateVariable| date: 'mediumDate'}}}

Upvotes: 8

Related Questions