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

DatePicker/MonthPicker: add support for translations provider #3390

Merged
merged 3 commits into from
Nov 27, 2024

Conversation

HalvorHaugan
Copy link
Contributor

@HalvorHaugan HalvorHaugan commented Nov 20, 2024

Maybe it should have been a separate PR, but I removed pointerEvents="none" on CalendarIcon so that you get a tooltip on hover. It also makes NVDA announce the title on hover, which I guess is a plus. (It normally announces everything you hover.)

Please help me check that I haven't missed any texts 😅

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation / Decision Records
  • Storybook
  • Style mappings (@navikt/core/css/config/_mappings.js)
  • Component tokens (@navikt/core/css/tokens.json)
  • CSS class deprecations (@navikt/aksel-stylelint/src/deprecations.ts)
  • Exports (@navikt/core/react/src/index.ts and @navikt/core/react/package.json)
  • New component? CSS import (@navikt/core/css/index.css)
  • Breaking change? Update migration guide. Consider codemod.
  • Changeset (Format: <Component>: <gitmoji?> <Text>. E.g. "Button: ✨ Add feature xyz.")

Copy link

changeset-bot bot commented Nov 20, 2024

🦋 Changeset detected

Latest commit: 13d0ca8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@navikt/ds-react Patch
@navikt/ds-css Patch
@navikt/ds-tokens Patch
@navikt/ds-tailwind Patch
@navikt/aksel-icons Patch
@navikt/aksel Patch
@navikt/aksel-stylelint Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Nov 20, 2024

Storybook demo / Chromatic

📝 Endringer til review: 58

21b8b3ecd | 91 komponenter | 135 stories

@@ -102,4 +102,24 @@ export default {
reset: "Tilbakestill tidsperspektiv",
},
},
DatePicker: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The translation object name is not ideal since it contains texts for both DatePicker and MonthPicker. Some are shared as well. Should we call it something else?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't really think of something different that makes sense, so DatePicker is probably fine. You are technically picking a date when you pick a month or year, so it still technically works in that sense 🙈

@@ -97,4 +97,24 @@ export default {
reset: "Tilbakestill tidsperspektiv",
},
},
DatePicker: {
close: "Lukk",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this generic enough to be under "global" ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nvm see the todo under nb.json now. I think it makes sense to just add it to global 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, probably. I will review all the TODOs after all translations has been added.

Comment on lines 115 to 116
nextMonth: "Gå til neste måned",
previousMonth: "Gå til forrige måned",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to prefix them like this to better indicate its intention?

Suggested change
nextMonth: "Gå til neste måned",
previousMonth: "Gå til forrige måned",
goToNextMonth: "Gå til neste måned",
goToPreviousMonth: "Gå til forrige måned",

month: "Måned",
nextMonth: "Gå til neste måned",
previousMonth: "Gå til forrige måned",
year: "År",
Copy link
Collaborator

Choose a reason for hiding this comment

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

More of a general question, but the keys day, month and year are quite generic. Would it make sense to have a "global" date key on the same level as "global"?

"date": {
year...
...
}

Copy link
Contributor Author

@HalvorHaugan HalvorHaugan Nov 21, 2024

Choose a reason for hiding this comment

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

Not sure. I want to be restrictive about making keys global since it complicates tings a little. (Have to useI18n() multiple times, and makes the translations prop on the component more complicated.)

Can you think of any benefits to this, other than that it avoids breaking changes if we need to make them global later?

(Side note: I wonder how hard it would be to support multiple "component names" in useI18n() 🤔)

Copy link
Collaborator

Choose a reason for hiding this comment

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

See no real benefits other than that if felt a little off that you define how "year" is written inside datepicker, so works fine as is for me 👍

Comment on lines 113 to 114
nextYear: "Go to next year",
previousYear: "Go to previous year",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as goToNextMonth comment further down, does it make sense to prefix these with goTo to show intention better?

@HalvorHaugan HalvorHaugan merged commit 1f4ac7b into main Nov 27, 2024
4 checks passed
@HalvorHaugan HalvorHaugan deleted the datemonthpicker-i18n branch November 27, 2024 11:29
@github-actions github-actions bot mentioned this pull request Nov 27, 2024
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