Due to Angular update, I have problem with locales.
For now:
import localePl from '@angular/common/locales/pl';
registerLocaleData(localePl);
It's working but causes an error:
WARNING in app.module.ts depends on @angular/common/locales/pl. CommonJS or AMD dependencies can cause optimization bailouts.
Where does it work?
LOCALE_ID
with value pl-PL
DatePipe
in HTML. (variable | date) - variable
is equal to new Date()
Tested ways:
1)
import localePl from '@angular/common/locales/global/pl'; registerLocaleData(localePl, 'pl-PL');
Error:
'Cannot read property '0' of undefined' for pipe
In code:
variable | date
Where variable is equal to new Date()
2)
If I completely remove registerLocaleData
Error:
Missing locale data for the locale "pl-PL".' for pipe 'DatePipe'
I had same issues, to resolve that I, in my app.module:
add
import '@angular/common/locales/global/pl
remove
import localePl from '@angular/common/locales/pl';
and remove "registerLocaleData" function, kept the LOCALE_ID
provider setting.
I hope works for you too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With