-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use next-intl for internationalization, replacing i18next (#260)
## Ticket Part of #66 ## Changes - Replace all I18next dependencies with [`next-intl`](https://next-intl-docs.vercel.app/) - Add new `tests/test-utils` file that would be used for rendering and querying a React tree in tests, rather than directly importing from `@testing-library/react`. This is so that the i18n content is provided to the component being tested. ## Context for reviewers This is one of the main pieces of the larger migration effort from the Pages router to the App Router (#66). To reduce the size of that PR, I've broken out the i18n migration work into this PR. Next.js App Router doesn't support internationalized routing or locale detection, like Pages router, and `next-intl` makes it easy to restore that functionality via middleware.
- Loading branch information
Showing
35 changed files
with
627 additions
and
1,097 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @file Storybook decorator, enabling internationalization for each story. | ||
* @see https://storybook.js.org/docs/writing-stories/decorators | ||
*/ | ||
import { StoryContext } from "@storybook/react"; | ||
|
||
import { NextIntlClientProvider } from "next-intl"; | ||
import React from "react"; | ||
|
||
import { defaultLocale, formats, getLocaleMessages } from "../src/i18n"; | ||
|
||
const I18nStoryWrapper = ( | ||
Story: React.ComponentType, | ||
context: StoryContext | ||
) => { | ||
const locale = context.globals.locale ?? defaultLocale; | ||
|
||
return ( | ||
<NextIntlClientProvider | ||
formats={formats} | ||
locale={locale} | ||
messages={getLocaleMessages(locale)} | ||
> | ||
<Story /> | ||
</NextIntlClientProvider> | ||
); | ||
}; | ||
|
||
export default I18nStoryWrapper; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.