Skip to content

Commit

Permalink
👽 [#724] Update react-intl addon init code to not use require
Browse files Browse the repository at this point in the history
require doesn't exist in Vite, but import.meta can be used
instead.
  • Loading branch information
sergei-maertens committed Nov 29, 2024
1 parent f3f66d3 commit 9d553e9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
withClearSessionStorage,
withClearSubmissionLocalStorage,
} from './decorators';
import {reactIntl} from './reactIntl.js';
import {reactIntl} from './reactIntl.mjs';
import ThemeProvider from './theme';

initialize({
Expand Down
15 changes: 0 additions & 15 deletions .storybook/reactIntl.js

This file was deleted.

18 changes: 18 additions & 0 deletions .storybook/reactIntl.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const locales = ['nl', 'en'];

const messages = {};
const importMessages = import.meta.glob('../src/i18n/compiled/*.json', {eager: true});

// Populate the messages object
locales.forEach(lang => {
messages[lang] = importMessages[`../src/i18n/compiled/${lang}.json`];
});

const formats = {}; // optional, if you have any formats

export const reactIntl = {
defaultLocale: 'nl',
locales,
messages,
formats,
};

0 comments on commit 9d553e9

Please sign in to comment.