All Projects → truffls → storybook-addon-intl

truffls / storybook-addon-intl

Licence: MIT License
Addon to provide a locale switcher and react-intl for storybook

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to storybook-addon-intl

storybook-addon-matrix
Storybook addon for rendering components with a matrix of props
Stars: ✭ 32 (-61.9%)
Mutual labels:  storybook, storybook-addon
i18n
internationalize projects to Arabic
Stars: ✭ 67 (-20.24%)
Mutual labels:  i18n, l10n
arabic-mathjax
Beautiful Arabic Math on all browsers. An extension for MathJax v2.
Stars: ✭ 12 (-85.71%)
Mutual labels:  i18n, l10n
lisan
🌈i18n, Reimagined! 🚀A blazing fast and super small i18n library for Javascript
Stars: ✭ 85 (+1.19%)
Mutual labels:  i18n, l10n
gettext-extractor
A flexible and powerful Gettext message extractor with support for JavaScript, TypeScript, JSX and HTML.
Stars: ✭ 82 (-2.38%)
Mutual labels:  i18n, l10n
mobx-react-intl
A connector between mobx-react and react-intl
Stars: ✭ 32 (-61.9%)
Mutual labels:  i18n, react-intl
oojs-ui
OOUI is a modern JavaScript UI library with strong cross-browser support. It is the standard library for MediaWiki and Wikipedia. This is a mirror from https://gerrit.wikimedia.org. Main website:
Stars: ✭ 45 (-46.43%)
Mutual labels:  i18n, l10n
awesome-translations
😎 Awesome lists about Internationalization & localization stuff. l10n, g11n, m17n, i18n. Translations! 🌎🌍
Stars: ✭ 54 (-35.71%)
Mutual labels:  i18n, l10n
Angular-Gulp-Boilerplate
Clean but full-featured AngularJS boilerplate using Gulp workflow and best practices
Stars: ✭ 30 (-64.29%)
Mutual labels:  i18n, l10n
inlang
Open Source Localization Solution for Software.
Stars: ✭ 160 (+90.48%)
Mutual labels:  i18n, l10n
stone.js
gettext-like client-side Javascript Internationalization Library
Stars: ✭ 20 (-76.19%)
Mutual labels:  i18n, l10n
translation
👅 Translations (symfony/translation) to Nette Framework (@nette)
Stars: ✭ 55 (-34.52%)
Mutual labels:  i18n, l10n
banana-i18n
banana-i18n - Javascript Internationalization library
Stars: ✭ 61 (-27.38%)
Mutual labels:  i18n, l10n
lp-loader
Frictionless language packs for Webpack.
Stars: ✭ 14 (-83.33%)
Mutual labels:  i18n, l10n
vue-example
Vue.js example application (server-side rendering, router, vuex store, form validation, i18n & l10n)
Stars: ✭ 62 (-26.19%)
Mutual labels:  i18n, l10n
go-locale
GoLang library used to retrieve the current locale(s) of the operating system.
Stars: ✭ 16 (-80.95%)
Mutual labels:  i18n, l10n
I18N
I18N Library for .NET, and Delphi
Stars: ✭ 48 (-42.86%)
Mutual labels:  i18n, l10n
storybook-graphql-kit
Write GraphQL queries and pass response data to your components
Stars: ✭ 19 (-77.38%)
Mutual labels:  storybook, storybook-addon
storybook-addon-headless
A Storybook addon to preview content from a headless CMS in components
Stars: ✭ 23 (-72.62%)
Mutual labels:  storybook, storybook-addon
extract-react-intl
Extract react-intl messages
Stars: ✭ 18 (-78.57%)
Mutual labels:  i18n, react-intl

Intl Addon Build Status

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

Note: Following peer dependencies are required: @storybook/addons, @storybook/react, react and react-intl.

Add this line to your addons.js file (create this file inside your storybook config directory if needed).

import 'storybook-addon-intl/register';

In your config.js import the setIntlConfig and withIntl function. Use setIntlConfig to set the configuration for react-intl and `withIntl´ as decorator.

import { addDecorator, configure } from '@storybook/react';
import { setIntlConfig, withIntl } from 'storybook-addon-intl';

// Load the locale data for all your defined locales
import { addLocaleData } from 'react-intl';
import enLocaleData from 'react-intl/locale-data/en';
import deLocaleData from 'react-intl/locale-data/de';

addLocaleData(enLocaleData);
addLocaleData(deLocaleData);

// Provide your messages
const messages = {
    'en': { 'button.label': 'Click me!' },
    'de': { 'button.label': 'Klick mich!' }
};

// Provide your formats (optional)
const formats = {
    'en': {
            'date': {
                'year-only': {
                    'year': '2-digit',
                },
            },
        },
    'de': {
            'date': {
                'year-only': {
                    'year': 'numeric',
                },
            },
        },
};

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

// Set intl configuration
setIntlConfig({
    locales: ['en', 'de'],
    defaultLocale: 'en',
    getMessages,
    getFormats,
});

// Register decorator
addDecorator(withIntl);


// Run storybook
configure(() => require('./stories'), module);

Troubleshooting

Accessing nonexistent addons channel error:

This error can be caused by multiple conflicting versions of @storybook/addons in your app.

  • Ensure that the entries starting with @storybook/addon- in your package.json refer to the same and latest version.
  • Add the latest version of @storybook/addons to your app's dependencies and reinstall all modules.

If the above steps don't solve the issue, please read the storybook documentation on this topic:

Most of the time, the fix is deleting the node_modules folder with any package-lock.json or yarn.lock and reinstalling.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].