I run into an issue recently - in some parts of my angular application I have to show the date in the following format: MMMM yyyy
, as well in some components of the Angular UI Bootstrap framework.
The basic issue is that in some languages the month in nominative and genitive case is spelled differently. In my case that would be Polish, Ukrainian and Russian.
As it seems by default MMMM
stands for month name in genitive case, which generally makes sense.
Though I've noticed that in angular locale files for Russian and Polish language there is a property STANDALONEMONTH
which, as I see, stands for month name in nominative. (though file for Ukrainian is missing that part)
Though I'm not quite sure how to take use on those.
My basic suggestion would be to go with a decorator for the dateFilter
.
So the question is - whether there is a standard way for month name inflection handling in angular, or a workaround that is commonly used, so that the third party libraries using the $locale
would use the proper month name.
Example
date: '2016-01-20'
en-us:
'dd MMMM yyyy' -> '20 January 2016'
'MMMM yyyy' -> 'January 2016'
uk-ua:
'dd MMMM yyyy' -> '20 січня 2016' // genitive case - it is fine
'MMMM yyyy' -> 'січня 2016' // wrong: should be 'січень 2016'
pl-pl:
'dd MMMM yyyy' -> '20 stycznia 2016' // genitive case - it is fine
'MMMM yyyy' -> 'stycznia 2016' // wrong: should be 'styczeń 2016'
As you see - for Ukrainian and Polish the name of the month should have a different ending in those two cases. As well for Polish and Russian there is a month name in proper case in angular locale files (STANDALONEMONTH
). Though I'm not quite sure they are used anywhere - was not able to find usage, or maybe I am missing something.