Skip to content

gabrielseco/addon-react-translate

Repository files navigation

Addon React-Translate NPM Version NPM Downloads Actions Status Actions Status

An addon for storybook to change language in your stories along with react-translate with ease

Install

npm install @rogal/addon-react-translate --save-dev

Getting Started

In your main.js, in the addons array add

{
  addons: [
    // other addons...

    "@rogal/addon-react-translate"
  ]
}

And then in your preview.js

import { withReactTranslate } from '@rogal/addon-react-translate';

addDecorator(
  withReactTranslate({
    languages: ['en', 'es'],
    language: 'en',
    fallbackLng: 'en',
    translations: {
      en: {
        collection: collectionEN,
      },
      es: {
        collection: collectionES,
      }
    }
  })
);

And then you are good to go

Features

  • Change the language of your stories with a selectbox

License

MIT