Browse Source
Merge pull request #868 from mrfelton/feat/storybook-i18n
feat(i18n): add i18n support to storybook
renovate/lint-staged-8.x
JimmyMow
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
29 additions and
3 deletions
-
.storybook/addons.js
-
.storybook/config.js
-
app/containers/Root.js
-
package.json
-
yarn.lock
|
|
@ -4,3 +4,4 @@ import 'storybook-addon-styled-component-theme/dist/register' |
|
|
|
import '@storybook/addon-storysource/register' |
|
|
|
import '@storybook/addon-links/register' |
|
|
|
import '@storybook/addon-console' |
|
|
|
import 'storybook-addon-intl/register' |
|
|
|
|
|
@ -5,13 +5,27 @@ import { withOptions } from '@storybook/addon-options' |
|
|
|
import { setDefaults, withInfo } from '@storybook/addon-info' |
|
|
|
import { withConsole } from '@storybook/addon-console' |
|
|
|
import { linkTo } from '@storybook/addon-links' |
|
|
|
import { setIntlConfig, withIntl } from 'storybook-addon-intl' |
|
|
|
import chaptersAddon from 'react-storybook-addon-chapters' |
|
|
|
import StoryRouter from 'storybook-react-router' |
|
|
|
import { dark, light } from 'themes' |
|
|
|
|
|
|
|
import { getDefaultLocale, locales } from 'lib/i18n' |
|
|
|
import React from 'react' |
|
|
|
import GlobalStyle from 'components/UI/GlobalStyle' |
|
|
|
|
|
|
|
// Register supported locales.
|
|
|
|
import '../app/lib/i18n/locale' |
|
|
|
|
|
|
|
// Get translations.
|
|
|
|
import translations from '../app/lib/i18n/translation' |
|
|
|
|
|
|
|
// Set intl configuration
|
|
|
|
setIntlConfig({ |
|
|
|
locales: locales, |
|
|
|
defaultLocale: getDefaultLocale(), |
|
|
|
getMessages: locale => translations[locale] |
|
|
|
}) |
|
|
|
|
|
|
|
// Info
|
|
|
|
addDecorator( |
|
|
|
withInfo({ |
|
|
@ -25,6 +39,9 @@ addDecorator( |
|
|
|
}) |
|
|
|
) |
|
|
|
|
|
|
|
// Intl
|
|
|
|
addDecorator(withIntl) |
|
|
|
|
|
|
|
// Router
|
|
|
|
addDecorator(StoryRouter({})) |
|
|
|
|
|
|
|
|
|
@ -70,10 +70,10 @@ class Root extends React.Component { |
|
|
|
|
|
|
|
// If this is the first time the app has mounted, initialise things.
|
|
|
|
if (!isMounted) { |
|
|
|
setMounted(true) |
|
|
|
initTheme() |
|
|
|
initLocale() |
|
|
|
initCurrency() |
|
|
|
setMounted(true) |
|
|
|
} |
|
|
|
|
|
|
|
// Hide the loading screen after a set time.
|
|
|
|
|
|
@ -284,6 +284,7 @@ |
|
|
|
"rimraf": "^2.6.2", |
|
|
|
"sass-loader": "^7.1.0", |
|
|
|
"spectron": "^4.0.0", |
|
|
|
"storybook-addon-intl": "^2.3.1", |
|
|
|
"storybook-addon-styled-component-theme": "^1.0.7", |
|
|
|
"storybook-react-router": "^1.0.1", |
|
|
|
"style-loader": "^0.23.1", |
|
|
|
|
|
@ -13278,7 +13278,7 @@ promzard@^0.3.0: |
|
|
|
dependencies: |
|
|
|
read "1" |
|
|
|
|
|
|
|
prop-types@15.x, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.5.9, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2: |
|
|
|
prop-types@15.x, prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.5.9, prop-types@^15.6.0, prop-types@^15.6.1, prop-types@^15.6.2: |
|
|
|
version "15.6.2" |
|
|
|
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102" |
|
|
|
integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ== |
|
|
@ -15631,6 +15631,13 @@ stealthy-require@^1.1.0: |
|
|
|
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" |
|
|
|
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks= |
|
|
|
|
|
|
|
storybook-addon-intl@^2.3.1: |
|
|
|
version "2.3.1" |
|
|
|
resolved "https://registry.yarnpkg.com/storybook-addon-intl/-/storybook-addon-intl-2.3.1.tgz#d333ab452026811bb8932708d6ff07d8a318821d" |
|
|
|
integrity sha512-G9c7eD1BuuOwc9F/RvAWSisxHQVrA2fCef6WhcvDwPyX6b0RuMLO9dEMABI2DFkLbkXhlXiZy0qdr9UZxEhH0A== |
|
|
|
dependencies: |
|
|
|
prop-types "^15.5.0" |
|
|
|
|
|
|
|
storybook-addon-styled-component-theme@^1.0.7: |
|
|
|
version "1.0.7" |
|
|
|
resolved "https://registry.yarnpkg.com/storybook-addon-styled-component-theme/-/storybook-addon-styled-component-theme-1.0.7.tgz#8126497f69e734212395e60aad68efa11d3c6fe5" |
|
|
|