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

✨ Release i18n support #3429

Merged
merged 16 commits into from
Dec 9, 2024
Merged

✨ Release i18n support #3429

merged 16 commits into from
Dec 9, 2024

Conversation

HalvorHaugan
Copy link
Contributor

@HalvorHaugan HalvorHaugan commented Dec 5, 2024

TODO: Update docs for Provider.

Description

Sorry for the size of this PR 🙈

  • Merged LanguageProvider into Provider, while also changing the API a bit to make it easier to use (with the help of TS).
  • Updated tests for useI18n() according to changes in API.
  • Chips.Removable: Removed prop removeLabel.
  • DatePicker/MonthPicker: Added new translations prop and deprecated locale prop.
  • Search: Deprecated prop clearButtonLabel.
  • Textarea: Deprecated prop i18n.
  • Timeline: Deprecated prop axisLabelTemplates.
  • nb/nn/en.ts:
    • Arranged the top level keys alphabetically.
    • Merged close in Modal and DatePicker and put it under the global key.
    • Changed Search.clear from "Clear" to "Clear field" to make it more... clear 😅
    • Removed Combobox.clear since the clear button has been removed.
    • Made them importable from @navikt/ds-react

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 Dec 5, 2024

🦋 Changeset detected

Latest commit: 4264036

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 Minor
@navikt/ds-css Minor
@navikt/ds-tokens Minor
@navikt/ds-tailwind Minor
@navikt/aksel-icons Minor
@navikt/aksel Minor
@navikt/aksel-stylelint Minor

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

@HalvorHaugan HalvorHaugan marked this pull request as draft December 5, 2024 11:37
Copy link
Contributor

github-actions bot commented Dec 5, 2024

Storybook demo / Chromatic

📝 Endringer til review: 1

e15fe101f | 91 komponenter | 135 stories

@HalvorHaugan HalvorHaugan changed the title ✨ release i18n support ✨ Release i18n support Dec 5, 2024
@HalvorHaugan HalvorHaugan marked this pull request as ready for review December 5, 2024 21:12
"@navikt/ds-react": minor
---

:sparkles: i18n support for all components. ([Docs](https://aksel.nav.no/komponenter/core/provider#84d7ea5ec517))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
:sparkles: i18n support for all components. ([Docs](https://aksel.nav.no/komponenter/core/provider#84d7ea5ec517))
i18n: :sparkles: Implemented i18n support for all components. Components comes with support for nb, nn and en locales ([Docs](https://aksel.nav.no/komponenter/core/provider#84d7ea5ec517))

@navikt/core/react/src/date/datepicker/types.ts Outdated Show resolved Hide resolved
@navikt/core/react/src/date/monthpicker/types.ts Outdated Show resolved Hide resolved

/**
* @private
* Temporary for backwards compatibility with locale prop
Copy link
Collaborator

Choose a reason for hiding this comment

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

For temp-comments, it could be nice to have a small comment describing the requirements for it being removed or "not" temporarily anymore if that makes sense 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Think it would be nice if to access the locales, you have to import from @navikt/ds-react/locales and not directly on "root" @navikt/ds-react. Just have to add this to "package.json" (i think). We then avoid "polluting" the root export with "non"-components

"./locales": {
      "import": {
        "types": "./esm/util/i18n/locales/index.d.ts",
        "default": "./esm/util/i18n/locales/index.js"
      },
      "require": {
        "types": "./cjs/util/i18n/locales/index.d.ts",
        "default": "./cjs/util/i18n/locales/index.js"
      }
    },

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could even take it further and have to import from import enLocale from "@navikt/ds-react/locales/en" and just get a default export 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that require an entry in package.json for each locale?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes to properly scope it to each locale they would all require an entry. I think this technically works, but risks exposing other things in the dir, so one entry per locale would be the safest here.

"./locales/*": "./[path]/*"

Copy link
Contributor Author

@HalvorHaugan HalvorHaugan Dec 6, 2024

Choose a reason for hiding this comment

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

For some reason, this doesn't seem to work with autocomplete:

image

But the first suggestion works:

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Lets go for the first variant then 🚀

}
} & (
| {
/** Locale provided by Aksel */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could link to docs here, or show jsdoc-example with import+use

@navikt/core/react/src/date/datepicker/types.ts Outdated Show resolved Hide resolved
@navikt/core/react/src/timeline/Timeline.tsx Outdated Show resolved Hide resolved
@navikt/core/react/src/timeline/timeline.stories.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@KenAJoh KenAJoh left a comment

Choose a reason for hiding this comment

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

:shipit:

@HalvorHaugan HalvorHaugan merged commit 878ee68 into main Dec 9, 2024
4 checks passed
@HalvorHaugan HalvorHaugan deleted the release-i18n-support branch December 9, 2024 14:38
@github-actions github-actions bot mentioned this pull request Dec 9, 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