-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format day of month ('Do') french translation error #437
Comments
Thank you for the report! cc @date-fns/i18n-french |
I'm trying to fix the exact same problem in Moment.js. (And might fix it here too.) Please read related issue moment/moment#3375 (comment) The English2017-03-01 → French2017-03-01 → When writing long date format in French, we want to use ordinal for day 1 (token Solutions I can think of:
Name it Or maybe this problem is too specific of the French language, doesn't merit a dedicated token for all languages, and is semantically better handled within the French locale code. This brings second solution:
Other ideas? What is your preference? |
var monthsTokens = ['MMM', 'MMMM']
monthsTokens.forEach(function (monthToken) {
formatters['Do ' + monthToken] = function (date) {
var dayOfMonth = date.getUTCDate()
var formattedDayOfMonth = dayOfMonth === 1 ? '1er' : String(dayOfMonth)
var formattedMonth = formatters[monthToken](date)
return formattedDayOfMonth + ' ' + formattedMonth
}
})
|
@fbonzon oh yeah, I missed your pull request, sorry 😅 |
I'm agree with your comment @fbonzon Maybe other languages, like Italian, follow the same rules? Like "Il 1° guigno" ("the 1th june") but "Il 2 guigno" ("the 2nd june"). About your ideas of solution 1. or 2., I personally think both achieve the goals and can't tell wich one is the better ;) |
@leshakoss #448 addresses an unrelated problem, thus I did not mention it here. A similar code to the Russian example you mentioned could be written for French, yes. If I understand correctly, it is possible to include a given token in several formatters? How is selected the one to use? E.g. if I define formatters for |
@fbonzon both formatters (MMM and Do MMM) should work, I think |
Yes, but what is the logic to decide which formatter to use? I could dig into the code, but maybe you know the answer already. Provided I define formatters for (1) |
@fbonzon alright token string is splitted by a regexp of all possible tokens, sorted backwards alphanumerically:
Here, it splitted the token string like this: ['MMMM', ' ', 'Do', ' ', 'Do MMMM', ' ', 'Do'] |
Is now clear to me, thanks. Verified in code, is the same for all locales. The priority is indeed defined only by reversed alphabetical order. It would work for our use case. We would modify contents of I can code this is it's your preferred solution. It's not the most elegant one, in my opinion, but it works. |
@fbonzon yeah alright thank you 😄 |
Fix released in v1.28.0 |
Could we get a similar fix in v2? (see #1391 (comment)) |
Hi,
I think that the format of the day of month ('Do') isn't correct in french, it doesn't follow the same rules as in english or german for example or even doesn't follow the same logic as day of the year of week in french.
day of month ('Do'):
1st, 2nd, ..., 31st in english is correct
or
1., 2., ... 31. in german is correct too
but for day of the month in french, you not gonna says
1er, 2e, ... 31e
but
1er, 2, ... 31
like "le 1er janvier 2017" but like "le 2 janvier 2017", ... "le 31 janvier 2017"
Therefore I think that the function ordinal in src/locale/fr/build_format_locale/index.js should be extended, when the number is greater than 1, the code "number + 'e'" should only apply for day of the week and day of the year where it should only return "number" when day of the month.
Best regards
The text was updated successfully, but these errors were encountered: