-
Notifications
You must be signed in to change notification settings - Fork 39
Use storybook-react-intl addon #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
binh-dam-ibigroup
merged 15 commits into
opentripplanner:master
from
ibi-group:use-storybook-react-intl-addon
Mar 14, 2022
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e3bfe91
chore(deps): Set up storybook-react-intl.
binh-dam-ibigroup 7985e36
refactor(location-field): Remove intl decorator and deps from stories.
binh-dam-ibigroup 9043d7b
refactor(TripDetails.story): Convert some story args to parameters.
binh-dam-ibigroup 54dbfc2
refactor(TripDetails.story): Go back to args, but remove unused story…
binh-dam-ibigroup 00e6fee
refactor(.storybook/react-intl): Tweak message loading.
binh-dam-ibigroup bdcf62d
refactor(location-field stories): Improve story descriptions.
binh-dam-ibigroup 3632404
refactor(trip-form): Use storybook-react-intl with SettingsSelector
binh-dam-ibigroup 17b3384
style(TripDetails.story): Reorder props.
binh-dam-ibigroup 4b73ecd
test(Update snapshots):
binh-dam-ibigroup 8e8d45c
test(storybook): Remove redundant data from snapshots.
binh-dam-ibigroup 7acc4bf
refactor(.storybook/react-intl): Tweak comments.
binh-dam-ibigroup bc143e2
docs(TripDetails.story): Add comments regarding overriding msgs with …
binh-dam-ibigroup 2108869
refactor(trip-form/stories): Make decorator a fragment.
binh-dam-ibigroup a8b2908
Merge branch 'master' into use-storybook-react-intl-addon
binh-dam-ibigroup c103993
test(snapshots): Remove duplicate IntlProviders from snapshots.
binh-dam-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import flatten from "flat"; | ||
|
|
||
| /** | ||
| * Copied from https://stackoverflow.com/questions/50940640/how-to-determine-if-jest-is-running-the-code-or-not | ||
| */ | ||
| function isRunningJest() { | ||
| return process.env.JEST_WORKER_ID !== undefined; | ||
| } | ||
|
|
||
| /** Locales supported in the storybook "Globe" dropdown menu. */ | ||
| const locales = ["en-US", "fr", "unknown"]; | ||
|
|
||
| /** List of packages that will have localization support in Storybook. */ | ||
| const packages = [ | ||
| "location-field", | ||
| "trip-details", | ||
| "trip-form" | ||
| ]; | ||
|
|
||
| /** Messages for all packages AND locales above. */ | ||
| const messages = {}; | ||
|
|
||
| if (!isRunningJest()) { | ||
| // Populate messages if not running snapshots. | ||
| // (Message printouts would be unnecessary replicated in snapshots without that check.) | ||
| packages.forEach((pkg) => { | ||
| locales.forEach((locale) => { | ||
|
miles-grant-ibigroup marked this conversation as resolved.
|
||
| try { | ||
| messages[locale] = { | ||
| ...messages.[locale], | ||
| ...flatten(require(`../packages/${pkg}/i18n/${locale}.yml`)) | ||
| }; | ||
| } catch (e) { | ||
| // There is no yml files for the "unknown" locale, | ||
| // so it should fail, and we won't display an error message in that case. | ||
| if (locale !== "unknown") console.error(e); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| // TODO: place any applicable (date, time, etc) format parameters here. | ||
| const formats = {}; | ||
|
|
||
| export const reactIntl = { | ||
| defaultLocale: "en-US", | ||
| formats, | ||
| locales, | ||
| messages | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.