Lately, I encountered an issue where certain parts of my Angular application require the date to be displayed in the format: MMMM yyyy
. This also applies to components within the Angular UI Bootstrap framework.
The challenge arises from the fact that some languages have different spellings for the month in nominative and genitive cases. This is particularly evident in languages like Polish, Ukrainian, and Russian.
By default, it appears that MMMM
represents the month name in the genitive case, which seems logical.
Upon inspecting the angular locale files for Russian and Polish, I noticed a property called STANDALONEMONTH
, which seemingly denotes the month name in the nominative case (although this part is missing in the file for Ukrainian).
However, I am uncertain how to leverage this information effectively.
One possible solution could involve creating a decorator for the dateFilter
.
Hence, my question is - is there a standardized approach for handling month name inflection in Angular, or perhaps a commonly used workaround that ensures third-party libraries utilizing $locale
employ the correct month names?
For instance:
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 - acceptable
'MMMM yyyy' -> 'січня 2016' // incorrect: should be 'січень 2016'
pl-pl:
'dd MMMM yyyy' -> '20 stycznia 2016' // genitive case - acceptable
'MMMM yyyy' -> 'stycznia 2016' // incorrect: should be 'styczeń 2016'
From the examples above, we can observe that Ukrainian and Polish necessitate different endings for the month names in these situations. Additionally, the angular locale files for Polish and Russian feature a month name in the proper case (STANDALONEMONTH
). Nevertheless, its actual usage remains unclear as I couldn't find any instances of it being implemented, unless I'm overlooking something.