Skip to content
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

Use locale for month aria labels #4697

Merged

Conversation

lasseklovstad
Copy link
Contributor

@lasseklovstad lasseklovstad commented Apr 16, 2024

Description

Added using locale for aria labels in Month component

Couldn't find any issues on this...

Problem
When showing MonthYearPicker the locale is not used when formatting date. -> Screenreaders will always read english months...

Changes
I have added using locale when formatting both the month listbox and options.

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ This pull request was sent to the PullRequest network for review. Expert reviewers are now being matched to your request based on the code's requirements. Stay tuned!

What to expect from this code review:
  • Comments posted to any areas of potential concern or improvement.
  • Detailed feedback or actions needed to resolve issues that are found.
  • Turnaround times vary, but we aim to be swift.

@lasseklovstad you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PullRequest Breakdown

Reviewable lines of change

+ 34
- 3

84% JavaScript (tests)
16% JavaScript

Type of change

Minor Update - These changes appear to be a minor update to existing functionality and features.

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.09%. Comparing base (903d0ce) to head (e52335d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4697   +/-   ##
=======================================
  Coverage   97.09%   97.09%           
=======================================
  Files          28       28           
  Lines        2653     2653           
  Branches     1123     1140   +17     
=======================================
  Hits         2576     2576           
  Misses         77       77           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code as-is would work, which is why I marked it as "looks good". With that said, I would personally prefer to use the browser's built-in localization, which would be far more thorough and up-to-date than any library ever could be.

Image of Jacob Jacob


Reviewed with ❤️ by PullRequest

const labelDate = utils.setMonth(day, month);
const prefix =
this.isDisabled(labelDate) || this.isExcluded(labelDate)
? disabledDayAriaLabelPrefix
: chooseDayAriaLabelPrefix;

return `${prefix} ${utils.formatDate(labelDate, "MMMM yyyy")}`;
return `${prefix} ${utils.formatDate(labelDate, "MMMM yyyy", locale)}`;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it would be better to format it in the user's preferred locale (using Intl.DateTimeFormat).

🔹 Best Practices (Nice to have)

Image of Jacob Jacob

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the formatDate function defaults to the users perfered locale when this prop is undefined.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking more in terms of leveraging what the browser already provides, as the time and effort put into it for browsers is far more than a library. Though now that I say that, both most likely fall back to CLDR as their data source.

I don't feel strongly either way; it was merely a suggestion for a possible improvement that I would make. The PR is certainly fine as-is.

Image of Jacob Jacob

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After alittle more research, the formatDate function fallbacks to whatever locale you have set with the setDefaultLocale function. But if you have not registered that language with the registerLocale function it will fall back to date-fns default locale i think.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work here. I don't have any concerns with these changes.

Image of Graham C Graham C


Reviewed with ❤️ by PullRequest

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PullRequest reviewed the updates made to #4697 since our last review was posted. This includes comments that have been posted by non-PullRequest reviewers. No further issues were found.

Reviewed by:

Image of Graham C Graham C

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants