Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addon to provide a locale switcher and react-intl for storybook

License

NotificationsYou must be signed in to change notification settings

truffls/storybook-addon-intl

Repository files navigation

The Intl addon can be used to provide locale switcher and react-intl.

Getting Started

First, install the addon

npm install -D storybook-addon-intl

Then, add following content to.storybook/main.js:

exportdefault{addons:['storybook-addon-intl']};

In.storybook/preview.js, add the following:

// Provide your messagesconstmessages={en:{message:'Just some text.'},de:{message:'Nur etwas Text.'},es:{message:'Sólo un texto.'}};constgetMessages=(locale)=>messages[locale];exportdefault{parameters:{intl:{locales:defaultLocales,defaultLocale:'en',            getMessages}}};

Configuration

Parameter key:intl

locales

Type:string[]

Available locales.

defaultLocale

Type:string

Fallback locale.

getMessages

Type:(locale: string) => object

Getter function that takes the active locale as arguments and expects anobject of messages as a return value.

(Seemessages inIntlProvider docs of react-intl)

getFormats

Type:(locale: string) => object

Getter function that takes the active locale as arguments and expects anobject of formats as a return value.

(Seeformats inIntlProvider docs of react-intl)

defaultRichTextElements

Type:object

Object of rich text elements.

(SeedefaultRichTextElements inIntlProvider docs of react-intl)

About

Addon to provide a locale switcher and react-intl for storybook

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors14


[8]ページ先頭

©2009-2025 Movatter.jp