Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

storybook-addon-intl

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storybook-addon-intl

Addon to provide locale switcher and react-intl for storybook

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
34K
increased by12.82%
Maintainers
1
Weekly downloads
 
Created
Source

Storybook Addon Intl

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:

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

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

// Provide your messages
const messages = {
    en: { message: 'Just some text.' },
    de: { message: 'Nur etwas Text.' },
    es: { message: 'Sólo un texto.' }
};

const getMessages = (locale) => messages[locale];

export default {
    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 an object of messages as a return value.

(See messages in IntlProvider docs of react-intl)

getFormats

Type: (locale: string) => object

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

(See formats in IntlProvider docs of react-intl)

defaultRichTextElements

Type: object

Object of rich text elements.

(See defaultRichTextElements in IntlProvider docs of react-intl)

Keywords

FAQs

Package last updated on 16 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc