Skip to content

Commit

Permalink
feat: use storybook-i18n 2.1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
stevensacks committed Mar 6, 2024
1 parent 859c809 commit 7fc0ef8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 39 deletions.
6 changes: 3 additions & 3 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const preview: Preview = {
globals: {
locale: 'en',
locales: {
en: {title: 'English', left: '🇺🇸', right: 'EN'},
fr: {title: 'French', left: '🇫🇷', right: 'FR'},
ja: {title: '日本語', left: '🇯🇵', right: 'JA'},
en: {icon: '🇺🇸', title: 'English', right: 'EN'},
fr: {icon: '🇫🇷', title: 'Français', right: 'FR'},
ja: {icon: '🇯🇵', title: '日本語', right: 'JP'},
},
},
parameters: {
Expand Down
22 changes: 9 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Easy react-i18next Storybook integration.

Required Peer Dependencies:
* storybook - `^7.0.0`
* storybook - `^8.0.0`
* i18next - `^22.0.0`
* i18next-browser-languagedetector - `^7.0.0`
* i18next-http-backend: `^2.0.0`
Expand Down Expand Up @@ -156,9 +156,9 @@ const preview: Preview = {
globals: {
locale: "en",
locales: {
en: {title: "English", left: '🇺🇸'},
fr: {title: "Français", left: '🇫🇷'},
ja: {title: "日本語", left: '🇯🇵'},
en: {icon: '🇺🇸', title: 'English', right: 'EN'},
fr: {icon: '🇫🇷', title: 'Français', right: 'FR'},
ja: {icon: '🇯🇵', title: '日本語', right: 'JP'},
},
},
parameters: {
Expand All @@ -175,12 +175,12 @@ import i18n from './i18next';

const preview: Preview = {
globals: {
locale: "en_US",
locale: 'en_US',
locales: {
en_US: {title: "English", right: 'US'},
en_GB: {title: "English", right: 'GB'},
fr_FR: {title: "Français", right: 'FR'},
ja_JP: {title: "日本語", right: 'JP'},
en_US: {title: 'English', right: 'US'},
en_GB: {title: 'English', right: 'GB'},
fr_FR: {title: 'Français', right: 'FR'},
ja_JP: {title: '日本語', right: 'JP'},
},
},
parameters: {
Expand Down Expand Up @@ -217,7 +217,3 @@ Once you have finished these steps and launch storybook, you should see a globe
Clicking this globe icon will show a dropdown with the locales you defined in `parameters`.

Switching locales will use the strings defined in your locale json files.

## Migrating to Storybook 7

In `.storybook/preview.ts`, move the locale/locales to be under `globals` instead of `parameters`.
30 changes: 8 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"storybook-i18n": "../storybook-i18n"
"storybook-i18n": "^2.1.1"
},
"devDependencies": {
"@storybook/addon-essentials": "8.0.0-beta.2",
Expand Down

0 comments on commit 7fc0ef8

Please sign in to comment.