Gourav Pokharkar
Gourav Pokharkar

Reputation: 1648

Does Angular i18n support Devanagari digits?

I'm working on i18n in Angular 8 app. I have registered locale Hindi ('hi') using following code inside app.module.ts.

import { registerLocaleData } from '@angular/common';
import localeHi from '@angular/common/locales/hi';
import localeHiExtra from '@angular/common/locales/extra/hi';

registerLocaleData(localeHi, 'hi', localeHiExtra);

It changed the digits and month text inside which is as expected. But, when I use DatePipe on date inside a template, it just converted month name to Devanagari and didn't converted digits of date. Same is happening with DecimalPipe.

I even tried to specify locale manually to these pipes, but it didn't work. Why is it behaving differently with <mat-datepicker> and DatePipe? I'm doing something wrong or is it intended behaviour? Any help would be appreciated!

Upvotes: 4

Views: 172

Answers (1)

Gourav Pokharkar
Gourav Pokharkar

Reputation: 1648

While finding solution, I found that in Angular Material Datepicker, I'm using MomentDateAdapter. It's moment.js which has Devanagari digits included in its Hindi locale, but Angular doesn't have these digits.

That's why I'm not able to get Devanagari digits in other places. Though, I wish it could be consistent in all places.

Upvotes: 2

Related Questions