From de19bb07fa80fa08ad97621cffe0e755d6231ed5 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Thu, 13 Mar 2025 12:52:08 -0700 Subject: [PATCH] ICU book workflow --- .github/workflows/icu-book.yml | 61 ++++++++++++++++ .storybook/icu-lookup.html | 71 +++++++++++++++++++ .storybook/preview.tsx | 10 +++ .storybook/test-runner.ts | 52 ++++++++++++++ package.json | 4 +- pnpm-lock.yaml | 37 +++------- ts/components/About.stories.tsx | 4 +- .../AddGroupMemberErrorDialog.stories.tsx | 4 +- .../AddUserToAnotherGroupModal.stories.tsx | 4 +- ts/components/Alert.stories.tsx | 4 +- .../AttachmentNotAvailableModal.stories.tsx | 4 +- ts/components/Avatar.stories.tsx | 4 +- ts/components/AvatarColorPicker.stories.tsx | 5 +- ts/components/AvatarEditor.stories.tsx | 5 +- ts/components/AvatarIconEditor.stories.tsx | 5 +- ts/components/AvatarLightbox.stories.tsx | 4 +- ts/components/AvatarModalButtons.stories.tsx | 4 +- ts/components/AvatarPreview.stories.tsx | 4 +- ts/components/AvatarTextEditor.stories.tsx | 5 +- ts/components/AvatarUploadButton.stories.tsx | 5 +- .../BackupMediaDownloadProgress.stories.tsx | 4 +- ts/components/BadgeDialog.stories.tsx | 4 +- ts/components/BetterAvatar.stories.tsx | 4 +- ts/components/BetterAvatarBubble.stories.tsx | 4 +- .../CallLinkAddNameModal.stories.tsx | 4 +- ts/components/CallLinkDetails.stories.tsx | 4 +- ts/components/CallLinkEditModal.stories.tsx | 4 +- ...allLinkPendingParticipantModal.stories.tsx | 4 +- ts/components/CallManager.stories.tsx | 4 +- .../CallNeedPermissionScreen.stories.tsx | 4 +- ts/components/CallScreen.stories.tsx | 4 +- .../CallingAdhocCallInfo.stories.tsx | 4 +- ts/components/CallingButton.stories.tsx | 4 +- .../CallingDeviceSelection.stories.tsx | 4 +- ts/components/CallingHeader.stories.tsx | 4 +- ts/components/CallingLobby.stories.tsx | 4 +- .../CallingParticipantsList.stories.tsx | 4 +- .../CallingPendingParticipants.stories.tsx | 4 +- ts/components/CallingPip.stories.tsx | 4 +- ts/components/CallingPreCallInfo.stories.tsx | 4 +- .../CallingRaisedHandsList.stories.tsx | 4 +- ...CallingScreenSharingController.stories.tsx | 4 +- ...ngSelectPresentingSourcesModal.stories.tsx | 5 +- ts/components/CaptchaDialog.stories.tsx | 4 +- ts/components/ChatColorPicker.stories.tsx | 4 +- ts/components/ChatsTab.stories.tsx | 4 +- ts/components/ClearingData.stories.tsx | 4 +- ts/components/CollidingAvatars.stories.tsx | 4 +- ts/components/CompositionArea.stories.tsx | 4 +- ts/components/CompositionInput.stories.tsx | 4 +- .../CompositionRecording.stories.tsx | 4 +- .../CompositionRecordingDraft.stories.tsx | 4 +- .../ConfirmDiscardDialog.stories.tsx | 5 +- ts/components/ConfirmationDialog.stories.tsx | 4 +- ts/components/ContactPills.stories.tsx | 4 +- ts/components/ContextMenu.stories.tsx | 4 +- ts/components/ConversationList.stories.tsx | 4 +- ts/components/CountryCodeSelect.stories.tsx | 4 +- ts/components/CrashReportDialog.stories.tsx | 4 +- ts/components/CustomColorEditor.stories.tsx | 4 +- ...omizingPreferredReactionsModal.stories.tsx | 5 +- ts/components/DebugLogWindow.stories.tsx | 4 +- ts/components/DeleteMessagesModal.stories.tsx | 4 +- ts/components/DialogExpiredBuild.stories.tsx | 4 +- ts/components/DialogNetworkStatus.stories.tsx | 4 +- ts/components/DialogRelink.stories.tsx | 4 +- ts/components/DialogUpdate.stories.tsx | 5 +- .../DisappearingTimeDialog.stories.tsx | 5 +- .../DisappearingTimerSelect.stories.tsx | 4 +- .../EditNicknameAndNoteModal.stories.tsx | 4 +- .../EditUsernameModalBody.stories.tsx | 4 +- ts/components/ErrorModal.stories.tsx | 4 +- .../ForwardMessagesModal.stories.tsx | 4 +- .../GroupCallOverflowArea.stories.tsx | 4 +- .../GroupCallRemoteParticipant.stories.tsx | 4 +- .../GroupDescriptionInput.stories.tsx | 4 +- ts/components/GroupTitleInput.stories.tsx | 4 +- .../GroupV1MigrationDialog.stories.tsx | 4 +- ts/components/GroupV2JoinDialog.stories.tsx | 4 +- ts/components/I18n.stories.tsx | 4 +- ts/components/InContactsIcon.stories.tsx | 4 +- ts/components/Inbox.stories.tsx | 5 +- ts/components/IncomingCallBar.stories.tsx | 4 +- ts/components/Input.stories.tsx | 4 +- ts/components/LeftPane.stories.tsx | 4 +- ts/components/Lightbox.stories.tsx | 4 +- .../LocalDeleteWarningModal.stories.tsx | 4 +- ts/components/MediaEditor.stories.tsx | 4 +- .../MediaPermissionsModal.stories.tsx | 4 +- .../MediaQualitySelector.stories.tsx | 4 +- ts/components/MiniPlayer.stories.tsx | 5 +- ts/components/Modal.stories.tsx | 4 +- ts/components/MyStories.stories.tsx | 4 +- ts/components/MyStoryButton.stories.tsx | 4 +- ...atedGroupInvitedContactsDialog.stories.tsx | 4 +- ts/components/NotePreviewModal.stories.tsx | 4 +- .../OutgoingGiftBadgeModal.stories.tsx | 4 +- ts/components/Preferences.stories.tsx | 4 +- ts/components/ProfileEditor.stories.tsx | 4 +- ts/components/ProgressDialog.stories.tsx | 5 +- ts/components/ProgressModal.stories.tsx | 4 +- .../SafetyNumberChangeDialog.stories.tsx | 4 +- .../SafetyNumberNotReady.stories.tsx | 4 +- ts/components/SafetyNumberViewer.stories.tsx | 4 +- ts/components/SafetyTipsModal.stories.tsx | 4 +- ts/components/SendStoryModal.stories.tsx | 4 +- ts/components/ShortcutGuide.stories.tsx | 4 +- .../SignalConnectionsModal.stories.tsx | 4 +- .../StoriesSettingsModal.stories.tsx | 4 +- ts/components/StoriesTab.stories.tsx | 4 +- ts/components/StoryCreator.stories.tsx | 4 +- ts/components/StoryDetailsModal.stories.tsx | 4 +- ts/components/StoryImage.stories.tsx | 4 +- ts/components/StoryLinkPreview.stories.tsx | 4 +- ts/components/StoryListItem.stories.tsx | 4 +- ts/components/StoryViewer.stories.tsx | 4 +- .../StoryViewsNRepliesModal.stories.tsx | 4 +- .../TapToViewNotAvailableModal.stories.tsx | 4 +- ts/components/TextAttachment.stories.tsx | 4 +- ts/components/ToastManager.stories.tsx | 4 +- ts/components/UnsupportedOSDialog.stories.tsx | 4 +- .../UsernameLinkModalBody.stories.tsx | 4 +- ts/components/UsernameMegaphone.stories.tsx | 4 +- .../UsernameOnboardingModal.stories.tsx | 5 +- ts/components/WhatsNewModal.stories.tsx | 4 +- .../AboutContactModal.stories.tsx | 4 +- .../AttachmentDetailPill.stories.tsx | 4 +- .../conversation/AttachmentList.stories.tsx | 4 +- .../CallingNotification.stories.tsx | 4 +- .../ChangeNumberNotification.stories.tsx | 4 +- .../ChatSessionRefreshedDialog.stories.tsx | 4 +- ...atSessionRefreshedNotification.stories.tsx | 4 +- .../conversation/ContactDetail.stories.tsx | 4 +- .../conversation/ContactModal.stories.tsx | 4 +- .../ContactSpoofingReviewDialog.stories.tsx | 4 +- ...tactSpoofingReviewDialogPerson.stories.tsx | 4 +- .../ConversationHeader.stories.tsx | 4 +- .../conversation/ConversationHero.stories.tsx | 4 +- .../ConversationMergeNotification.stories.tsx | 4 +- .../DeliveryIssueDialog.stories.tsx | 4 +- .../DeliveryIssueNotification.stories.tsx | 4 +- .../conversation/ErrorBoundary.stories.tsx | 4 +- .../conversation/GroupDescription.stories.tsx | 4 +- .../GroupNotification.stories.tsx | 4 +- .../GroupV1DisabledActions.stories.tsx | 4 +- .../conversation/GroupV1Migration.stories.tsx | 4 +- .../conversation/GroupV2Change.stories.tsx | 4 +- .../GroupV2PendingApprovalActions.stories.tsx | 4 +- ts/components/conversation/Image.stories.tsx | 4 +- .../conversation/ImageGrid.stories.tsx | 4 +- .../JoinedSignalNotification.stories.tsx | 4 +- .../LastSeenIndicator.stories.tsx | 4 +- ...MandatoryProfileSharingActions.stories.tsx | 4 +- .../conversation/MessageBody.stories.tsx | 4 +- .../MessageBodyReadMore.stories.tsx | 4 +- .../conversation/MessageDetail.stories.tsx | 4 +- .../MessageRequestActions.stories.tsx | 4 +- .../conversation/MessageTimestamp.stories.tsx | 4 +- ...oneNumberDiscoveryNotification.stories.tsx | 4 +- .../ProfileChangeNotification.stories.tsx | 4 +- ts/components/conversation/Quote.stories.tsx | 4 +- .../conversation/ReactionPicker.stories.tsx | 4 +- .../conversation/ReactionViewer.stories.tsx | 4 +- .../ResetSessionNotification.stories.tsx | 4 +- .../SafetyNumberNotification.stories.tsx | 4 +- .../conversation/ScrollDownButton.stories.tsx | 4 +- .../StagedGenericAttachment.stories.tsx | 4 +- .../StagedLinkPreview.stories.tsx | 4 +- .../StagedPlaceholderAttachment.stories.tsx | 4 +- .../conversation/Timeline.stories.tsx | 4 +- .../TimelineFloatingHeader.stories.tsx | 4 +- .../conversation/TimelineItem.stories.tsx | 6 +- .../conversation/TimelineMessage.stories.tsx | 6 +- .../TimerNotification.stories.tsx | 4 +- .../TitleTransitionNotification.stories.tsx | 4 +- .../conversation/TypingAnimation.stories.tsx | 4 +- .../conversation/TypingBubble.stories.tsx | 4 +- .../UniversalTimerNotification.stories.tsx | 4 +- .../UnsupportedMessage.stories.tsx | 4 +- .../VerificationNotification.stories.tsx | 4 +- .../AddGroupMembersModal.stories.tsx | 4 +- .../ConversationDetails.stories.tsx | 4 +- .../ConversationDetailsActions.stories.tsx | 4 +- .../ConversationDetailsHeader.stories.tsx | 4 +- .../ConversationDetailsMediaList.stories.tsx | 4 +- ...versationDetailsMembershipList.stories.tsx | 4 +- ...versationNotificationsSettings.stories.tsx | 4 +- ...ditConversationAttributesModal.stories.tsx | 4 +- .../GroupLinkManagement.stories.tsx | 4 +- .../GroupV2Permissions.stories.tsx | 4 +- .../PendingInvites.stories.tsx | 4 +- .../AttachmentSection.stories.tsx | 4 +- .../media-gallery/MediaGallery.stories.tsx | 4 +- .../media-gallery/MediaGridItem.stories.tsx | 4 +- .../MessageSearchResult.stories.tsx | 4 +- ts/components/emoji/EmojiButton.stories.tsx | 4 +- ts/components/emoji/EmojiPicker.stories.tsx | 4 +- ts/components/fun/FunEmojiPicker.stories.tsx | 4 +- ts/components/fun/FunPicker.stories.tsx | 4 +- .../InstallScreenBackupImportStep.stories.tsx | 4 +- .../InstallScreenErrorStep.stories.tsx | 4 +- .../InstallScreenLinkInProgress.stories.tsx | 4 +- ...tallScreenQrCodeNotScannedStep.stories.tsx | 4 +- .../stickers/StickerButton.stories.tsx | 4 +- .../stickers/StickerManager.stories.tsx | 4 +- .../stickers/StickerPicker.stories.tsx | 4 +- .../stickers/StickerPreviewModal.stories.tsx | 4 +- ts/scripts/compile-stories-icu-lookup.ts | 69 ++++++++++++++++++ ts/state/ducks/user.ts | 2 + ts/types/Util.ts | 4 ++ ts/util/setupI18nMain.ts | 20 ++++++ 211 files changed, 503 insertions(+), 649 deletions(-) create mode 100644 .github/workflows/icu-book.yml create mode 100644 .storybook/icu-lookup.html create mode 100644 .storybook/test-runner.ts create mode 100644 ts/scripts/compile-stories-icu-lookup.ts diff --git a/.github/workflows/icu-book.yml b/.github/workflows/icu-book.yml new file mode 100644 index 000000000..33627f606 --- /dev/null +++ b/.github/workflows/icu-book.yml @@ -0,0 +1,61 @@ +# Copyright 2025 Signal Messenger, LLC +# SPDX-License-Identifier: AGPL-3.0-only +name: ICU Book +on: + workflow_dispatch: + push: + tags: + - 'v[0-9]+.[0-9]+.*' +jobs: + build-icu-book: + name: Build ICU Book + runs-on: ubuntu-latest-8-cores + if: ${{ github.repository == 'signalapp/Signal-Desktop-Private' }} + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Setup pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.3.0 + - name: Setup node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'pnpm' + cache-dependency-path: 'pnpm-lock.yaml' + - name: Cache .electron-gyp + uses: actions/cache@v4 + with: + path: ~/.electron-gyp + key: electron-gyp-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} + + - name: Setup sccache + uses: mozilla-actions/sccache-action@v0.0.7 + - name: Restore sccache + uses: actions/cache@v4 + id: cache-sccache + with: + path: ${{ env.SCCACHE_PATH }} + key: sccache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'patches/**') }} + + - name: Install Desktop node_modules + run: pnpm install + env: + CC: sccache gcc + CXX: sccache g++ + SCCACHE_GHA_ENABLED: "true" + NPM_CONFIG_LOGLEVEL: verbose + + - run: pnpm run build:storybook + - run: ./node_modules/.bin/playwright install chromium + - run: ./node_modules/.bin/run-p --race test:storybook:serve test:storybook:test + env: + ARTIFACTS_DIR: stories/data + - run: pnpm run build:esbuild + - run: node ts/scripts/compile-stories-icu-lookup.js stories + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: desktop-${{ github.ref_name }}-icu + path: stories diff --git a/.storybook/icu-lookup.html b/.storybook/icu-lookup.html new file mode 100644 index 000000000..89009f33f --- /dev/null +++ b/.storybook/icu-lookup.html @@ -0,0 +1,71 @@ + + + + + + + + Signal Desktop ICU + + + + +

+
+ + + + diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx index 5c3570459..e94760aa6 100644 --- a/.storybook/preview.tsx +++ b/.storybook/preview.tsx @@ -16,6 +16,7 @@ import { setupI18n } from '../ts/util/setupI18n'; import { HourCyclePreference } from '../ts/types/I18N'; import { Provider } from 'react-redux'; import { Store, combineReducers, createStore } from 'redux'; +import { Globals } from '@react-spring/web'; import { StateType } from '../ts/state/reducer'; import { ScrollerLockContext, @@ -130,6 +131,15 @@ window.SignalContext = { const result = parseUnknown(LocaleEmojiListSchema, json); return result; }, + + // For test-runner + _skipAnimation: () => { + Globals.assign({ + skipAnimation: true, + }); + }, + _trackICUStrings: () => i18n.trackUsage(), + _stopTrackingICUStrings: () => i18n.stopTrackingUsage(), }; window.i18n = i18n; diff --git a/.storybook/test-runner.ts b/.storybook/test-runner.ts new file mode 100644 index 000000000..dc8d34760 --- /dev/null +++ b/.storybook/test-runner.ts @@ -0,0 +1,52 @@ +// Copyright 2025 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import { mkdir, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import { + type TestRunnerConfig, + waitForPageReady, +} from '@storybook/test-runner'; + +const { ARTIFACTS_DIR } = process.env; + +const config: TestRunnerConfig = { + async preVisit(page) { + if (!ARTIFACTS_DIR) { + return; + } + + await page.evaluate('window.SignalContext._skipAnimation()'); + await page.evaluate('window.SignalContext._trackICUStrings()'); + }, + async postVisit(page, context) { + if (context.hasFailure) { + return; + } + if (!ARTIFACTS_DIR) { + return; + } + + await waitForPageReady(page); + + const result = await page.evaluate( + 'window.SignalContext._stopTrackingICUStrings()' + ); + + // No strings - no file + if (result.length === 0) { + return; + } + + const image = await page.screenshot({ fullPage: true }); + + const dir = join(ARTIFACTS_DIR, context.id); + await mkdir(dir, { recursive: true }); + + await Promise.all([ + writeFile(join(dir, 'screenshot.png'), image), + writeFile(join(dir, 'strings.json'), JSON.stringify(result)), + ]); + }, +}; +export default config; diff --git a/package.json b/package.json index 0fbd907c4..e947632f7 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "build:storybook": "pnpm run build-protobuf && cross-env SIGNAL_ENV=storybook storybook build", "test:storybook": "pnpm run build:storybook && run-p --race test:storybook:*", "test:storybook:serve": "http-server storybook-static --port 6006 --silent", - "test:storybook:test": "wait-on http://127.0.0.1:6006/ --timeout 5000 && test-storybook", + "test:storybook:test": "wait-on http://127.0.0.1:6006/ --timeout 5000 && test-storybook --testTimeout 60000", "build": "run-s --print-label generate build:esbuild:prod build:release", "build-win32-all": "run-s --print-label generate build:esbuild:prod build:release-win32-all", "build-linux": "run-s generate build:esbuild:prod && pnpm run build:release --publish=never", @@ -236,7 +236,7 @@ "@storybook/react": "8.4.4", "@storybook/react-webpack5": "8.4.4", "@storybook/test": "8.4.4", - "@storybook/test-runner": "0.19.1", + "@storybook/test-runner": "0.22.0", "@storybook/types": "8.1.11", "@types/backbone": "1.4.22", "@types/blueimp-load-image": "5.16.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index eeae08a05..1931b07ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -477,8 +477,8 @@ importers: specifier: 8.4.4 version: 8.4.4(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10)) '@storybook/test-runner': - specifier: 0.19.1 - version: 0.19.1(@swc/helpers@0.5.15)(@types/node@20.17.6)(debug@4.3.7)(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))(ts-node@10.9.2(@swc/core@1.10.16(@swc/helpers@0.5.15))(@types/node@20.17.6)(typescript@5.6.3)) + specifier: 0.22.0 + version: 0.22.0(@swc/helpers@0.5.15)(@types/node@20.17.6)(debug@4.3.7)(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))(ts-node@10.9.2(@swc/core@1.10.16(@swc/helpers@0.5.15))(@types/node@20.17.6)(typescript@5.6.3)) '@storybook/types': specifier: 8.1.11 version: 8.1.11 @@ -2642,11 +2642,6 @@ packages: peerDependencies: storybook: ^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0 - '@storybook/core-common@8.5.5': - resolution: {integrity: sha512-CxNfFMMXTCta9GiyhIXIYkbyHZz2owbJV1slIxcQgQVkodN4iyroY0mOps8o2ArE9v8tApumdiFv/NoDprsh4A==} - peerDependencies: - storybook: ^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0 - '@storybook/core-events@8.1.11': resolution: {integrity: sha512-vXaNe2KEW9BGlLrg0lzmf5cJ0xt+suPjWmEODH5JqBbrdZ67X6ApA2nb6WcxDQhykesWCuFN5gp1l+JuDOBi7A==} @@ -2663,11 +2658,6 @@ packages: prettier: optional: true - '@storybook/csf-tools@8.5.5': - resolution: {integrity: sha512-Aw1bhfFIhDF1uKykDWcmdYf5R0pxfF1/1ig2UcjQrfH20EoPRKN666DlwHiJjdtvFzQlhemh3T1FqCvkI6pR6A==} - peerDependencies: - storybook: ^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0 - '@storybook/csf@0.1.11': resolution: {integrity: sha512-dHYFQH3mA+EtnCkHXzicbLgsvzYjcDJ1JWsogbItZogkPHgSJM/Wr71uMkcvw8v9mmCyP4NpXJuu6bPoVsOnzg==} @@ -2741,10 +2731,12 @@ packages: typescript: optional: true - '@storybook/test-runner@0.19.1': - resolution: {integrity: sha512-Nc4djXw3Lv3AAXg6TJ7yVTeuMryjMsTDd8GCbE/PStU602rpe8syEqElz78GPoJqB1VYWQ3T9pcu93MKyHT+xQ==} + '@storybook/test-runner@0.22.0': + resolution: {integrity: sha512-fKY6MTE/bcvMaulKXy+z0fPmRXJx1REkYMOMcGn8zn6uffyBigGgaVf/sZ+AZfibwvjzg/StWhJ9HvAM8pc14g==} engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} hasBin: true + peerDependencies: + storybook: ^0.0.0-0 || ^8.2.0 || ^8.3.0-0 || ^8.4.0-0 || ^8.5.0-0 || ^8.6.0-0 || ^9.0.0-0 '@storybook/test@8.4.4': resolution: {integrity: sha512-tmJd+lxl3MC0Xdu1KW/69V8tibv98OvdopxGqfVR0x5dkRHM3sFK/tv1ZJAUeronlvRyhGySOu1tHUrMjcNqyA==} @@ -12453,10 +12445,6 @@ snapshots: dependencies: storybook: 8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10) - '@storybook/core-common@8.5.5(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))': - dependencies: - storybook: 8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10) - '@storybook/core-events@8.1.11': dependencies: '@storybook/csf': 0.1.11 @@ -12488,10 +12476,6 @@ snapshots: - supports-color - utf-8-validate - '@storybook/csf-tools@8.5.5(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))': - dependencies: - storybook: 8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10) - '@storybook/csf@0.1.11': dependencies: type-fest: 2.19.0 @@ -12594,17 +12578,14 @@ snapshots: '@storybook/test': 8.4.4(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10)) typescript: 5.6.3 - '@storybook/test-runner@0.19.1(@swc/helpers@0.5.15)(@types/node@20.17.6)(debug@4.3.7)(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))(ts-node@10.9.2(@swc/core@1.10.16(@swc/helpers@0.5.15))(@types/node@20.17.6)(typescript@5.6.3))': + '@storybook/test-runner@0.22.0(@swc/helpers@0.5.15)(@types/node@20.17.6)(debug@4.3.7)(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10))(ts-node@10.9.2(@swc/core@1.10.16(@swc/helpers@0.5.15))(@types/node@20.17.6)(typescript@5.6.3))': dependencies: '@babel/core': 7.26.0 '@babel/generator': 7.26.8 '@babel/template': 7.26.8 '@babel/types': 7.26.8 '@jest/types': 29.6.3 - '@storybook/core-common': 8.5.5(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10)) '@storybook/csf': 0.1.11 - '@storybook/csf-tools': 8.5.5(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10)) - '@storybook/preview-api': 8.4.4(storybook@8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10)) '@swc/core': 1.10.16(@swc/helpers@0.5.15) '@swc/jest': 0.2.37(@swc/core@1.10.16(@swc/helpers@0.5.15)) expect-playwright: 0.8.0 @@ -12618,13 +12599,13 @@ snapshots: jest-watch-typeahead: 2.2.2(jest@29.7.0(@types/node@20.17.6)(ts-node@10.9.2(@swc/core@1.10.16(@swc/helpers@0.5.15))(@types/node@20.17.6)(typescript@5.6.3))) nyc: 15.1.0 playwright: 1.45.0 + storybook: 8.4.4(bufferutil@4.0.9)(prettier@3.3.3)(utf-8-validate@5.0.10) transitivePeerDependencies: - '@swc/helpers' - '@types/node' - babel-plugin-macros - debug - node-notifier - - storybook - supports-color - ts-node @@ -20933,7 +20914,7 @@ snapshots: wide-align@1.1.5: dependencies: - string-width: 1.0.2 + string-width: 4.2.3 widest-line@2.0.1: dependencies: diff --git a/ts/components/About.stories.tsx b/ts/components/About.stories.tsx index 36330070e..6a0ce6727 100644 --- a/ts/components/About.stories.tsx +++ b/ts/components/About.stories.tsx @@ -3,13 +3,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { ComponentMeta } from '../storybook/types'; import type { AboutProps } from './About'; import { About } from './About'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/About', diff --git a/ts/components/AddGroupMemberErrorDialog.stories.tsx b/ts/components/AddGroupMemberErrorDialog.stories.tsx index 5db6945b6..f0a333be9 100644 --- a/ts/components/AddGroupMemberErrorDialog.stories.tsx +++ b/ts/components/AddGroupMemberErrorDialog.stories.tsx @@ -6,15 +6,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './AddGroupMemberErrorDialog'; import { AddGroupMemberErrorDialog, AddGroupMemberErrorDialogMode, } from './AddGroupMemberErrorDialog'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/AddGroupMemberErrorDialog', diff --git a/ts/components/AddUserToAnotherGroupModal.stories.tsx b/ts/components/AddUserToAnotherGroupModal.stories.tsx index 85a1e09be..e1312da0c 100644 --- a/ts/components/AddUserToAnotherGroupModal.stories.tsx +++ b/ts/components/AddUserToAnotherGroupModal.stories.tsx @@ -6,15 +6,13 @@ import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import type { Props } from './AddUserToAnotherGroupModal'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation, getDefaultGroup, } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { AddUserToAnotherGroupModal } from './AddUserToAnotherGroupModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/AddUserToAnotherGroupModal', diff --git a/ts/components/Alert.stories.tsx b/ts/components/Alert.stories.tsx index 272b6af0d..f0e86c2fa 100644 --- a/ts/components/Alert.stories.tsx +++ b/ts/components/Alert.stories.tsx @@ -4,12 +4,10 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './Alert'; import { Alert } from './Alert'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Alert', diff --git a/ts/components/AttachmentNotAvailableModal.stories.tsx b/ts/components/AttachmentNotAvailableModal.stories.tsx index 5854a2139..ce65c049d 100644 --- a/ts/components/AttachmentNotAvailableModal.stories.tsx +++ b/ts/components/AttachmentNotAvailableModal.stories.tsx @@ -3,8 +3,6 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './AttachmentNotAvailableModal'; import { AttachmentNotAvailableModal, @@ -12,7 +10,7 @@ import { } from './AttachmentNotAvailableModal'; import type { ComponentMeta } from '../storybook/types'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/AttachmentNotAvailableModal', diff --git a/ts/components/Avatar.stories.tsx b/ts/components/Avatar.stories.tsx index 546b85a5e..996011133 100644 --- a/ts/components/Avatar.stories.tsx +++ b/ts/components/Avatar.stories.tsx @@ -8,15 +8,13 @@ import { isBoolean } from 'lodash'; import { expect, fn, within, userEvent } from '@storybook/test'; import type { AvatarColorType } from '../types/Colors'; import type { Props } from './Avatar'; -import enMessages from '../../_locales/en/messages.json'; import { Avatar, AvatarBlur, AvatarSize } from './Avatar'; import { AvatarColors } from '../types/Colors'; import { HasStories } from '../types/Stories'; import { ThemeType } from '../types/Util'; import { getFakeBadge } from '../test-both/helpers/getFakeBadge'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Avatar', diff --git a/ts/components/AvatarColorPicker.stories.tsx b/ts/components/AvatarColorPicker.stories.tsx index 43e03caa3..a3a618649 100644 --- a/ts/components/AvatarColorPicker.stories.tsx +++ b/ts/components/AvatarColorPicker.stories.tsx @@ -5,14 +5,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './AvatarColorPicker'; import { AvatarColorPicker } from './AvatarColorPicker'; import { AvatarColors } from '../types/Colors'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ i18n, diff --git a/ts/components/AvatarEditor.stories.tsx b/ts/components/AvatarEditor.stories.tsx index 659d71412..6b4f32d01 100644 --- a/ts/components/AvatarEditor.stories.tsx +++ b/ts/components/AvatarEditor.stories.tsx @@ -5,16 +5,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import { AvatarColors } from '../types/Colors'; import type { PropsType } from './AvatarEditor'; import { AvatarEditor } from './AvatarEditor'; import { getDefaultAvatars } from '../types/Avatar'; import { createAvatarData } from '../util/createAvatarData'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ avatarColor: overrideProps.avatarColor || AvatarColors[9], diff --git a/ts/components/AvatarIconEditor.stories.tsx b/ts/components/AvatarIconEditor.stories.tsx index 8caeab8b6..6804d1f5d 100644 --- a/ts/components/AvatarIconEditor.stories.tsx +++ b/ts/components/AvatarIconEditor.stories.tsx @@ -5,16 +5,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './AvatarIconEditor'; import { AvatarIconEditor } from './AvatarIconEditor'; import { GroupAvatarIcons, PersonalAvatarIcons } from '../types/Avatar'; import { AvatarColors } from '../types/Colors'; import { createAvatarData } from '../util/createAvatarData'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ avatarData: overrideProps.avatarData || createAvatarData({}), diff --git a/ts/components/AvatarLightbox.stories.tsx b/ts/components/AvatarLightbox.stories.tsx index b2a5bf65a..837c77ebc 100644 --- a/ts/components/AvatarLightbox.stories.tsx +++ b/ts/components/AvatarLightbox.stories.tsx @@ -4,14 +4,12 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import { AvatarColors } from '../types/Colors'; import type { PropsType } from './AvatarLightbox'; import { AvatarLightbox } from './AvatarLightbox'; -import { setupI18n } from '../util/setupI18n'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/AvatarLightbox', diff --git a/ts/components/AvatarModalButtons.stories.tsx b/ts/components/AvatarModalButtons.stories.tsx index 10005459e..8a5bb7fbb 100644 --- a/ts/components/AvatarModalButtons.stories.tsx +++ b/ts/components/AvatarModalButtons.stories.tsx @@ -6,12 +6,10 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './AvatarModalButtons'; import { AvatarModalButtons } from './AvatarModalButtons'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ hasChanges: Boolean(overrideProps.hasChanges), diff --git a/ts/components/AvatarPreview.stories.tsx b/ts/components/AvatarPreview.stories.tsx index 465bcb314..b394ba663 100644 --- a/ts/components/AvatarPreview.stories.tsx +++ b/ts/components/AvatarPreview.stories.tsx @@ -10,10 +10,8 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './AvatarPreview'; import { AvatarPreview } from './AvatarPreview'; import { AvatarColors } from '../types/Colors'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const TEST_IMAGE = new Uint8Array( chunk( diff --git a/ts/components/AvatarTextEditor.stories.tsx b/ts/components/AvatarTextEditor.stories.tsx index 8058bb776..93f08e835 100644 --- a/ts/components/AvatarTextEditor.stories.tsx +++ b/ts/components/AvatarTextEditor.stories.tsx @@ -5,14 +5,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './AvatarTextEditor'; import { AvatarTextEditor } from './AvatarTextEditor'; import { AvatarColors } from '../types/Colors'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ avatarData: overrideProps.avatarData, diff --git a/ts/components/AvatarUploadButton.stories.tsx b/ts/components/AvatarUploadButton.stories.tsx index 6a866de04..15eea3e4e 100644 --- a/ts/components/AvatarUploadButton.stories.tsx +++ b/ts/components/AvatarUploadButton.stories.tsx @@ -5,13 +5,10 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './AvatarUploadButton'; import { AvatarUploadButton } from './AvatarUploadButton'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ className: overrideProps.className || '', diff --git a/ts/components/BackupMediaDownloadProgress.stories.tsx b/ts/components/BackupMediaDownloadProgress.stories.tsx index b1b1aba40..b16f1770d 100644 --- a/ts/components/BackupMediaDownloadProgress.stories.tsx +++ b/ts/components/BackupMediaDownloadProgress.stories.tsx @@ -5,12 +5,10 @@ import React, { type ComponentProps } from 'react'; import type { Meta } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { BackupMediaDownloadProgress } from './BackupMediaDownloadProgress'; import { KIBIBYTE } from '../types/AttachmentSize'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type PropsType = ComponentProps; diff --git a/ts/components/BadgeDialog.stories.tsx b/ts/components/BadgeDialog.stories.tsx index c45deeea0..2313bbdb0 100644 --- a/ts/components/BadgeDialog.stories.tsx +++ b/ts/components/BadgeDialog.stories.tsx @@ -6,15 +6,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { getFakeBadge, getFakeBadges } from '../test-both/helpers/getFakeBadge'; import { repeat, zipObject } from '../util/iterables'; import { BadgeImageTheme } from '../badges/BadgeImageTheme'; import type { PropsType } from './BadgeDialog'; import { BadgeDialog } from './BadgeDialog'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/BadgeDialog', diff --git a/ts/components/BetterAvatar.stories.tsx b/ts/components/BetterAvatar.stories.tsx index 6a15a926f..fd48b8329 100644 --- a/ts/components/BetterAvatar.stories.tsx +++ b/ts/components/BetterAvatar.stories.tsx @@ -6,15 +6,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import { AvatarColors } from '../types/Colors'; import { GroupAvatarIcons, PersonalAvatarIcons } from '../types/Avatar'; import type { PropsType } from './BetterAvatar'; import { BetterAvatar } from './BetterAvatar'; import { createAvatarData } from '../util/createAvatarData'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ avatarData: diff --git a/ts/components/BetterAvatarBubble.stories.tsx b/ts/components/BetterAvatarBubble.stories.tsx index c4fa5f1de..4d08eb22e 100644 --- a/ts/components/BetterAvatarBubble.stories.tsx +++ b/ts/components/BetterAvatarBubble.stories.tsx @@ -6,13 +6,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import { AvatarColors } from '../types/Colors'; import type { PropsType } from './BetterAvatarBubble'; import { BetterAvatarBubble } from './BetterAvatarBubble'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ children: overrideProps.children, diff --git a/ts/components/CallLinkAddNameModal.stories.tsx b/ts/components/CallLinkAddNameModal.stories.tsx index 1f1516637..8ba514359 100644 --- a/ts/components/CallLinkAddNameModal.stories.tsx +++ b/ts/components/CallLinkAddNameModal.stories.tsx @@ -3,14 +3,12 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { CallLinkAddNameModalProps } from './CallLinkAddNameModal'; import { CallLinkAddNameModal } from './CallLinkAddNameModal'; import type { ComponentMeta } from '../storybook/types'; import { FAKE_CALL_LINK_WITH_ADMIN_KEY } from '../test-both/helpers/fakeCallLink'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallLinkAddNameModal', diff --git a/ts/components/CallLinkDetails.stories.tsx b/ts/components/CallLinkDetails.stories.tsx index 734430b5e..a6df12bc0 100644 --- a/ts/components/CallLinkDetails.stories.tsx +++ b/ts/components/CallLinkDetails.stories.tsx @@ -5,15 +5,13 @@ import { action } from '@storybook/addon-actions'; import type { ComponentMeta } from '../storybook/types'; import type { CallLinkDetailsProps } from './CallLinkDetails'; import { CallLinkDetails } from './CallLinkDetails'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { FAKE_CALL_LINK, FAKE_CALL_LINK_WITH_ADMIN_KEY, } from '../test-both/helpers/fakeCallLink'; import { getFakeCallLinkHistoryGroup } from '../test-both/helpers/getFakeCallHistoryGroup'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallLinkDetails', diff --git a/ts/components/CallLinkEditModal.stories.tsx b/ts/components/CallLinkEditModal.stories.tsx index 6cb5bd54f..51b5b70c4 100644 --- a/ts/components/CallLinkEditModal.stories.tsx +++ b/ts/components/CallLinkEditModal.stories.tsx @@ -3,14 +3,12 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { CallLinkEditModalProps } from './CallLinkEditModal'; import { CallLinkEditModal } from './CallLinkEditModal'; import type { ComponentMeta } from '../storybook/types'; import { FAKE_CALL_LINK_WITH_ADMIN_KEY } from '../test-both/helpers/fakeCallLink'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallLinkEditModal', diff --git a/ts/components/CallLinkPendingParticipantModal.stories.tsx b/ts/components/CallLinkPendingParticipantModal.stories.tsx index 35ae9f01d..765afc796 100644 --- a/ts/components/CallLinkPendingParticipantModal.stories.tsx +++ b/ts/components/CallLinkPendingParticipantModal.stories.tsx @@ -3,14 +3,12 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { CallLinkPendingParticipantModalProps } from './CallLinkPendingParticipantModal'; import { CallLinkPendingParticipantModal } from './CallLinkPendingParticipantModal'; import type { ComponentMeta } from '../storybook/types'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversation = getDefaultConversation({ acceptedMessageRequest: true, diff --git a/ts/components/CallManager.stories.tsx b/ts/components/CallManager.stories.tsx index 37b402aed..5c4787ddc 100644 --- a/ts/components/CallManager.stories.tsx +++ b/ts/components/CallManager.stories.tsx @@ -26,8 +26,6 @@ import { AvatarColors } from '../types/Colors'; import { generateAci } from '../types/ServiceId'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { StorySendMode } from '../types/Stories'; import { FAKE_CALL_LINK, @@ -37,7 +35,7 @@ import { import { allRemoteParticipants } from './CallScreen.stories'; import { getPlaceholderContact } from '../state/selectors/conversations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const getConversation = () => getDefaultConversation({ diff --git a/ts/components/CallNeedPermissionScreen.stories.tsx b/ts/components/CallNeedPermissionScreen.stories.tsx index 42e684984..97ce31062 100644 --- a/ts/components/CallNeedPermissionScreen.stories.tsx +++ b/ts/components/CallNeedPermissionScreen.stories.tsx @@ -4,13 +4,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { Props } from './CallNeedPermissionScreen'; import { CallNeedPermissionScreen } from './CallNeedPermissionScreen'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallNeedPermissionScreen', diff --git a/ts/components/CallScreen.stories.tsx b/ts/components/CallScreen.stories.tsx index 120c9b7f8..f3b51ab10 100644 --- a/ts/components/CallScreen.stories.tsx +++ b/ts/components/CallScreen.stories.tsx @@ -24,14 +24,12 @@ import { AvatarColors } from '../types/Colors'; import type { PropsType } from './CallScreen'; import { CallScreen as UnwrappedCallScreen } from './CallScreen'; import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../reactions/constants'; -import { setupI18n } from '../util/setupI18n'; import { missingCaseError } from '../util/missingCaseError'; import { getDefaultConversation, getDefaultConversationWithServiceId, } from '../test-both/helpers/getDefaultConversation'; import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource'; -import enMessages from '../../_locales/en/messages.json'; import { CallingToastProvider, useCallingToasts } from './CallingToast'; import type { CallingImageDataCache } from './CallManager'; import { MINUTE } from '../util/durations'; @@ -39,7 +37,7 @@ import { MINUTE } from '../util/durations'; const MAX_PARTICIPANTS = 75; const LOCAL_DEMUX_ID = 1; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversation = getDefaultConversation({ id: '3051234567', diff --git a/ts/components/CallingAdhocCallInfo.stories.tsx b/ts/components/CallingAdhocCallInfo.stories.tsx index 48c0b8c59..7ed364482 100644 --- a/ts/components/CallingAdhocCallInfo.stories.tsx +++ b/ts/components/CallingAdhocCallInfo.stories.tsx @@ -12,12 +12,10 @@ import { AvatarColors } from '../types/Colors'; import type { GroupCallRemoteParticipantType } from '../types/Calling'; import { generateAci } from '../types/ServiceId'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { CallLinkType } from '../types/CallLink'; import { CallLinkRestrictions } from '../types/CallLink'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const OUR_ACI = generateAci(); diff --git a/ts/components/CallingButton.stories.tsx b/ts/components/CallingButton.stories.tsx index 4d51cdf70..71014d607 100644 --- a/ts/components/CallingButton.stories.tsx +++ b/ts/components/CallingButton.stories.tsx @@ -7,10 +7,8 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './CallingButton'; import { CallingButton, CallingButtonType } from './CallingButton'; import { TooltipPlacement } from './Tooltip'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallingButton', diff --git a/ts/components/CallingDeviceSelection.stories.tsx b/ts/components/CallingDeviceSelection.stories.tsx index c75828e1c..218e6eb1e 100644 --- a/ts/components/CallingDeviceSelection.stories.tsx +++ b/ts/components/CallingDeviceSelection.stories.tsx @@ -7,10 +7,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './CallingDeviceSelection'; import { CallingDeviceSelection } from './CallingDeviceSelection'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const audioDevice = { name: '', diff --git a/ts/components/CallingHeader.stories.tsx b/ts/components/CallingHeader.stories.tsx index ee377143e..2046df68d 100644 --- a/ts/components/CallingHeader.stories.tsx +++ b/ts/components/CallingHeader.stories.tsx @@ -6,11 +6,9 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './CallingHeader'; import { CallingHeader } from './CallingHeader'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { CallViewMode } from '../types/Calling'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CallingHeader', diff --git a/ts/components/CallingLobby.stories.tsx b/ts/components/CallingLobby.stories.tsx index f1aa9ebaa..66a8dc864 100644 --- a/ts/components/CallingLobby.stories.tsx +++ b/ts/components/CallingLobby.stories.tsx @@ -11,9 +11,7 @@ import { AvatarColors } from '../types/Colors'; import type { ConversationType } from '../state/ducks/conversations'; import type { PropsType } from './CallingLobby'; import { CallingLobby as UnwrappedCallingLobby } from './CallingLobby'; -import { setupI18n } from '../util/setupI18n'; import { generateAci } from '../types/ServiceId'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation, getDefaultConversationWithServiceId, @@ -22,7 +20,7 @@ import { CallingToastProvider } from './CallingToast'; import { CallMode } from '../types/CallDisposition'; import { getDefaultCallLinkConversation } from '../test-both/helpers/fakeCallLink'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const camera = { deviceId: 'dfbe6effe70b0611ba0fdc2a9ea3f39f6cb110e6687948f7e5f016c111b7329c', diff --git a/ts/components/CallingParticipantsList.stories.tsx b/ts/components/CallingParticipantsList.stories.tsx index 8ddce02a8..4658b7373 100644 --- a/ts/components/CallingParticipantsList.stories.tsx +++ b/ts/components/CallingParticipantsList.stories.tsx @@ -12,10 +12,8 @@ import { AvatarColors } from '../types/Colors'; import type { GroupCallRemoteParticipantType } from '../types/Calling'; import { generateAci } from '../types/ServiceId'; import { getDefaultConversationWithServiceId } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; function createParticipant( participantProps: Partial diff --git a/ts/components/CallingPendingParticipants.stories.tsx b/ts/components/CallingPendingParticipants.stories.tsx index c33b17791..597a9e926 100644 --- a/ts/components/CallingPendingParticipants.stories.tsx +++ b/ts/components/CallingPendingParticipants.stories.tsx @@ -6,11 +6,9 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './CallingPendingParticipants'; import { CallingPendingParticipants } from './CallingPendingParticipants'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { allRemoteParticipants } from './CallScreen.stories'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (storyProps: Partial = {}): PropsType => ({ i18n, diff --git a/ts/components/CallingPip.stories.tsx b/ts/components/CallingPip.stories.tsx index 9f1aab545..f82e31888 100644 --- a/ts/components/CallingPip.stories.tsx +++ b/ts/components/CallingPip.stories.tsx @@ -19,11 +19,9 @@ import { import { CallMode } from '../types/CallDisposition'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { MINUTE } from '../util/durations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversation: ConversationType = getDefaultConversation({ id: '3051234567', diff --git a/ts/components/CallingPreCallInfo.stories.tsx b/ts/components/CallingPreCallInfo.stories.tsx index a445d1eb0..3f8cb3e96 100644 --- a/ts/components/CallingPreCallInfo.stories.tsx +++ b/ts/components/CallingPreCallInfo.stories.tsx @@ -4,8 +4,6 @@ import React from 'react'; import { times } from 'lodash'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import type { PropsType } from './CallingPreCallInfo'; import { CallingPreCallInfo, RingMode } from './CallingPreCallInfo'; @@ -15,7 +13,7 @@ import { generateAci } from '../types/ServiceId'; import { FAKE_CALL_LINK } from '../test-both/helpers/fakeCallLink'; import { callLinkToConversation } from '../util/callLinks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const getDefaultGroupConversation = () => getDefaultConversation({ name: 'Tahoe Trip', diff --git a/ts/components/CallingRaisedHandsList.stories.tsx b/ts/components/CallingRaisedHandsList.stories.tsx index ca242a885..f34f34489 100644 --- a/ts/components/CallingRaisedHandsList.stories.tsx +++ b/ts/components/CallingRaisedHandsList.stories.tsx @@ -17,8 +17,6 @@ import { import type { ConversationType } from '../state/ducks/conversations'; import { AvatarColors } from '../types/Colors'; import { getDefaultConversationWithServiceId } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; const MAX_HANDS = 20; const LOCAL_DEMUX_ID = 1; @@ -31,7 +29,7 @@ const NAMES = [ 'Kiki', ]; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversation = getDefaultConversationWithServiceId({ id: '3051234567', diff --git a/ts/components/CallingScreenSharingController.stories.tsx b/ts/components/CallingScreenSharingController.stories.tsx index d55fba16f..463c5de21 100644 --- a/ts/components/CallingScreenSharingController.stories.tsx +++ b/ts/components/CallingScreenSharingController.stories.tsx @@ -8,11 +8,9 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './CallingScreenSharingController'; import { CallingScreenSharingController } from './CallingScreenSharingController'; -import { setupI18n } from '../util/setupI18n'; import { ScreenShareStatus } from '../types/Calling'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ i18n, diff --git a/ts/components/CallingSelectPresentingSourcesModal.stories.tsx b/ts/components/CallingSelectPresentingSourcesModal.stories.tsx index d66c7e44e..efa671c8f 100644 --- a/ts/components/CallingSelectPresentingSourcesModal.stories.tsx +++ b/ts/components/CallingSelectPresentingSourcesModal.stories.tsx @@ -8,10 +8,7 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './CallingSelectPresentingSourcesModal'; import { CallingSelectPresentingSourcesModal } from './CallingSelectPresentingSourcesModal'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): PropsType => ({ i18n, diff --git a/ts/components/CaptchaDialog.stories.tsx b/ts/components/CaptchaDialog.stories.tsx index d9071414d..b84d55b7e 100644 --- a/ts/components/CaptchaDialog.stories.tsx +++ b/ts/components/CaptchaDialog.stories.tsx @@ -7,10 +7,8 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './CaptchaDialog'; import { CaptchaDialog } from './CaptchaDialog'; import { Button } from './Button'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CaptchaDialog', diff --git a/ts/components/ChatColorPicker.stories.tsx b/ts/components/ChatColorPicker.stories.tsx index c8b534115..f629df4e1 100644 --- a/ts/components/ChatColorPicker.stories.tsx +++ b/ts/components/ChatColorPicker.stories.tsx @@ -4,13 +4,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './ChatColorPicker'; import { ChatColorPicker } from './ChatColorPicker'; import { ConversationColors } from '../types/Colors'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ChatColorPicker', diff --git a/ts/components/ChatsTab.stories.tsx b/ts/components/ChatsTab.stories.tsx index 38306c2df..bf790200e 100644 --- a/ts/components/ChatsTab.stories.tsx +++ b/ts/components/ChatsTab.stories.tsx @@ -3,13 +3,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { ComponentMeta } from '../storybook/types'; import type { ChatsTabProps } from './ChatsTab'; import { ChatsTab } from './ChatsTab'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ChatsTab', diff --git a/ts/components/ClearingData.stories.tsx b/ts/components/ClearingData.stories.tsx index e6e183f84..cf9f6121c 100644 --- a/ts/components/ClearingData.stories.tsx +++ b/ts/components/ClearingData.stories.tsx @@ -4,12 +4,10 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './ClearingData'; import { ClearingData } from './ClearingData'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ClearingData', diff --git a/ts/components/CollidingAvatars.stories.tsx b/ts/components/CollidingAvatars.stories.tsx index 4d5cff1d5..b78b42cc4 100644 --- a/ts/components/CollidingAvatars.stories.tsx +++ b/ts/components/CollidingAvatars.stories.tsx @@ -5,11 +5,9 @@ import React from 'react'; import type { PropsType } from './CollidingAvatars'; import { CollidingAvatars } from './CollidingAvatars'; import { type ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const alice = getDefaultConversation(); const bob = getDefaultConversation(); diff --git a/ts/components/CompositionArea.stories.tsx b/ts/components/CompositionArea.stories.tsx index 756975898..a81e15a87 100644 --- a/ts/components/CompositionArea.stories.tsx +++ b/ts/components/CompositionArea.stories.tsx @@ -7,8 +7,6 @@ import type { Meta } from '@storybook/react'; import { IMAGE_JPEG } from '../types/MIME'; import type { Props } from './CompositionArea'; import { CompositionArea } from './CompositionArea'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { fakeDraftAttachment } from '../test-both/helpers/fakeAttachment'; @@ -18,7 +16,7 @@ import { ConversationColors } from '../types/Colors'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { PaymentEventKind } from '../types/Payment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CompositionArea', diff --git a/ts/components/CompositionInput.stories.tsx b/ts/components/CompositionInput.stories.tsx index e31c979bf..fff8d0f4f 100644 --- a/ts/components/CompositionInput.stories.tsx +++ b/ts/components/CompositionInput.stories.tsx @@ -9,12 +9,10 @@ import type { Meta } from '@storybook/react'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import type { Props } from './CompositionInput'; import { CompositionInput } from './CompositionInput'; -import { setupI18n } from '../util/setupI18n'; import { generateAci } from '../types/ServiceId'; -import enMessages from '../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CompositionInput', diff --git a/ts/components/CompositionRecording.stories.tsx b/ts/components/CompositionRecording.stories.tsx index 868c02979..3c7b7f06c 100644 --- a/ts/components/CompositionRecording.stories.tsx +++ b/ts/components/CompositionRecording.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './CompositionRecording'; import { CompositionRecording } from './CompositionRecording'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'components/CompositionRecording', diff --git a/ts/components/CompositionRecordingDraft.stories.tsx b/ts/components/CompositionRecordingDraft.stories.tsx index ac5969670..e7720b270 100644 --- a/ts/components/CompositionRecordingDraft.stories.tsx +++ b/ts/components/CompositionRecordingDraft.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './CompositionRecordingDraft'; import { CompositionRecordingDraft } from './CompositionRecordingDraft'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'components/CompositionRecordingDraft', diff --git a/ts/components/ConfirmDiscardDialog.stories.tsx b/ts/components/ConfirmDiscardDialog.stories.tsx index 04ef5da27..2ed1bae7f 100644 --- a/ts/components/ConfirmDiscardDialog.stories.tsx +++ b/ts/components/ConfirmDiscardDialog.stories.tsx @@ -5,13 +5,10 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './ConfirmDiscardDialog'; import { ConfirmDiscardDialog } from './ConfirmDiscardDialog'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): PropsType => ({ i18n, diff --git a/ts/components/ConfirmationDialog.stories.tsx b/ts/components/ConfirmationDialog.stories.tsx index 629e19e1f..507f942da 100644 --- a/ts/components/ConfirmationDialog.stories.tsx +++ b/ts/components/ConfirmationDialog.stories.tsx @@ -7,10 +7,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './ConfirmationDialog'; import { ConfirmationDialog } from './ConfirmationDialog'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ConfirmationDialog', diff --git a/ts/components/ContactPills.stories.tsx b/ts/components/ContactPills.stories.tsx index f13f587d7..49f2f2148 100644 --- a/ts/components/ContactPills.stories.tsx +++ b/ts/components/ContactPills.stories.tsx @@ -7,15 +7,13 @@ import { times } from 'lodash'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { ContactPills } from './ContactPills'; import type { PropsType as ContactPillPropsType } from './ContactPill'; import { ContactPill } from './ContactPill'; import { gifUrl } from '../storybook/Fixtures'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Contact Pills', diff --git a/ts/components/ContextMenu.stories.tsx b/ts/components/ContextMenu.stories.tsx index cdb4e70f3..89d6ea7a3 100644 --- a/ts/components/ContextMenu.stories.tsx +++ b/ts/components/ContextMenu.stories.tsx @@ -7,10 +7,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './ContextMenu'; import { ContextMenu } from './ContextMenu'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ContextMenu', diff --git a/ts/components/ConversationList.stories.tsx b/ts/components/ConversationList.stories.tsx index 73dcbbbdc..e77ef9df9 100644 --- a/ts/components/ConversationList.stories.tsx +++ b/ts/components/ConversationList.stories.tsx @@ -13,13 +13,11 @@ import type { PropsData as ConversationListItemPropsType } from './conversationL import { MessageStatuses } from './conversationList/ConversationListItem'; import { ContactCheckboxDisabledReason } from './conversationList/ContactCheckbox'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { ThemeType } from '../types/Util'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { makeFakeLookupConversationWithoutServiceId } from '../test-both/helpers/fakeLookupConversationWithoutServiceId'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ConversationList', diff --git a/ts/components/CountryCodeSelect.stories.tsx b/ts/components/CountryCodeSelect.stories.tsx index 8a9d8da69..f77228162 100644 --- a/ts/components/CountryCodeSelect.stories.tsx +++ b/ts/components/CountryCodeSelect.stories.tsx @@ -5,10 +5,8 @@ import React, { useState } from 'react'; import type { PropsType } from './CountryCodeSelect'; import { CountryCodeSelect } from './CountryCodeSelect'; import { type ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type StoryPropsType = Omit; diff --git a/ts/components/CrashReportDialog.stories.tsx b/ts/components/CrashReportDialog.stories.tsx index 114abfeda..ffe188fdf 100644 --- a/ts/components/CrashReportDialog.stories.tsx +++ b/ts/components/CrashReportDialog.stories.tsx @@ -7,15 +7,13 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './CrashReportDialog'; import { CrashReportDialog } from './CrashReportDialog'; -import { setupI18n } from '../util/setupI18n'; import { sleep } from '../util/sleep'; -import enMessages from '../../_locales/en/messages.json'; export default { title: 'Components/CrashReportDialog', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Basic(): JSX.Element { const [isPending, setIsPending] = useState(false); diff --git a/ts/components/CustomColorEditor.stories.tsx b/ts/components/CustomColorEditor.stories.tsx index 91beaaee4..e6ebbe320 100644 --- a/ts/components/CustomColorEditor.stories.tsx +++ b/ts/components/CustomColorEditor.stories.tsx @@ -6,16 +6,14 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './CustomColorEditor'; import { CustomColorEditor } from './CustomColorEditor'; -import { setupI18n } from '../util/setupI18n'; export default { title: 'Components/CustomColorEditor', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): PropsType => ({ i18n, diff --git a/ts/components/CustomizingPreferredReactionsModal.stories.tsx b/ts/components/CustomizingPreferredReactionsModal.stories.tsx index 23572eb2c..b95faa41e 100644 --- a/ts/components/CustomizingPreferredReactionsModal.stories.tsx +++ b/ts/components/CustomizingPreferredReactionsModal.stories.tsx @@ -6,14 +6,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../reactions/constants'; -import enMessages from '../../_locales/en/messages.json'; - import type { PropsType } from './CustomizingPreferredReactionsModal'; import { CustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/CustomizingPreferredReactionsModal', diff --git a/ts/components/DebugLogWindow.stories.tsx b/ts/components/DebugLogWindow.stories.tsx index dcb638f88..909cae063 100644 --- a/ts/components/DebugLogWindow.stories.tsx +++ b/ts/components/DebugLogWindow.stories.tsx @@ -5,13 +5,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './DebugLogWindow'; import { DebugLogWindow } from './DebugLogWindow'; -import { setupI18n } from '../util/setupI18n'; import { sleep } from '../util/sleep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): PropsType => ({ closeWindow: action('closeWindow'), diff --git a/ts/components/DeleteMessagesModal.stories.tsx b/ts/components/DeleteMessagesModal.stories.tsx index e1436ab36..9a6daf35a 100644 --- a/ts/components/DeleteMessagesModal.stories.tsx +++ b/ts/components/DeleteMessagesModal.stories.tsx @@ -5,12 +5,10 @@ import React from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import DeleteMessagesModal from './DeleteMessagesModal'; import type { DeleteMessagesModalProps } from './DeleteMessagesModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/DeleteMessagesModal', diff --git a/ts/components/DialogExpiredBuild.stories.tsx b/ts/components/DialogExpiredBuild.stories.tsx index 2d8b732e6..936c6639b 100644 --- a/ts/components/DialogExpiredBuild.stories.tsx +++ b/ts/components/DialogExpiredBuild.stories.tsx @@ -5,12 +5,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import type { PropsType } from './DialogExpiredBuild'; import { DialogExpiredBuild } from './DialogExpiredBuild'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { WidthBreakpoint } from './_util'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/DialogExpiredBuild', diff --git a/ts/components/DialogNetworkStatus.stories.tsx b/ts/components/DialogNetworkStatus.stories.tsx index 1b75acee6..1584c47b4 100644 --- a/ts/components/DialogNetworkStatus.stories.tsx +++ b/ts/components/DialogNetworkStatus.stories.tsx @@ -8,12 +8,10 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './DialogNetworkStatus'; import { DialogNetworkStatus } from './DialogNetworkStatus'; import { SocketStatus } from '../types/SocketStatus'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { WidthBreakpoint } from './_util'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultProps = { containerWidthBreakpoint: WidthBreakpoint.Wide, diff --git a/ts/components/DialogRelink.stories.tsx b/ts/components/DialogRelink.stories.tsx index 01ab3e7fc..8b117382d 100644 --- a/ts/components/DialogRelink.stories.tsx +++ b/ts/components/DialogRelink.stories.tsx @@ -6,12 +6,10 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './DialogRelink'; import { DialogRelink } from './DialogRelink'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { WidthBreakpoint } from './_util'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultProps = { containerWidthBreakpoint: WidthBreakpoint.Wide, diff --git a/ts/components/DialogUpdate.stories.tsx b/ts/components/DialogUpdate.stories.tsx index 097206d81..6e0c24972 100644 --- a/ts/components/DialogUpdate.stories.tsx +++ b/ts/components/DialogUpdate.stories.tsx @@ -11,10 +11,7 @@ import { WidthBreakpoint } from './_util'; import { SECOND } from '../util/durations'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultProps = { containerWidthBreakpoint: WidthBreakpoint.Wide, diff --git a/ts/components/DisappearingTimeDialog.stories.tsx b/ts/components/DisappearingTimeDialog.stories.tsx index 69a99e115..1b642fa4c 100644 --- a/ts/components/DisappearingTimeDialog.stories.tsx +++ b/ts/components/DisappearingTimeDialog.stories.tsx @@ -6,16 +6,13 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './DisappearingTimeDialog'; import { DisappearingTimeDialog } from './DisappearingTimeDialog'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - import { EXPIRE_TIMERS } from '../test-both/util/expireTimers'; export default { title: 'Components/DisappearingTimeDialog', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Seconds(): JSX.Element { return ( diff --git a/ts/components/DisappearingTimerSelect.stories.tsx b/ts/components/DisappearingTimerSelect.stories.tsx index 460abf1d6..a6c57d746 100644 --- a/ts/components/DisappearingTimerSelect.stories.tsx +++ b/ts/components/DisappearingTimerSelect.stories.tsx @@ -5,15 +5,13 @@ import React, { useState } from 'react'; import type { Meta } from '@storybook/react'; import type { Props } from './DisappearingTimerSelect'; import { DisappearingTimerSelect } from './DisappearingTimerSelect'; -import { setupI18n } from '../util/setupI18n'; import { DurationInSeconds } from '../util/durations'; -import enMessages from '../../_locales/en/messages.json'; export default { title: 'Components/DisappearingTimerSelect', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type Args = { initialValue: number; diff --git a/ts/components/EditNicknameAndNoteModal.stories.tsx b/ts/components/EditNicknameAndNoteModal.stories.tsx index 399ced79f..02af384b6 100644 --- a/ts/components/EditNicknameAndNoteModal.stories.tsx +++ b/ts/components/EditNicknameAndNoteModal.stories.tsx @@ -2,14 +2,12 @@ // SPDX-License-Identifier: AGPL-3.0-only import { action } from '@storybook/addon-actions'; import * as React from 'react'; -import enMessages from '../../_locales/en/messages.json'; import type { ComponentMeta } from '../storybook/types'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import type { EditNicknameAndNoteModalProps } from './EditNicknameAndNoteModal'; import { EditNicknameAndNoteModal } from './EditNicknameAndNoteModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/EditNicknameAndNoteModal', diff --git a/ts/components/EditUsernameModalBody.stories.tsx b/ts/components/EditUsernameModalBody.stories.tsx index c32c475ba..52dc0acf9 100644 --- a/ts/components/EditUsernameModalBody.stories.tsx +++ b/ts/components/EditUsernameModalBody.stories.tsx @@ -5,8 +5,6 @@ import React from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import type { UsernameReservationType } from '../types/Username'; import type { PropsType } from './EditUsernameModalBody'; @@ -16,7 +14,7 @@ import { UsernameReservationError, } from '../state/ducks/usernameEnums'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const DEFAULT_RESERVATION: UsernameReservationType = { username: 'reserved.56', diff --git a/ts/components/ErrorModal.stories.tsx b/ts/components/ErrorModal.stories.tsx index e20380263..2f1981db9 100644 --- a/ts/components/ErrorModal.stories.tsx +++ b/ts/components/ErrorModal.stories.tsx @@ -8,11 +8,9 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './ErrorModal'; import { ErrorModal } from './ErrorModal'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { ButtonVariant } from './Button'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ buttonVariant: overrideProps.buttonVariant ?? undefined, diff --git a/ts/components/ForwardMessagesModal.stories.tsx b/ts/components/ForwardMessagesModal.stories.tsx index 66600aa58..ccfc8e04f 100644 --- a/ts/components/ForwardMessagesModal.stories.tsx +++ b/ts/components/ForwardMessagesModal.stories.tsx @@ -4,7 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { AttachmentType } from '../types/Attachment'; import type { PropsType } from './ForwardMessagesModal'; import { @@ -13,7 +12,6 @@ import { } from './ForwardMessagesModal'; import { IMAGE_JPEG, VIDEO_MP4, stringToMIMEType } from '../types/MIME'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { CompositionTextArea } from './CompositionTextArea'; import type { MessageForwardDraft } from '../types/ForwardDraft'; @@ -36,7 +34,7 @@ export default { args: {}, } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const LONG_TITLE = "This is a super-sweet site. And it's got some really amazing content in store for you if you just click that link. Can you click that link for me?"; diff --git a/ts/components/GroupCallOverflowArea.stories.tsx b/ts/components/GroupCallOverflowArea.stories.tsx index ae0e4a8e7..4945a647a 100644 --- a/ts/components/GroupCallOverflowArea.stories.tsx +++ b/ts/components/GroupCallOverflowArea.stories.tsx @@ -7,18 +7,16 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './GroupCallOverflowArea'; import { GroupCallOverflowArea } from './GroupCallOverflowArea'; -import { setupI18n } from '../util/setupI18n'; import { getDefaultConversationWithServiceId } from '../test-both/helpers/getDefaultConversation'; import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource'; import { FRAME_BUFFER_SIZE } from '../calling/constants'; -import enMessages from '../../_locales/en/messages.json'; import { generateAci } from '../types/ServiceId'; import type { CallingImageDataCache } from './CallManager'; import { MINUTE } from '../util/durations'; const MAX_PARTICIPANTS = 32; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const allRemoteParticipants = times(MAX_PARTICIPANTS).map(index => ({ aci: generateAci(), diff --git a/ts/components/GroupCallRemoteParticipant.stories.tsx b/ts/components/GroupCallRemoteParticipant.stories.tsx index 850c974ef..ffc4337a5 100644 --- a/ts/components/GroupCallRemoteParticipant.stories.tsx +++ b/ts/components/GroupCallRemoteParticipant.stories.tsx @@ -8,13 +8,11 @@ import type { PropsType } from './GroupCallRemoteParticipant'; import { GroupCallRemoteParticipant } from './GroupCallRemoteParticipant'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { FRAME_BUFFER_SIZE } from '../calling/constants'; -import { setupI18n } from '../util/setupI18n'; import { generateAci } from '../types/ServiceId'; -import enMessages from '../../_locales/en/messages.json'; import type { CallingImageDataCache } from './CallManager'; import { MINUTE } from '../util/durations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type OverridePropsType = { audioLevel?: number; diff --git a/ts/components/GroupDescriptionInput.stories.tsx b/ts/components/GroupDescriptionInput.stories.tsx index b692f4fbd..094daf41c 100644 --- a/ts/components/GroupDescriptionInput.stories.tsx +++ b/ts/components/GroupDescriptionInput.stories.tsx @@ -3,12 +3,10 @@ import React, { useState } from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './GroupDescriptionInput'; import { GroupDescriptionInput } from './GroupDescriptionInput'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/GroupDescriptionInput', diff --git a/ts/components/GroupTitleInput.stories.tsx b/ts/components/GroupTitleInput.stories.tsx index d873de91d..b6d0b5681 100644 --- a/ts/components/GroupTitleInput.stories.tsx +++ b/ts/components/GroupTitleInput.stories.tsx @@ -3,12 +3,10 @@ import React, { useState } from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './GroupTitleInput'; import { GroupTitleInput } from './GroupTitleInput'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/GroupTitleInput', diff --git a/ts/components/GroupV1MigrationDialog.stories.tsx b/ts/components/GroupV1MigrationDialog.stories.tsx index 3a6ba2e72..bc9fe09cc 100644 --- a/ts/components/GroupV1MigrationDialog.stories.tsx +++ b/ts/components/GroupV1MigrationDialog.stories.tsx @@ -9,12 +9,10 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './GroupV1MigrationDialog'; import { GroupV1MigrationDialog } from './GroupV1MigrationDialog'; import type { ConversationType } from '../state/ducks/conversations'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { ThemeType } from '../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const contact1: ConversationType = getDefaultConversation({ title: 'Alice', diff --git a/ts/components/GroupV2JoinDialog.stories.tsx b/ts/components/GroupV2JoinDialog.stories.tsx index 6a348fad4..5f8a6cad3 100644 --- a/ts/components/GroupV2JoinDialog.stories.tsx +++ b/ts/components/GroupV2JoinDialog.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './GroupV2JoinDialog'; import { GroupV2JoinDialog } from './GroupV2JoinDialog'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ memberCount: overrideProps.memberCount ?? 12, diff --git a/ts/components/I18n.stories.tsx b/ts/components/I18n.stories.tsx index a4f56ce08..88c484012 100644 --- a/ts/components/I18n.stories.tsx +++ b/ts/components/I18n.stories.tsx @@ -6,10 +6,8 @@ import * as React from 'react'; import type { ComponentMeta } from '../storybook/types'; import type { Props } from './I18n'; import { I18n } from './I18n'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/I18n', diff --git a/ts/components/InContactsIcon.stories.tsx b/ts/components/InContactsIcon.stories.tsx index 42db8da1b..4377cf590 100644 --- a/ts/components/InContactsIcon.stories.tsx +++ b/ts/components/InContactsIcon.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './InContactsIcon'; import { InContactsIcon } from './InContactsIcon'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/InContactsIcon', diff --git a/ts/components/Inbox.stories.tsx b/ts/components/Inbox.stories.tsx index e6b1b5506..4db17afb6 100644 --- a/ts/components/Inbox.stories.tsx +++ b/ts/components/Inbox.stories.tsx @@ -9,10 +9,7 @@ import { Inbox } from './Inbox'; import type { PropsType } from './Inbox'; import { DAY, SECOND } from '../util/durations'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Inbox', diff --git a/ts/components/IncomingCallBar.stories.tsx b/ts/components/IncomingCallBar.stories.tsx index 66dbb70b6..7efbad179 100644 --- a/ts/components/IncomingCallBar.stories.tsx +++ b/ts/components/IncomingCallBar.stories.tsx @@ -7,11 +7,9 @@ import type { Meta } from '@storybook/react'; import type { PropsType } from './IncomingCallBar'; import { IncomingCallBar } from './IncomingCallBar'; import { CallMode } from '../types/CallDisposition'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const commonProps = { acceptCall: action('accept-call'), diff --git a/ts/components/Input.stories.tsx b/ts/components/Input.stories.tsx index e6b580e90..ed930400b 100644 --- a/ts/components/Input.stories.tsx +++ b/ts/components/Input.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './Input'; import { Input } from './Input'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Input', diff --git a/ts/components/LeftPane.stories.tsx b/ts/components/LeftPane.stories.tsx index 66a0c607e..4febb3e27 100644 --- a/ts/components/LeftPane.stories.tsx +++ b/ts/components/LeftPane.stories.tsx @@ -18,9 +18,7 @@ import { DialogUpdate } from './DialogUpdate'; import { UnsupportedOSDialog } from './UnsupportedOSDialog'; import type { ConversationType } from '../state/ducks/conversations'; import { MessageSearchResult } from './conversationList/MessageSearchResult'; -import { setupI18n } from '../util/setupI18n'; import { DurationInSeconds, DAY } from '../util/durations'; -import enMessages from '../../_locales/en/messages.json'; import { LeftPaneMode } from '../types/leftPane'; import { ThemeType } from '../types/Util'; import { @@ -37,7 +35,7 @@ import { import type { GroupListItemConversationType } from './conversationList/GroupListItem'; import { CriticalIdlePrimaryDeviceDialog } from './CriticalIdlePrimaryDeviceDialog'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type OverridePropsType = Partial & { dialogNetworkStatus?: Partial; diff --git a/ts/components/Lightbox.stories.tsx b/ts/components/Lightbox.stories.tsx index cf89c6e43..1f4101624 100644 --- a/ts/components/Lightbox.stories.tsx +++ b/ts/components/Lightbox.stories.tsx @@ -5,11 +5,9 @@ import React, { useState } from 'react'; import { action } from '@storybook/addon-actions'; import { noop } from 'lodash'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './Lightbox'; import { Lightbox } from './Lightbox'; import type { MediaItemType } from '../types/MediaItem'; -import { setupI18n } from '../util/setupI18n'; import { AUDIO_MP3, IMAGE_JPEG, @@ -20,7 +18,7 @@ import { import { fakeAttachment } from '../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Lightbox', diff --git a/ts/components/LocalDeleteWarningModal.stories.tsx b/ts/components/LocalDeleteWarningModal.stories.tsx index 7a07dd871..6ebb362bd 100644 --- a/ts/components/LocalDeleteWarningModal.stories.tsx +++ b/ts/components/LocalDeleteWarningModal.stories.tsx @@ -6,11 +6,9 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './LocalDeleteWarningModal'; -import enMessages from '../../_locales/en/messages.json'; import { LocalDeleteWarningModal } from './LocalDeleteWarningModal'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/LocalDeleteWarningModal', diff --git a/ts/components/MediaEditor.stories.tsx b/ts/components/MediaEditor.stories.tsx index 8c89733ae..502399c2f 100644 --- a/ts/components/MediaEditor.stories.tsx +++ b/ts/components/MediaEditor.stories.tsx @@ -7,11 +7,9 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './MediaEditor'; import { MediaEditor } from './MediaEditor'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import { Stickers, installedPacks } from '../test-both/helpers/getStickerPacks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const IMAGE_1 = '/fixtures/nathan-anderson-316188-unsplash.jpg'; const IMAGE_2 = '/fixtures/tina-rolf-269345-unsplash.jpg'; const IMAGE_3 = '/fixtures/kitten-4-112-112.jpg'; diff --git a/ts/components/MediaPermissionsModal.stories.tsx b/ts/components/MediaPermissionsModal.stories.tsx index 1b92c9291..746294760 100644 --- a/ts/components/MediaPermissionsModal.stories.tsx +++ b/ts/components/MediaPermissionsModal.stories.tsx @@ -2,13 +2,11 @@ // SPDX-License-Identifier: AGPL-3.0-only import React, { StrictMode } from 'react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; import { type ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; import type { PropsType } from './MediaPermissionsModal'; import { MediaPermissionsModal } from './MediaPermissionsModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type TemplateProps = Omit; diff --git a/ts/components/MediaQualitySelector.stories.tsx b/ts/components/MediaQualitySelector.stories.tsx index 61ba742e1..01b776f91 100644 --- a/ts/components/MediaQualitySelector.stories.tsx +++ b/ts/components/MediaQualitySelector.stories.tsx @@ -4,10 +4,8 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './MediaQualitySelector'; import { MediaQualitySelector } from './MediaQualitySelector'; -import { setupI18n } from '../util/setupI18n'; export default { title: 'Components/MediaQualitySelector', @@ -15,7 +13,7 @@ export default { args: {}, } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (overrideProps: Partial = {}): PropsType => ({ conversationId: 'abc123', diff --git a/ts/components/MiniPlayer.stories.tsx b/ts/components/MiniPlayer.stories.tsx index f1570e3b1..79f38c2a1 100644 --- a/ts/components/MiniPlayer.stories.tsx +++ b/ts/components/MiniPlayer.stories.tsx @@ -6,10 +6,7 @@ import type { Meta } from '@storybook/react'; import type { Props } from './MiniPlayer'; import { MiniPlayer, PlayerState } from './MiniPlayer'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; - -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const audio = new Audio(); audio.src = '/fixtures/incompetech-com-Agnus-Dei-X.mp3'; diff --git a/ts/components/Modal.stories.tsx b/ts/components/Modal.stories.tsx index 6a4034feb..bfd19d56e 100644 --- a/ts/components/Modal.stories.tsx +++ b/ts/components/Modal.stories.tsx @@ -5,13 +5,11 @@ import React from 'react'; import { noop } from 'lodash'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { Button } from './Button'; import type { ModalPropsType } from './Modal'; import { Modal } from './Modal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Modal', diff --git a/ts/components/MyStories.stories.tsx b/ts/components/MyStories.stories.tsx index abf032b0f..75c1d9168 100644 --- a/ts/components/MyStories.stories.tsx +++ b/ts/components/MyStories.stories.tsx @@ -9,16 +9,14 @@ import { expect, fn, within, userEvent } from '@storybook/test'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './MyStories'; -import enMessages from '../../_locales/en/messages.json'; import { MY_STORY_ID } from '../types/Stories'; import { MyStories } from './MyStories'; import { SendStatus } from '../messages/MessageSendState'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { getFakeMyStory } from '../test-both/helpers/getFakeStory'; -import { setupI18n } from '../util/setupI18n'; import { sleep } from '../util/sleep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/MyStories', diff --git a/ts/components/MyStoryButton.stories.tsx b/ts/components/MyStoryButton.stories.tsx index f327ea3d5..765d68d67 100644 --- a/ts/components/MyStoryButton.stories.tsx +++ b/ts/components/MyStoryButton.stories.tsx @@ -8,15 +8,13 @@ import { expect, fn, within, userEvent } from '@storybook/test'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './MyStoryButton'; -import enMessages from '../../_locales/en/messages.json'; import { MyStoryButton } from './MyStoryButton'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { getFakeMyStory } from '../test-both/helpers/getFakeStory'; -import { setupI18n } from '../util/setupI18n'; import { SendStatus } from '../messages/MessageSendState'; import { ResolvedSendStatus } from '../types/Stories'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/MyStoriesButton', diff --git a/ts/components/NewlyCreatedGroupInvitedContactsDialog.stories.tsx b/ts/components/NewlyCreatedGroupInvitedContactsDialog.stories.tsx index c4c458e93..982c50cf6 100644 --- a/ts/components/NewlyCreatedGroupInvitedContactsDialog.stories.tsx +++ b/ts/components/NewlyCreatedGroupInvitedContactsDialog.stories.tsx @@ -8,13 +8,11 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './NewlyCreatedGroupInvitedContactsDialog'; import { NewlyCreatedGroupInvitedContactsDialog } from './NewlyCreatedGroupInvitedContactsDialog'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { ConversationType } from '../state/ducks/conversations'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { ThemeType } from '../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversations: Array = [ getDefaultConversation({ title: 'Fred Willard' }), diff --git a/ts/components/NotePreviewModal.stories.tsx b/ts/components/NotePreviewModal.stories.tsx index 1a0ebfe49..517c877c9 100644 --- a/ts/components/NotePreviewModal.stories.tsx +++ b/ts/components/NotePreviewModal.stories.tsx @@ -2,16 +2,14 @@ // SPDX-License-Identifier: AGPL-3.0-only import { action } from '@storybook/addon-actions'; import * as React from 'react'; -import enMessages from '../../_locales/en/messages.json'; import type { ComponentMeta } from '../storybook/types'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { NotePreviewModal, type NotePreviewModalProps, } from './NotePreviewModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/NotePreviewModal', diff --git a/ts/components/OutgoingGiftBadgeModal.stories.tsx b/ts/components/OutgoingGiftBadgeModal.stories.tsx index d5a85f5ea..71634ce50 100644 --- a/ts/components/OutgoingGiftBadgeModal.stories.tsx +++ b/ts/components/OutgoingGiftBadgeModal.stories.tsx @@ -6,11 +6,9 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './OutgoingGiftBadgeModal'; import { OutgoingGiftBadgeModal } from './OutgoingGiftBadgeModal'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { BadgeCategory } from '../badges/BadgeCategory'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const getPreferredBadge = () => ({ category: BadgeCategory.Donor, diff --git a/ts/components/Preferences.stories.tsx b/ts/components/Preferences.stories.tsx index 45692d8e9..1d64b0ab0 100644 --- a/ts/components/Preferences.stories.tsx +++ b/ts/components/Preferences.stories.tsx @@ -5,16 +5,14 @@ import type { Meta, StoryFn } from '@storybook/react'; import React from 'react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './Preferences'; import { Preferences } from './Preferences'; -import { setupI18n } from '../util/setupI18n'; import { DEFAULT_CONVERSATION_COLOR } from '../types/Colors'; import { PhoneNumberSharingMode } from '../util/phoneNumberSharingMode'; import { PhoneNumberDiscoverability } from '../util/phoneNumberDiscoverability'; import { DurationInSeconds } from '../util/durations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const availableMicrophones = [ { diff --git a/ts/components/ProfileEditor.stories.tsx b/ts/components/ProfileEditor.stories.tsx index d6bcdd547..1d4da4732 100644 --- a/ts/components/ProfileEditor.stories.tsx +++ b/ts/components/ProfileEditor.stories.tsx @@ -8,7 +8,6 @@ import casual from 'casual'; import { v4 as generateUuid } from 'uuid'; import type { PropsType } from './ProfileEditor'; -import enMessages from '../../_locales/en/messages.json'; import { ProfileEditor } from './ProfileEditor'; import { EditUsernameModalBody } from './EditUsernameModalBody'; import { @@ -17,10 +16,9 @@ import { UsernameReservationState, } from '../state/ducks/usernameEnums'; import { getRandomColor } from '../test-both/helpers/getRandomColor'; -import { setupI18n } from '../util/setupI18n'; import { SignalService as Proto } from '../protobuf'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { component: ProfileEditor, diff --git a/ts/components/ProgressDialog.stories.tsx b/ts/components/ProgressDialog.stories.tsx index a4ebc5184..5abc852a5 100644 --- a/ts/components/ProgressDialog.stories.tsx +++ b/ts/components/ProgressDialog.stories.tsx @@ -6,15 +6,12 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import type { PropsType } from './ProgressDialog'; import { ProgressDialog } from './ProgressDialog'; -import { setupI18n } from '../util/setupI18n'; - -import enMessages from '../../_locales/en/messages.json'; export default { title: 'Components/ProgressDialog', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): PropsType => ({ i18n, diff --git a/ts/components/ProgressModal.stories.tsx b/ts/components/ProgressModal.stories.tsx index 3a770d717..d825bbabc 100644 --- a/ts/components/ProgressModal.stories.tsx +++ b/ts/components/ProgressModal.stories.tsx @@ -5,10 +5,8 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import type { PropsType } from './ProgressModal'; import { ProgressModal } from './ProgressModal'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ProgressModal', diff --git a/ts/components/SafetyNumberChangeDialog.stories.tsx b/ts/components/SafetyNumberChangeDialog.stories.tsx index 721b8869d..044097893 100644 --- a/ts/components/SafetyNumberChangeDialog.stories.tsx +++ b/ts/components/SafetyNumberChangeDialog.stories.tsx @@ -7,14 +7,12 @@ import type { Meta } from '@storybook/react'; import type { Props } from './SafetyNumberChangeDialog'; import { SafetyNumberChangeDialog } from './SafetyNumberChangeDialog'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../.storybook/StorybookThemeContext'; import { getFakeBadge } from '../test-both/helpers/getFakeBadge'; import { MY_STORY_ID } from '../types/Stories'; import { generateStoryDistributionId } from '../types/StoryDistributionId'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const contactWithAllData = getDefaultConversation({ id: 'abc', diff --git a/ts/components/SafetyNumberNotReady.stories.tsx b/ts/components/SafetyNumberNotReady.stories.tsx index dc3f3e51b..e1c1b3a0c 100644 --- a/ts/components/SafetyNumberNotReady.stories.tsx +++ b/ts/components/SafetyNumberNotReady.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './SafetyNumberNotReady'; import { SafetyNumberNotReady } from './SafetyNumberNotReady'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/SafetyNumberNotReady', diff --git a/ts/components/SafetyNumberViewer.stories.tsx b/ts/components/SafetyNumberViewer.stories.tsx index c9c42d8e3..454593105 100644 --- a/ts/components/SafetyNumberViewer.stories.tsx +++ b/ts/components/SafetyNumberViewer.stories.tsx @@ -6,8 +6,6 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './SafetyNumberViewer'; import { SafetyNumberViewer } from './SafetyNumberViewer'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; function generateQRData() { @@ -30,7 +28,7 @@ function generateNumberBlocks() { return result; } -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const contactWithAllData = getDefaultConversation({ title: 'Summer Smith', diff --git a/ts/components/SafetyTipsModal.stories.tsx b/ts/components/SafetyTipsModal.stories.tsx index 5836e184c..e30c5dbd1 100644 --- a/ts/components/SafetyTipsModal.stories.tsx +++ b/ts/components/SafetyTipsModal.stories.tsx @@ -2,13 +2,11 @@ // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; import type { ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; import type { SafetyTipsModalProps } from './SafetyTipsModal'; import { SafetyTipsModal } from './SafetyTipsModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/SafetyTipsModal', diff --git a/ts/components/SendStoryModal.stories.tsx b/ts/components/SendStoryModal.stories.tsx index 4d9a4f0df..dfdd885d2 100644 --- a/ts/components/SendStoryModal.stories.tsx +++ b/ts/components/SendStoryModal.stories.tsx @@ -6,13 +6,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './SendStoryModal'; -import enMessages from '../../_locales/en/messages.json'; import { SendStoryModal } from './SendStoryModal'; import { getDefaultConversation, getDefaultGroup, } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { getMyStories, getFakeDistributionListsWithMembers, @@ -20,7 +18,7 @@ import { import { VIDEO_MP4 } from '../types/MIME'; import type { StoryDistributionIdString } from '../types/StoryDistributionId'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const myStories = { ...getMyStories(), diff --git a/ts/components/ShortcutGuide.stories.tsx b/ts/components/ShortcutGuide.stories.tsx index 55e4dcc35..c2f86ef84 100644 --- a/ts/components/ShortcutGuide.stories.tsx +++ b/ts/components/ShortcutGuide.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { Props } from './ShortcutGuide'; import { ShortcutGuide } from './ShortcutGuide'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/ShortcutGuide', diff --git a/ts/components/SignalConnectionsModal.stories.tsx b/ts/components/SignalConnectionsModal.stories.tsx index 806031622..6a48d76b1 100644 --- a/ts/components/SignalConnectionsModal.stories.tsx +++ b/ts/components/SignalConnectionsModal.stories.tsx @@ -6,11 +6,9 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './SignalConnectionsModal'; -import enMessages from '../../_locales/en/messages.json'; import { SignalConnectionsModal } from './SignalConnectionsModal'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/SignalConnectionsModal', diff --git a/ts/components/StoriesSettingsModal.stories.tsx b/ts/components/StoriesSettingsModal.stories.tsx index de1848c85..3638287f5 100644 --- a/ts/components/StoriesSettingsModal.stories.tsx +++ b/ts/components/StoriesSettingsModal.stories.tsx @@ -6,19 +6,17 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoriesSettingsModal'; -import enMessages from '../../_locales/en/messages.json'; import { StoriesSettingsModal } from './StoriesSettingsModal'; import { getDefaultConversation, getDefaultGroup, } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { getMyStories, getFakeDistributionList, } from '../test-both/helpers/getFakeDistributionLists'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoriesSettingsModal', diff --git a/ts/components/StoriesTab.stories.tsx b/ts/components/StoriesTab.stories.tsx index 15fe74af0..1c3bac3c6 100644 --- a/ts/components/StoriesTab.stories.tsx +++ b/ts/components/StoriesTab.stories.tsx @@ -7,8 +7,6 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoriesTab'; import { StoriesTab } from './StoriesTab'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { getFakeMyStory, @@ -16,7 +14,7 @@ import { } from '../test-both/helpers/getFakeStory'; import * as durations from '../util/durations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoriesTab', diff --git a/ts/components/StoryCreator.stories.tsx b/ts/components/StoryCreator.stories.tsx index 0c3f67edc..5b115e0d1 100644 --- a/ts/components/StoryCreator.stories.tsx +++ b/ts/components/StoryCreator.stories.tsx @@ -6,7 +6,6 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoryCreator'; -import enMessages from '../../_locales/en/messages.json'; import { StoryCreator } from './StoryCreator'; import { fakeAttachment } from '../test-both/helpers/fakeAttachment'; import { @@ -14,9 +13,8 @@ import { getDefaultGroup, } from '../test-both/helpers/getDefaultConversation'; import { getFakeDistributionListsWithMembers } from '../test-both/helpers/getFakeDistributionLists'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryCreator', diff --git a/ts/components/StoryDetailsModal.stories.tsx b/ts/components/StoryDetailsModal.stories.tsx index 63b9e7e6c..ba41701fc 100644 --- a/ts/components/StoryDetailsModal.stories.tsx +++ b/ts/components/StoryDetailsModal.stories.tsx @@ -7,13 +7,11 @@ import casual from 'casual'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoryDetailsModal'; -import enMessages from '../../_locales/en/messages.json'; import { SendStatus } from '../messages/MessageSendState'; import { StoryDetailsModal } from './StoryDetailsModal'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryDetailsModal', diff --git a/ts/components/StoryImage.stories.tsx b/ts/components/StoryImage.stories.tsx index 909a4fe53..665d208ae 100644 --- a/ts/components/StoryImage.stories.tsx +++ b/ts/components/StoryImage.stories.tsx @@ -9,15 +9,13 @@ import { noop } from 'lodash'; import type { Meta } from '@storybook/react'; import type { PropsType } from './StoryImage'; import { StoryImage } from './StoryImage'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import { fakeAttachment, fakeThumbnail, } from '../test-both/helpers/fakeAttachment'; import { VIDEO_MP4 } from '../types/MIME'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryImage', diff --git a/ts/components/StoryLinkPreview.stories.tsx b/ts/components/StoryLinkPreview.stories.tsx index b46ba21e4..1764505bb 100644 --- a/ts/components/StoryLinkPreview.stories.tsx +++ b/ts/components/StoryLinkPreview.stories.tsx @@ -5,10 +5,8 @@ import type { Meta, StoryFn } from '@storybook/react'; import React from 'react'; import type { Props } from './StoryLinkPreview'; -import enMessages from '../../_locales/en/messages.json'; import { StoryLinkPreview } from './StoryLinkPreview'; import { fakeAttachment } from '../test-both/helpers/fakeAttachment'; -import { setupI18n } from '../util/setupI18n'; import { IMAGE_JPEG } from '../types/MIME'; const LONG_TITLE = @@ -16,7 +14,7 @@ const LONG_TITLE = const LONG_DESCRIPTION = "You're gonna love this description. Not only does it have a lot of characters, but it will also be truncated in the UI. How cool is that??"; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryLinkPreview', diff --git a/ts/components/StoryListItem.stories.tsx b/ts/components/StoryListItem.stories.tsx index 4a2f0d97b..0ca29c97f 100644 --- a/ts/components/StoryListItem.stories.tsx +++ b/ts/components/StoryListItem.stories.tsx @@ -7,15 +7,13 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoryListItem'; import { StoryListItem } from './StoryListItem'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { fakeAttachment, fakeThumbnail, } from '../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryListItem', diff --git a/ts/components/StoryViewer.stories.tsx b/ts/components/StoryViewer.stories.tsx index 8f31d8a28..bef085f0b 100644 --- a/ts/components/StoryViewer.stories.tsx +++ b/ts/components/StoryViewer.stories.tsx @@ -5,7 +5,6 @@ import type { Meta } from '@storybook/react'; import React from 'react'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoryViewer'; -import enMessages from '../../_locales/en/messages.json'; import { SendStatus } from '../messages/MessageSendState'; import { StoryViewModeType } from '../types/Stories'; import { generateStoryDistributionId } from '../types/StoryDistributionId'; @@ -14,10 +13,9 @@ import { VIDEO_MP4 } from '../types/MIME'; import { fakeAttachment } from '../test-both/helpers/fakeAttachment'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; import { getFakeStoryView } from '../test-both/helpers/getFakeStory'; -import { setupI18n } from '../util/setupI18n'; import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../reactions/constants'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryViewer', diff --git a/ts/components/StoryViewsNRepliesModal.stories.tsx b/ts/components/StoryViewsNRepliesModal.stories.tsx index 3be3418c0..111674aae 100644 --- a/ts/components/StoryViewsNRepliesModal.stories.tsx +++ b/ts/components/StoryViewsNRepliesModal.stories.tsx @@ -8,15 +8,13 @@ import { v4 as generateUuid } from 'uuid'; import { action } from '@storybook/addon-actions'; import type { PropsType } from './StoryViewsNRepliesModal'; import * as durations from '../util/durations'; -import enMessages from '../../_locales/en/messages.json'; import { SendStatus } from '../messages/MessageSendState'; import { StoryViewsNRepliesModal } from './StoryViewsNRepliesModal'; import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../util/setupI18n'; import { StoryViewTargetType } from '../types/Stories'; import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../reactions/constants'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/StoryViewsNRepliesModal', diff --git a/ts/components/TapToViewNotAvailableModal.stories.tsx b/ts/components/TapToViewNotAvailableModal.stories.tsx index fd4da626e..95acf5019 100644 --- a/ts/components/TapToViewNotAvailableModal.stories.tsx +++ b/ts/components/TapToViewNotAvailableModal.stories.tsx @@ -3,8 +3,6 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; import type { PropsType } from './TapToViewNotAvailableModal'; import { TapToViewNotAvailableModal, @@ -12,7 +10,7 @@ import { } from './TapToViewNotAvailableModal'; import type { ComponentMeta } from '../storybook/types'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/TapToViewNotAvailableModal', diff --git a/ts/components/TextAttachment.stories.tsx b/ts/components/TextAttachment.stories.tsx index 92e9cd32c..6c1aa827b 100644 --- a/ts/components/TextAttachment.stories.tsx +++ b/ts/components/TextAttachment.stories.tsx @@ -4,12 +4,10 @@ import React from 'react'; import type { Meta } from '@storybook/react'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; import { TextAttachment } from './TextAttachment'; import type { PropsType } from './TextAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const getDefaultProps = (): PropsType => ({ i18n, diff --git a/ts/components/ToastManager.stories.tsx b/ts/components/ToastManager.stories.tsx index 5533dc7f5..ffa00fa44 100644 --- a/ts/components/ToastManager.stories.tsx +++ b/ts/components/ToastManager.stories.tsx @@ -5,17 +5,15 @@ import type { Meta, StoryFn } from '@storybook/react'; import React from 'react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; import { ToastManager } from './ToastManager'; import type { AnyToast } from '../types/Toast'; import { ToastType } from '../types/Toast'; import type { AnyActionableMegaphone } from '../types/Megaphone'; import { MegaphoneType } from '../types/Megaphone'; -import { setupI18n } from '../util/setupI18n'; import { missingCaseError } from '../util/missingCaseError'; import type { PropsType } from './ToastManager'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; function getToast(toastType: ToastType): AnyToast { switch (toastType) { diff --git a/ts/components/UnsupportedOSDialog.stories.tsx b/ts/components/UnsupportedOSDialog.stories.tsx index 824cefccc..7bf143d07 100644 --- a/ts/components/UnsupportedOSDialog.stories.tsx +++ b/ts/components/UnsupportedOSDialog.stories.tsx @@ -5,13 +5,11 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import { UnsupportedOSDialog } from './UnsupportedOSDialog'; import type { PropsType } from './UnsupportedOSDialog'; -import { setupI18n } from '../util/setupI18n'; import { DAY } from '../util/durations'; -import enMessages from '../../_locales/en/messages.json'; import { WidthBreakpoint } from './_util'; import { FakeLeftPaneContainer } from '../test-both/helpers/FakeLeftPaneContainer'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultProps: PropsType = { containerWidthBreakpoint: WidthBreakpoint.Wide, diff --git a/ts/components/UsernameLinkModalBody.stories.tsx b/ts/components/UsernameLinkModalBody.stories.tsx index 4865cded6..d2cf4d9ee 100644 --- a/ts/components/UsernameLinkModalBody.stories.tsx +++ b/ts/components/UsernameLinkModalBody.stories.tsx @@ -5,9 +5,7 @@ import React, { useCallback, useState } from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; import { UsernameLinkState } from '../state/ducks/usernameEnums'; -import { setupI18n } from '../util/setupI18n'; import { SignalService as Proto } from '../protobuf'; import type { PropsType } from './UsernameLinkModalBody'; @@ -20,7 +18,7 @@ import { Modal } from './Modal'; const ColorEnum = Proto.AccountRecord.UsernameLink.Color; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { component: UsernameLinkModalBody, diff --git a/ts/components/UsernameMegaphone.stories.tsx b/ts/components/UsernameMegaphone.stories.tsx index 9c8f2986b..251c31ed6 100644 --- a/ts/components/UsernameMegaphone.stories.tsx +++ b/ts/components/UsernameMegaphone.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { PropsType } from './UsernameMegaphone'; import { UsernameMegaphone } from './UsernameMegaphone'; import { type ComponentMeta } from '../storybook/types'; -import { setupI18n } from '../util/setupI18n'; -import enMessages from '../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/UsernameMegaphone', diff --git a/ts/components/UsernameOnboardingModal.stories.tsx b/ts/components/UsernameOnboardingModal.stories.tsx index 5974cc286..1d967923e 100644 --- a/ts/components/UsernameOnboardingModal.stories.tsx +++ b/ts/components/UsernameOnboardingModal.stories.tsx @@ -5,13 +5,10 @@ import React from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; - import type { PropsType } from './UsernameOnboardingModal'; import { UsernameOnboardingModal } from './UsernameOnboardingModal'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { component: UsernameOnboardingModal, diff --git a/ts/components/WhatsNewModal.stories.tsx b/ts/components/WhatsNewModal.stories.tsx index 69e7f5b5f..155799829 100644 --- a/ts/components/WhatsNewModal.stories.tsx +++ b/ts/components/WhatsNewModal.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType } from './WhatsNewModal'; import { WhatsNewModal } from './WhatsNewModal'; -import enMessages from '../../_locales/en/messages.json'; -import { setupI18n } from '../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/WhatsNewModal', diff --git a/ts/components/conversation/AboutContactModal.stories.tsx b/ts/components/conversation/AboutContactModal.stories.tsx index d9492cdd1..ef3f74751 100644 --- a/ts/components/conversation/AboutContactModal.stories.tsx +++ b/ts/components/conversation/AboutContactModal.stories.tsx @@ -6,11 +6,9 @@ import { action } from '@storybook/addon-actions'; import type { PropsType } from './AboutContactModal'; import { AboutContactModal } from './AboutContactModal'; import { type ComponentMeta } from '../../storybook/types'; -import { setupI18n } from '../../util/setupI18n'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const conversation = getDefaultConversation({ acceptedMessageRequest: true, diff --git a/ts/components/conversation/AttachmentDetailPill.stories.tsx b/ts/components/conversation/AttachmentDetailPill.stories.tsx index 941875e69..bb76826a0 100644 --- a/ts/components/conversation/AttachmentDetailPill.stories.tsx +++ b/ts/components/conversation/AttachmentDetailPill.stories.tsx @@ -5,11 +5,9 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import { type PropsType, AttachmentDetailPill } from './AttachmentDetailPill'; import { type ComponentMeta } from '../../storybook/types'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { fakeAttachment } from '../../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/AttachmentDetailPill', diff --git a/ts/components/conversation/AttachmentList.stories.tsx b/ts/components/conversation/AttachmentList.stories.tsx index 050b7f9c4..92fd4677c 100644 --- a/ts/components/conversation/AttachmentList.stories.tsx +++ b/ts/components/conversation/AttachmentList.stories.tsx @@ -17,11 +17,9 @@ import { VIDEO_MP4, stringToMIMEType, } from '../../types/MIME'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { fakeDraftAttachment } from '../../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/AttachmentList', diff --git a/ts/components/conversation/CallingNotification.stories.tsx b/ts/components/conversation/CallingNotification.stories.tsx index 12db60f50..044557a55 100644 --- a/ts/components/conversation/CallingNotification.stories.tsx +++ b/ts/components/conversation/CallingNotification.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { CallMode, CallType, @@ -22,7 +20,7 @@ import { import type { CallStatus } from '../../types/CallDisposition'; import type { ConversationType } from '../../state/ducks/conversations'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/CallingNotification', diff --git a/ts/components/conversation/ChangeNumberNotification.stories.tsx b/ts/components/conversation/ChangeNumberNotification.stories.tsx index 97c173d30..881a0a609 100644 --- a/ts/components/conversation/ChangeNumberNotification.stories.tsx +++ b/ts/components/conversation/ChangeNumberNotification.stories.tsx @@ -3,8 +3,6 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import type { Props } from './ChangeNumberNotification'; import { ChangeNumberNotification } from './ChangeNumberNotification'; @@ -13,7 +11,7 @@ export default { title: 'Components/Conversation/ChangeNumberNotification', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Default(): JSX.Element { return ( diff --git a/ts/components/conversation/ChatSessionRefreshedDialog.stories.tsx b/ts/components/conversation/ChatSessionRefreshedDialog.stories.tsx index 9570fa852..8b74be715 100644 --- a/ts/components/conversation/ChatSessionRefreshedDialog.stories.tsx +++ b/ts/components/conversation/ChatSessionRefreshedDialog.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './ChatSessionRefreshedDialog'; import { ChatSessionRefreshedDialog } from './ChatSessionRefreshedDialog'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ChatSessionRefreshedDialog', diff --git a/ts/components/conversation/ChatSessionRefreshedNotification.stories.tsx b/ts/components/conversation/ChatSessionRefreshedNotification.stories.tsx index 0441e86ce..bc189d10f 100644 --- a/ts/components/conversation/ChatSessionRefreshedNotification.stories.tsx +++ b/ts/components/conversation/ChatSessionRefreshedNotification.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './ChatSessionRefreshedNotification'; import { ChatSessionRefreshedNotification } from './ChatSessionRefreshedNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ChatSessionRefreshedNotification', diff --git a/ts/components/conversation/ContactDetail.stories.tsx b/ts/components/conversation/ContactDetail.stories.tsx index 9eab3a3e7..75f5bb99b 100644 --- a/ts/components/conversation/ContactDetail.stories.tsx +++ b/ts/components/conversation/ContactDetail.stories.tsx @@ -7,12 +7,10 @@ import type { Meta } from '@storybook/react'; import type { Props } from './ContactDetail'; import { ContactDetail } from './ContactDetail'; import { AddressType, ContactFormType } from '../../types/EmbeddedContact'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { IMAGE_GIF } from '../../types/MIME'; import { fakeAttachment } from '../../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ContactDetail', diff --git a/ts/components/conversation/ContactModal.stories.tsx b/ts/components/conversation/ContactModal.stories.tsx index 70a1d1e17..a9ce2ebd4 100644 --- a/ts/components/conversation/ContactModal.stories.tsx +++ b/ts/components/conversation/ContactModal.stories.tsx @@ -7,15 +7,13 @@ import casual from 'casual'; import { action } from '@storybook/addon-actions'; import type { ConversationType } from '../../state/ducks/conversations'; import type { PropsType } from './ContactModal'; -import enMessages from '../../../_locales/en/messages.json'; import { ContactModal } from './ContactModal'; import { HasStories } from '../../types/Stories'; import { ThemeType } from '../../types/Util'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import { getFakeBadges } from '../../test-both/helpers/getFakeBadge'; -import { setupI18n } from '../../util/setupI18n'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultContact: ConversationType = getDefaultConversation({ about: '👍 Free to chat', diff --git a/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx b/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx index f6a2d387b..931431d1d 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialog.stories.tsx @@ -5,15 +5,13 @@ import React from 'react'; import { times } from 'lodash'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import type { PropsType } from './ContactSpoofingReviewDialog'; import { ContactSpoofingReviewDialog } from './ContactSpoofingReviewDialog'; import { ContactSpoofingType } from '../../util/contactSpoofing'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ContactSpoofingReviewDialog', diff --git a/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx b/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx index 2203d1650..8ac9848f5 100644 --- a/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx +++ b/ts/components/conversation/ContactSpoofingReviewDialogPerson.stories.tsx @@ -5,15 +5,13 @@ import React from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../../_locales/en/messages.json'; -import { setupI18n } from '../../util/setupI18n'; import { ThemeType } from '../../types/Util'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import type { PropsType } from './ContactSpoofingReviewDialogPerson'; import { ContactSpoofingReviewDialogPerson } from './ContactSpoofingReviewDialogPerson'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { component: ContactSpoofingReviewDialogPerson, diff --git a/ts/components/conversation/ConversationHeader.stories.tsx b/ts/components/conversation/ConversationHeader.stories.tsx index c42b75f1f..31a183d5a 100644 --- a/ts/components/conversation/ConversationHeader.stories.tsx +++ b/ts/components/conversation/ConversationHeader.stories.tsx @@ -10,9 +10,7 @@ import { getDefaultGroup, } from '../../test-both/helpers/getDefaultConversation'; import { getRandomColor } from '../../test-both/helpers/getRandomColor'; -import { setupI18n } from '../../util/setupI18n'; import { DurationInSeconds } from '../../util/durations'; -import enMessages from '../../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext'; import type { PropsType } from './ConversationHeader'; import { @@ -26,7 +24,7 @@ export default { title: 'Components/Conversation/ConversationHeader', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type ItemsType = Array<{ title: string; diff --git a/ts/components/conversation/ConversationHero.stories.tsx b/ts/components/conversation/ConversationHero.stories.tsx index 7dde06413..5a90e1fbd 100644 --- a/ts/components/conversation/ConversationHero.stories.tsx +++ b/ts/components/conversation/ConversationHero.stories.tsx @@ -5,16 +5,14 @@ import type { Meta, StoryFn } from '@storybook/react'; import React, { useContext } from 'react'; import casual from 'casual'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './ConversationHero'; import { ConversationHero } from './ConversationHero'; import { HasStories } from '../../types/Stories'; import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../../util/setupI18n'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationHero', diff --git a/ts/components/conversation/ConversationMergeNotification.stories.tsx b/ts/components/conversation/ConversationMergeNotification.stories.tsx index 1aa6a6db5..b2445e906 100644 --- a/ts/components/conversation/ConversationMergeNotification.stories.tsx +++ b/ts/components/conversation/ConversationMergeNotification.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './ConversationMergeNotification'; import { ConversationMergeNotification } from './ConversationMergeNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationMergeNotification', diff --git a/ts/components/conversation/DeliveryIssueDialog.stories.tsx b/ts/components/conversation/DeliveryIssueDialog.stories.tsx index c0a3a2d03..474d61ce0 100644 --- a/ts/components/conversation/DeliveryIssueDialog.stories.tsx +++ b/ts/components/conversation/DeliveryIssueDialog.stories.tsx @@ -4,13 +4,11 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './DeliveryIssueDialog'; import { DeliveryIssueDialog } from './DeliveryIssueDialog'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const sender = getDefaultConversation(); export default { diff --git a/ts/components/conversation/DeliveryIssueNotification.stories.tsx b/ts/components/conversation/DeliveryIssueNotification.stories.tsx index 6bf736cdd..9eae5110a 100644 --- a/ts/components/conversation/DeliveryIssueNotification.stories.tsx +++ b/ts/components/conversation/DeliveryIssueNotification.stories.tsx @@ -3,8 +3,6 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './DeliveryIssueNotification'; import { DeliveryIssueNotification } from './DeliveryIssueNotification'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; @@ -13,7 +11,7 @@ export default { title: 'Components/Conversation/DeliveryIssueNotification', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const sender = getDefaultConversation(); export function Default(): JSX.Element { diff --git a/ts/components/conversation/ErrorBoundary.stories.tsx b/ts/components/conversation/ErrorBoundary.stories.tsx index 8e574ae52..9f2b59d1e 100644 --- a/ts/components/conversation/ErrorBoundary.stories.tsx +++ b/ts/components/conversation/ErrorBoundary.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './ErrorBoundary'; import { ErrorBoundary } from './ErrorBoundary'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ErrorBoundary', diff --git a/ts/components/conversation/GroupDescription.stories.tsx b/ts/components/conversation/GroupDescription.stories.tsx index 01dd57e71..7c3a0465c 100644 --- a/ts/components/conversation/GroupDescription.stories.tsx +++ b/ts/components/conversation/GroupDescription.stories.tsx @@ -5,10 +5,8 @@ import React from 'react'; import type { Meta } from '@storybook/react'; import type { PropsType } from './GroupDescription'; import { GroupDescription } from './GroupDescription'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/GroupDescription', diff --git a/ts/components/conversation/GroupNotification.stories.tsx b/ts/components/conversation/GroupNotification.stories.tsx index e90d2e6c9..f6d915046 100644 --- a/ts/components/conversation/GroupNotification.stories.tsx +++ b/ts/components/conversation/GroupNotification.stories.tsx @@ -3,8 +3,6 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './GroupNotification'; import { GroupNotification } from './GroupNotification'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; @@ -13,7 +11,7 @@ export default { title: 'Components/Conversation', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type GroupNotificationStory = [string, Array]; diff --git a/ts/components/conversation/GroupV1DisabledActions.stories.tsx b/ts/components/conversation/GroupV1DisabledActions.stories.tsx index 39a098d05..60c867763 100644 --- a/ts/components/conversation/GroupV1DisabledActions.stories.tsx +++ b/ts/components/conversation/GroupV1DisabledActions.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType as GroupV1DisabledActionsPropsType } from './GroupV1DisabledActions'; import { GroupV1DisabledActions } from './GroupV1DisabledActions'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): GroupV1DisabledActionsPropsType => ({ conversationId: '123', diff --git a/ts/components/conversation/GroupV1Migration.stories.tsx b/ts/components/conversation/GroupV1Migration.stories.tsx index 77b4a0e38..49424db1c 100644 --- a/ts/components/conversation/GroupV1Migration.stories.tsx +++ b/ts/components/conversation/GroupV1Migration.stories.tsx @@ -4,13 +4,11 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './GroupV1Migration'; import { GroupV1Migration } from './GroupV1Migration'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const contact1 = getDefaultConversation({ title: 'Alice', diff --git a/ts/components/conversation/GroupV2Change.stories.tsx b/ts/components/conversation/GroupV2Change.stories.tsx index be4741895..8b4e666b4 100644 --- a/ts/components/conversation/GroupV2Change.stories.tsx +++ b/ts/components/conversation/GroupV2Change.stories.tsx @@ -4,10 +4,8 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; import { generateAci, generatePni } from '../../types/ServiceId'; import type { ServiceIdString, AciString } from '../../types/ServiceId'; -import enMessages from '../../../_locales/en/messages.json'; import type { GroupV2ChangeType } from '../../groups'; import { SignalService as Proto } from '../../protobuf'; import type { SmartContactRendererType } from '../../groupChange'; @@ -17,7 +15,7 @@ import { GroupV2Change } from './GroupV2Change'; // Note: this should be kept up to date with backup_groupv2_notifications_test.ts, to // maintain the comprehensive set of GroupV2 notifications we need to handle -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const OUR_ACI = generateAci(); const OUR_PNI = generatePni(); diff --git a/ts/components/conversation/GroupV2PendingApprovalActions.stories.tsx b/ts/components/conversation/GroupV2PendingApprovalActions.stories.tsx index caa5799ae..3ad71ffe3 100644 --- a/ts/components/conversation/GroupV2PendingApprovalActions.stories.tsx +++ b/ts/components/conversation/GroupV2PendingApprovalActions.stories.tsx @@ -6,10 +6,8 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { PropsType as GroupV2PendingApprovalActionsPropsType } from './GroupV2PendingApprovalActions'; import { GroupV2PendingApprovalActions } from './GroupV2PendingApprovalActions'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = (): GroupV2PendingApprovalActionsPropsType => ({ cancelJoinRequest: action('cancelJoinRequest'), diff --git a/ts/components/conversation/Image.stories.tsx b/ts/components/conversation/Image.stories.tsx index c65f446a6..25e8b4336 100644 --- a/ts/components/conversation/Image.stories.tsx +++ b/ts/components/conversation/Image.stories.tsx @@ -9,13 +9,11 @@ import type { Props } from './Image'; import { CurveType, Image } from './Image'; import { IMAGE_PNG } from '../../types/MIME'; import type { ThemeType } from '../../types/Util'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext'; import { fakeAttachment } from '../../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/Image', diff --git a/ts/components/conversation/ImageGrid.stories.tsx b/ts/components/conversation/ImageGrid.stories.tsx index 3d3e63fff..6c0d26204 100644 --- a/ts/components/conversation/ImageGrid.stories.tsx +++ b/ts/components/conversation/ImageGrid.stories.tsx @@ -14,12 +14,10 @@ import { VIDEO_MP4, stringToMIMEType, } from '../../types/MIME'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { pngUrl, squareStickerUrl } from '../../storybook/Fixtures'; import { fakeAttachment } from '../../test-both/helpers/fakeAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ImageGrid', diff --git a/ts/components/conversation/JoinedSignalNotification.stories.tsx b/ts/components/conversation/JoinedSignalNotification.stories.tsx index 956cde44c..51fba3e8d 100644 --- a/ts/components/conversation/JoinedSignalNotification.stories.tsx +++ b/ts/components/conversation/JoinedSignalNotification.stories.tsx @@ -3,8 +3,6 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './JoinedSignalNotification'; import { JoinedSignalNotification } from './JoinedSignalNotification'; @@ -12,7 +10,7 @@ export default { title: 'Components/Conversation/JoinedSignalNotification', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Default(): JSX.Element { return ; diff --git a/ts/components/conversation/LastSeenIndicator.stories.tsx b/ts/components/conversation/LastSeenIndicator.stories.tsx index e659a29d3..87006783d 100644 --- a/ts/components/conversation/LastSeenIndicator.stories.tsx +++ b/ts/components/conversation/LastSeenIndicator.stories.tsx @@ -5,10 +5,8 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import type { Props } from './LastSeenIndicator'; import { LastSeenIndicator } from './LastSeenIndicator'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/LastSeenIndicator', diff --git a/ts/components/conversation/MandatoryProfileSharingActions.stories.tsx b/ts/components/conversation/MandatoryProfileSharingActions.stories.tsx index 48a5fcac0..0af7b9dd1 100644 --- a/ts/components/conversation/MandatoryProfileSharingActions.stories.tsx +++ b/ts/components/conversation/MandatoryProfileSharingActions.stories.tsx @@ -6,14 +6,12 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './MandatoryProfileSharingActions'; import { MandatoryProfileSharingActions } from './MandatoryProfileSharingActions'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation, getDefaultGroup, } from '../../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type Args = { conversationType: 'direct' | 'group'; diff --git a/ts/components/conversation/MessageBody.stories.tsx b/ts/components/conversation/MessageBody.stories.tsx index 4cb30b80e..2e59438c0 100644 --- a/ts/components/conversation/MessageBody.stories.tsx +++ b/ts/components/conversation/MessageBody.stories.tsx @@ -6,8 +6,6 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './MessageBody'; import { MessageBody } from './MessageBody'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { BodyRange } from '../../types/BodyRange'; import { generateAci } from '../../types/ServiceId'; import { RenderLocation } from './MessageTextRenderer'; @@ -24,7 +22,7 @@ const SERVICE_ID_9 = generateAci(); const SERVICE_ID_10 = generateAci(); const SERVICE_ID_11 = generateAci(); -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/MessageBody', diff --git a/ts/components/conversation/MessageBodyReadMore.stories.tsx b/ts/components/conversation/MessageBodyReadMore.stories.tsx index 27e3f8f32..871f03dcc 100644 --- a/ts/components/conversation/MessageBodyReadMore.stories.tsx +++ b/ts/components/conversation/MessageBodyReadMore.stories.tsx @@ -6,14 +6,12 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './MessageBodyReadMore'; import { MessageBodyReadMore } from './MessageBodyReadMore'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { HydratedBodyRangesType } from '../../types/BodyRange'; import { BodyRange } from '../../types/BodyRange'; import { generateAci } from '../../types/ServiceId'; import { RenderLocation } from './MessageTextRenderer'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/MessageBodyReadMore', diff --git a/ts/components/conversation/MessageDetail.stories.tsx b/ts/components/conversation/MessageDetail.stories.tsx index d0992d57c..d733af246 100644 --- a/ts/components/conversation/MessageDetail.stories.tsx +++ b/ts/components/conversation/MessageDetail.stories.tsx @@ -11,12 +11,10 @@ import { MessageDetail } from './MessageDetail'; import { SendStatus } from '../../messages/MessageSendState'; import { ReadStatus } from '../../messages/MessageReadStatus'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getFakeBadge } from '../../test-both/helpers/getFakeBadge'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const defaultMessage: MessageDataPropsType = { author: getDefaultConversation({ diff --git a/ts/components/conversation/MessageRequestActions.stories.tsx b/ts/components/conversation/MessageRequestActions.stories.tsx index 54ec5a3ce..42fb555a5 100644 --- a/ts/components/conversation/MessageRequestActions.stories.tsx +++ b/ts/components/conversation/MessageRequestActions.stories.tsx @@ -5,14 +5,12 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import { MessageRequestActions } from './MessageRequestActions'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation, getDefaultGroup, } from '../../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type Args = { conversationType: 'direct' | 'group'; diff --git a/ts/components/conversation/MessageTimestamp.stories.tsx b/ts/components/conversation/MessageTimestamp.stories.tsx index eb2f0a735..a412f1559 100644 --- a/ts/components/conversation/MessageTimestamp.stories.tsx +++ b/ts/components/conversation/MessageTimestamp.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './MessageTimestamp'; import { MessageTimestamp } from './MessageTimestamp'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const { now } = Date; const seconds = (n: number) => n * 1000; diff --git a/ts/components/conversation/PhoneNumberDiscoveryNotification.stories.tsx b/ts/components/conversation/PhoneNumberDiscoveryNotification.stories.tsx index f60145762..369f74a28 100644 --- a/ts/components/conversation/PhoneNumberDiscoveryNotification.stories.tsx +++ b/ts/components/conversation/PhoneNumberDiscoveryNotification.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './PhoneNumberDiscoveryNotification'; import { PhoneNumberDiscoveryNotification } from './PhoneNumberDiscoveryNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/PhoneNumberDiscoveryNotification', diff --git a/ts/components/conversation/ProfileChangeNotification.stories.tsx b/ts/components/conversation/ProfileChangeNotification.stories.tsx index 2e41569ef..1af6612af 100644 --- a/ts/components/conversation/ProfileChangeNotification.stories.tsx +++ b/ts/components/conversation/ProfileChangeNotification.stories.tsx @@ -5,12 +5,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './ProfileChangeNotification'; import { ProfileChangeNotification } from './ProfileChangeNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ProfileChangeNotification', diff --git a/ts/components/conversation/Quote.stories.tsx b/ts/components/conversation/Quote.stories.tsx index 99360270a..49cb4741c 100644 --- a/ts/components/conversation/Quote.stories.tsx +++ b/ts/components/conversation/Quote.stories.tsx @@ -21,14 +21,12 @@ import { import type { Props } from './Quote'; import { Quote } from './Quote'; import { ReadStatus } from '../../messages/MessageReadStatus'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import { WidthBreakpoint } from '../_util'; import { ThemeType } from '../../types/Util'; import { PaymentEventKind } from '../../types/Payment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { component: Quote, diff --git a/ts/components/conversation/ReactionPicker.stories.tsx b/ts/components/conversation/ReactionPicker.stories.tsx index 739a09220..45f0fab9c 100644 --- a/ts/components/conversation/ReactionPicker.stories.tsx +++ b/ts/components/conversation/ReactionPicker.stories.tsx @@ -4,14 +4,12 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props as ReactionPickerProps } from './ReactionPicker'; import { ReactionPicker } from './ReactionPicker'; import { EmojiPicker } from '../emoji/EmojiPicker'; import { DEFAULT_PREFERRED_REACTION_EMOJI } from '../../reactions/constants'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const renderEmojiPicker: ReactionPickerProps['renderEmojiPicker'] = ({ onClose, diff --git a/ts/components/conversation/ReactionViewer.stories.tsx b/ts/components/conversation/ReactionViewer.stories.tsx index 2a78ddfc1..e3d46bd21 100644 --- a/ts/components/conversation/ReactionViewer.stories.tsx +++ b/ts/components/conversation/ReactionViewer.stories.tsx @@ -6,12 +6,10 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './ReactionViewer'; import { ReactionViewer } from './ReactionViewer'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ReactionViewer', diff --git a/ts/components/conversation/ResetSessionNotification.stories.tsx b/ts/components/conversation/ResetSessionNotification.stories.tsx index 7b02146b5..6e6a9badf 100644 --- a/ts/components/conversation/ResetSessionNotification.stories.tsx +++ b/ts/components/conversation/ResetSessionNotification.stories.tsx @@ -5,10 +5,8 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; import type { Props } from './ResetSessionNotification'; import { ResetSessionNotification } from './ResetSessionNotification'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ResetSessionNotification', diff --git a/ts/components/conversation/SafetyNumberNotification.stories.tsx b/ts/components/conversation/SafetyNumberNotification.stories.tsx index 20c91cf88..7ba2435d5 100644 --- a/ts/components/conversation/SafetyNumberNotification.stories.tsx +++ b/ts/components/conversation/SafetyNumberNotification.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { ContactType, Props } from './SafetyNumberNotification'; import { SafetyNumberNotification } from './SafetyNumberNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createContact = (props: Partial): ContactType => ({ id: '', diff --git a/ts/components/conversation/ScrollDownButton.stories.tsx b/ts/components/conversation/ScrollDownButton.stories.tsx index 55842b527..0748686d1 100644 --- a/ts/components/conversation/ScrollDownButton.stories.tsx +++ b/ts/components/conversation/ScrollDownButton.stories.tsx @@ -5,12 +5,10 @@ import * as React from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { ScrollDownButtonPropsType } from './ScrollDownButton'; import { ScrollDownButton, ScrollDownButtonVariant } from './ScrollDownButton'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const createProps = ( overrideProps: Partial = {} diff --git a/ts/components/conversation/StagedGenericAttachment.stories.tsx b/ts/components/conversation/StagedGenericAttachment.stories.tsx index 5b17fa317..d7f7fcac4 100644 --- a/ts/components/conversation/StagedGenericAttachment.stories.tsx +++ b/ts/components/conversation/StagedGenericAttachment.stories.tsx @@ -6,12 +6,10 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { AttachmentType } from '../../types/Attachment'; import { stringToMIMEType } from '../../types/MIME'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './StagedGenericAttachment'; import { StagedGenericAttachment } from './StagedGenericAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/StagedGenericAttachment', diff --git a/ts/components/conversation/StagedLinkPreview.stories.tsx b/ts/components/conversation/StagedLinkPreview.stories.tsx index ab3b8746e..4f0c09e60 100644 --- a/ts/components/conversation/StagedLinkPreview.stories.tsx +++ b/ts/components/conversation/StagedLinkPreview.stories.tsx @@ -6,10 +6,8 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Props } from './StagedLinkPreview'; -import enMessages from '../../../_locales/en/messages.json'; import { StagedLinkPreview } from './StagedLinkPreview'; import { fakeAttachment } from '../../test-both/helpers/fakeAttachment'; -import { setupI18n } from '../../util/setupI18n'; import { IMAGE_JPEG } from '../../types/MIME'; const LONG_TITLE = @@ -17,7 +15,7 @@ const LONG_TITLE = const LONG_DESCRIPTION = "You're gonna love this description. Not only does it have a lot of characters, but it will also be truncated in the UI. How cool is that??"; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/StagedLinkPreview', diff --git a/ts/components/conversation/StagedPlaceholderAttachment.stories.tsx b/ts/components/conversation/StagedPlaceholderAttachment.stories.tsx index 57456b6b7..5bb4a9b69 100644 --- a/ts/components/conversation/StagedPlaceholderAttachment.stories.tsx +++ b/ts/components/conversation/StagedPlaceholderAttachment.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './StagedPlaceholderAttachment'; import { StagedPlaceholderAttachment } from './StagedPlaceholderAttachment'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/StagedPlaceholderAttachment', diff --git a/ts/components/conversation/Timeline.stories.tsx b/ts/components/conversation/Timeline.stories.tsx index 148fb3c0d..701d9ac77 100644 --- a/ts/components/conversation/Timeline.stories.tsx +++ b/ts/components/conversation/Timeline.stories.tsx @@ -6,9 +6,7 @@ import { times } from 'lodash'; import { v4 as uuid } from 'uuid'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; import { DurationInSeconds } from '../../util/durations'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './Timeline'; import { Timeline } from './Timeline'; import type { TimelineItemType } from './TimelineItem'; @@ -26,7 +24,7 @@ import { PaymentEventKind } from '../../types/Payment'; import type { PropsData as TimelineMessageProps } from './TimelineMessage'; import { CollidingAvatars } from '../CollidingAvatars'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const alice = getDefaultConversation(); const bob = getDefaultConversation(); diff --git a/ts/components/conversation/TimelineFloatingHeader.stories.tsx b/ts/components/conversation/TimelineFloatingHeader.stories.tsx index c67ca841a..99e14823c 100644 --- a/ts/components/conversation/TimelineFloatingHeader.stories.tsx +++ b/ts/components/conversation/TimelineFloatingHeader.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './TimelineFloatingHeader'; import { TimelineFloatingHeader } from './TimelineFloatingHeader'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/TimelineFloatingHeader', diff --git a/ts/components/conversation/TimelineItem.stories.tsx b/ts/components/conversation/TimelineItem.stories.tsx index f849580c8..baa75e53f 100644 --- a/ts/components/conversation/TimelineItem.stories.tsx +++ b/ts/components/conversation/TimelineItem.stories.tsx @@ -5,9 +5,7 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import { EmojiPicker } from '../emoji/EmojiPicker'; -import { setupI18n } from '../../util/setupI18n'; import { DurationInSeconds } from '../../util/durations'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType as TimelineItemProps } from './TimelineItem'; import { TimelineItem } from './TimelineItem'; import { UniversalTimerNotification } from './UniversalTimerNotification'; @@ -19,7 +17,7 @@ import { ThemeType } from '../../types/Util'; import { PaymentEventKind } from '../../types/Payment'; import { ErrorBoundary } from './ErrorBoundary'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const renderEmojiPicker: TimelineItemProps['renderEmojiPicker'] = ({ onClose, @@ -27,7 +25,7 @@ const renderEmojiPicker: TimelineItemProps['renderEmojiPicker'] = ({ ref, }) => ( ( ; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Default(): JSX.Element { return ; diff --git a/ts/components/conversation/TypingAnimation.stories.tsx b/ts/components/conversation/TypingAnimation.stories.tsx index 714f832fc..dddba724f 100644 --- a/ts/components/conversation/TypingAnimation.stories.tsx +++ b/ts/components/conversation/TypingAnimation.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './TypingAnimation'; import { TypingAnimation } from './TypingAnimation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/TypingAnimation', diff --git a/ts/components/conversation/TypingBubble.stories.tsx b/ts/components/conversation/TypingBubble.stories.tsx index aed503684..7adfcb0ea 100644 --- a/ts/components/conversation/TypingBubble.stories.tsx +++ b/ts/components/conversation/TypingBubble.stories.tsx @@ -6,15 +6,13 @@ import { times } from 'lodash'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { TypingBubblePropsType } from './TypingBubble'; import { TypingBubble } from './TypingBubble'; import { AvatarColors } from '../../types/Colors'; import { getFakeBadge } from '../../test-both/helpers/getFakeBadge'; import { ThemeType } from '../../types/Util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/TypingBubble', diff --git a/ts/components/conversation/UniversalTimerNotification.stories.tsx b/ts/components/conversation/UniversalTimerNotification.stories.tsx index 6c89ffa3e..4a601463c 100644 --- a/ts/components/conversation/UniversalTimerNotification.stories.tsx +++ b/ts/components/conversation/UniversalTimerNotification.stories.tsx @@ -5,15 +5,13 @@ import React from 'react'; import type { Meta } from '@storybook/react'; import type { Props } from './UniversalTimerNotification'; import { UniversalTimerNotification } from './UniversalTimerNotification'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { EXPIRE_TIMERS } from '../../test-both/util/expireTimers'; export default { title: 'Components/UniversalTimerNotification', } satisfies Meta; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export function Seconds(): JSX.Element { return ( diff --git a/ts/components/conversation/UnsupportedMessage.stories.tsx b/ts/components/conversation/UnsupportedMessage.stories.tsx index 5af325a46..05d117815 100644 --- a/ts/components/conversation/UnsupportedMessage.stories.tsx +++ b/ts/components/conversation/UnsupportedMessage.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { ContactType, Props } from './UnsupportedMessage'; import { UnsupportedMessage } from './UnsupportedMessage'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/UnsupportedMessage', diff --git a/ts/components/conversation/VerificationNotification.stories.tsx b/ts/components/conversation/VerificationNotification.stories.tsx index 473883c5e..38f9ced23 100644 --- a/ts/components/conversation/VerificationNotification.stories.tsx +++ b/ts/components/conversation/VerificationNotification.stories.tsx @@ -3,12 +3,10 @@ import * as React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './VerificationNotification'; import { VerificationNotification } from './VerificationNotification'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const contact = { title: 'Mr. Fire' }; diff --git a/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx b/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx index 406a18361..dfcf10990 100644 --- a/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx +++ b/ts/components/conversation/conversation-details/AddGroupMembersModal.stories.tsx @@ -9,9 +9,7 @@ import type { Meta } from '@storybook/react'; import { sleep } from '../../../util/sleep'; import { makeLookup } from '../../../util/makeLookup'; import { deconstructLookup } from '../../../util/deconstructLookup'; -import { setupI18n } from '../../../util/setupI18n'; import type { ConversationType } from '../../../state/ducks/conversations'; -import enMessages from '../../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; import { AddGroupMembersModal } from './AddGroupMembersModal'; import { ChooseGroupMembersModal } from './AddGroupMembersModal/ChooseGroupMembersModal'; @@ -20,7 +18,7 @@ import { RequestState } from './util'; import { ThemeType } from '../../../types/Util'; import { makeFakeLookupConversationWithoutServiceId } from '../../../test-both/helpers/fakeLookupConversationWithoutServiceId'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/AddGroupMembersModal', diff --git a/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx index 2476abcf1..4bb454470 100644 --- a/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetails.stories.tsx @@ -7,8 +7,6 @@ import { action } from '@storybook/addon-actions'; import { times } from 'lodash'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { Props } from './ConversationDetails'; import { ConversationDetails } from './ConversationDetails'; import { ChooseGroupMembersModal } from './AddGroupMembersModal/ChooseGroupMembersModal'; @@ -21,7 +19,7 @@ import { DurationInSeconds } from '../../../util/durations'; import { NavTab } from '../../../state/ducks/nav'; import { getFakeCallHistoryGroup } from '../../../test-both/helpers/getFakeCallHistoryGroup'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/ConversationDetails', diff --git a/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx index f18681bac..093c198e2 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx @@ -5,12 +5,10 @@ import * as React from 'react'; import { isBoolean } from 'lodash'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { Props } from './ConversationDetailsActions'; import { ConversationDetailsActions } from './ConversationDetailsActions'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: diff --git a/ts/components/conversation/conversation-details/ConversationDetailsHeader.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetailsHeader.stories.tsx index 6286dfd1d..1ac129f79 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsHeader.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsHeader.stories.tsx @@ -6,14 +6,12 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; import { getFakeBadges } from '../../../test-both/helpers/getFakeBadge'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../../../.storybook/StorybookThemeContext'; import type { ConversationType } from '../../../state/ducks/conversations'; import type { Props } from './ConversationDetailsHeader'; import { ConversationDetailsHeader } from './ConversationDetailsHeader'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: diff --git a/ts/components/conversation/conversation-details/ConversationDetailsMediaList.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetailsMediaList.stories.tsx index 1364f4c25..2c6948ee1 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsMediaList.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsMediaList.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { Props } from './ConversationDetailsMediaList'; import { ConversationDetailsMediaList } from './ConversationDetailsMediaList'; import type { MediaItemType } from '../../../types/MediaItem'; @@ -15,7 +13,7 @@ import { createRandomMedia, } from '../media-gallery/utils/mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/ConversationMediaList', diff --git a/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.stories.tsx b/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.stories.tsx index c2a5ef6a0..6a70f9130 100644 --- a/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationDetailsMembershipList.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; import { ThemeType } from '../../../types/Util'; @@ -15,7 +13,7 @@ import type { } from './ConversationDetailsMembershipList'; import { ConversationDetailsMembershipList } from './ConversationDetailsMembershipList'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: diff --git a/ts/components/conversation/conversation-details/ConversationNotificationsSettings.stories.tsx b/ts/components/conversation/conversation-details/ConversationNotificationsSettings.stories.tsx index 511cdd32b..a558da731 100644 --- a/ts/components/conversation/conversation-details/ConversationNotificationsSettings.stories.tsx +++ b/ts/components/conversation/conversation-details/ConversationNotificationsSettings.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { PropsType } from './ConversationNotificationsSettings'; import { ConversationNotificationsSettings } from './ConversationNotificationsSettings'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: diff --git a/ts/components/conversation/conversation-details/EditConversationAttributesModal.stories.tsx b/ts/components/conversation/conversation-details/EditConversationAttributesModal.stories.tsx index af3b1d297..d7d42b42b 100644 --- a/ts/components/conversation/conversation-details/EditConversationAttributesModal.stories.tsx +++ b/ts/components/conversation/conversation-details/EditConversationAttributesModal.stories.tsx @@ -5,12 +5,10 @@ import type { ComponentProps } from 'react'; import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import { EditConversationAttributesModal } from './EditConversationAttributesModal'; import { RequestState } from './util'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: diff --git a/ts/components/conversation/conversation-details/GroupLinkManagement.stories.tsx b/ts/components/conversation/conversation-details/GroupLinkManagement.stories.tsx index 501a99aa2..000507f32 100644 --- a/ts/components/conversation/conversation-details/GroupLinkManagement.stories.tsx +++ b/ts/components/conversation/conversation-details/GroupLinkManagement.stories.tsx @@ -4,15 +4,13 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { PropsType } from './GroupLinkManagement'; import { GroupLinkManagement } from './GroupLinkManagement'; import { SignalService as Proto } from '../../../protobuf'; import type { ConversationType } from '../../../state/ducks/conversations'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/GroupLinkManagement', diff --git a/ts/components/conversation/conversation-details/GroupV2Permissions.stories.tsx b/ts/components/conversation/conversation-details/GroupV2Permissions.stories.tsx index 63c23f907..5b3ba32c0 100644 --- a/ts/components/conversation/conversation-details/GroupV2Permissions.stories.tsx +++ b/ts/components/conversation/conversation-details/GroupV2Permissions.stories.tsx @@ -4,14 +4,12 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { PropsType } from './GroupV2Permissions'; import { GroupV2Permissions } from './GroupV2Permissions'; import type { ConversationType } from '../../../state/ducks/conversations'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/GroupV2Permissions', diff --git a/ts/components/conversation/conversation-details/PendingInvites.stories.tsx b/ts/components/conversation/conversation-details/PendingInvites.stories.tsx index 069b7a91b..5934e5343 100644 --- a/ts/components/conversation/conversation-details/PendingInvites.stories.tsx +++ b/ts/components/conversation/conversation-details/PendingInvites.stories.tsx @@ -7,8 +7,6 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import { generateAci } from '../../../types/ServiceId'; import { StorySendMode } from '../../../types/Stories'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { PropsType } from './PendingInvites'; import { PendingInvites } from './PendingInvites'; import type { ConversationType } from '../../../state/ducks/conversations'; @@ -16,7 +14,7 @@ import { getDefaultConversation } from '../../../test-both/helpers/getDefaultCon import { getFakeBadge } from '../../../test-both/helpers/getFakeBadge'; import { StorybookThemeContext } from '../../../../.storybook/StorybookThemeContext'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/ConversationDetails/PendingInvites', diff --git a/ts/components/conversation/media-gallery/AttachmentSection.stories.tsx b/ts/components/conversation/media-gallery/AttachmentSection.stories.tsx index f69a850f1..321ddb599 100644 --- a/ts/components/conversation/media-gallery/AttachmentSection.stories.tsx +++ b/ts/components/conversation/media-gallery/AttachmentSection.stories.tsx @@ -6,13 +6,11 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { Props } from './AttachmentSection'; import { AttachmentSection } from './AttachmentSection'; import { createRandomDocuments, createRandomMedia, days } from './utils/mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/MediaGallery/AttachmentSection', diff --git a/ts/components/conversation/media-gallery/MediaGallery.stories.tsx b/ts/components/conversation/media-gallery/MediaGallery.stories.tsx index 40cd2ca13..8d7d788bc 100644 --- a/ts/components/conversation/media-gallery/MediaGallery.stories.tsx +++ b/ts/components/conversation/media-gallery/MediaGallery.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { Props } from './MediaGallery'; import { MediaGallery } from './MediaGallery'; import { @@ -15,7 +13,7 @@ import { days, } from './utils/mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/MediaGallery/MediaGallery', diff --git a/ts/components/conversation/media-gallery/MediaGridItem.stories.tsx b/ts/components/conversation/media-gallery/MediaGridItem.stories.tsx index 677208c33..26d66a5d1 100644 --- a/ts/components/conversation/media-gallery/MediaGridItem.stories.tsx +++ b/ts/components/conversation/media-gallery/MediaGridItem.stories.tsx @@ -4,15 +4,13 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../../util/setupI18n'; -import enMessages from '../../../../_locales/en/messages.json'; import type { MediaItemType } from '../../../types/MediaItem'; import type { AttachmentType } from '../../../types/Attachment'; import { stringToMIMEType } from '../../../types/MIME'; import type { Props } from './MediaGridItem'; import { MediaGridItem } from './MediaGridItem'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Conversation/MediaGallery/MediaGridItem', diff --git a/ts/components/conversationList/MessageSearchResult.stories.tsx b/ts/components/conversationList/MessageSearchResult.stories.tsx index c9c9fa857..969aa1013 100644 --- a/ts/components/conversationList/MessageSearchResult.stories.tsx +++ b/ts/components/conversationList/MessageSearchResult.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { StorybookThemeContext } from '../../../.storybook/StorybookThemeContext'; import { strictAssert } from '../../util/assert'; import { getFakeBadge } from '../../test-both/helpers/getFakeBadge'; @@ -19,7 +17,7 @@ const SERVICE_ID_1 = generateAci(); const SERVICE_ID_2 = generateAci(); const SERVICE_ID_3 = generateAci(); -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/MessageSearchResult', diff --git a/ts/components/emoji/EmojiButton.stories.tsx b/ts/components/emoji/EmojiButton.stories.tsx index 72a890262..c079a6de2 100644 --- a/ts/components/emoji/EmojiButton.stories.tsx +++ b/ts/components/emoji/EmojiButton.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './EmojiButton'; import { EmojiButton } from './EmojiButton'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Emoji/EmojiButton', diff --git a/ts/components/emoji/EmojiPicker.stories.tsx b/ts/components/emoji/EmojiPicker.stories.tsx index 85830ddbd..d0bad4488 100644 --- a/ts/components/emoji/EmojiPicker.stories.tsx +++ b/ts/components/emoji/EmojiPicker.stories.tsx @@ -4,12 +4,10 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './EmojiPicker'; import { EmojiPicker } from './EmojiPicker'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Emoji/EmojiPicker', diff --git a/ts/components/fun/FunEmojiPicker.stories.tsx b/ts/components/fun/FunEmojiPicker.stories.tsx index 69a4b27e2..23f0657d8 100644 --- a/ts/components/fun/FunEmojiPicker.stories.tsx +++ b/ts/components/fun/FunEmojiPicker.stories.tsx @@ -3,9 +3,7 @@ import React, { StrictMode } from 'react'; import { Button } from 'react-aria-components'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../../_locales/en/messages.json'; import { type ComponentMeta } from '../../storybook/types'; -import { setupI18n } from '../../util/setupI18n'; import type { FunEmojiPickerProps } from './FunEmojiPicker'; import { FunEmojiPicker } from './FunEmojiPicker'; import { MOCK_RECENT_EMOJIS } from './mocks'; @@ -13,7 +11,7 @@ import { FunProvider } from './FunProvider'; import { packs, recentStickers } from '../stickers/mocks'; import { EmojiSkinTone } from './data/emojis'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type TemplateProps = Omit; diff --git a/ts/components/fun/FunPicker.stories.tsx b/ts/components/fun/FunPicker.stories.tsx index 9b63673e3..f9cb29f15 100644 --- a/ts/components/fun/FunPicker.stories.tsx +++ b/ts/components/fun/FunPicker.stories.tsx @@ -3,9 +3,7 @@ import React, { StrictMode } from 'react'; import { Button } from 'react-aria-components'; import { action } from '@storybook/addon-actions'; -import enMessages from '../../../_locales/en/messages.json'; import { type ComponentMeta } from '../../storybook/types'; -import { setupI18n } from '../../util/setupI18n'; import { packs, recentStickers } from '../stickers/mocks'; import type { FunPickerProps } from './FunPicker'; import { FunPicker } from './FunPicker'; @@ -13,7 +11,7 @@ import { FunProvider } from './FunProvider'; import { MOCK_RECENT_EMOJIS } from './mocks'; import { EmojiSkinTone } from './data/emojis'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; type TemplateProps = Omit; diff --git a/ts/components/installScreen/InstallScreenBackupImportStep.stories.tsx b/ts/components/installScreen/InstallScreenBackupImportStep.stories.tsx index e569f386b..54eae5eb2 100644 --- a/ts/components/installScreen/InstallScreenBackupImportStep.stories.tsx +++ b/ts/components/installScreen/InstallScreenBackupImportStep.stories.tsx @@ -4,18 +4,16 @@ import React, { useState, useCallback, useEffect } from 'react'; import type { Meta, StoryFn } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import { setupI18n } from '../../util/setupI18n'; import { sleep } from '../../util/sleep'; import { InstallScreenBackupStep, InstallScreenBackupError, } from '../../types/InstallScreen'; import { DialogType } from '../../types/Dialogs'; -import enMessages from '../../../_locales/en/messages.json'; import type { PropsType } from './InstallScreenBackupImportStep'; import { InstallScreenBackupImportStep } from './InstallScreenBackupImportStep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const DEFAULT_UPDATES = { dialogType: DialogType.None, diff --git a/ts/components/installScreen/InstallScreenErrorStep.stories.tsx b/ts/components/installScreen/InstallScreenErrorStep.stories.tsx index c044524da..458b9ba90 100644 --- a/ts/components/installScreen/InstallScreenErrorStep.stories.tsx +++ b/ts/components/installScreen/InstallScreenErrorStep.stories.tsx @@ -4,13 +4,11 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; import { InstallScreenError } from '../../types/InstallScreen'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './InstallScreenErrorStep'; import { InstallScreenErrorStep } from './InstallScreenErrorStep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/InstallScreen/InstallScreenErrorStep', diff --git a/ts/components/installScreen/InstallScreenLinkInProgress.stories.tsx b/ts/components/installScreen/InstallScreenLinkInProgress.stories.tsx index f42792ec2..d7bde45d5 100644 --- a/ts/components/installScreen/InstallScreenLinkInProgress.stories.tsx +++ b/ts/components/installScreen/InstallScreenLinkInProgress.stories.tsx @@ -3,12 +3,10 @@ import React from 'react'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './InstallScreenLinkInProgressStep'; import { InstallScreenLinkInProgressStep } from './InstallScreenLinkInProgressStep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/InstallScreen/InstallScreenLinkInProgressStep', diff --git a/ts/components/installScreen/InstallScreenQrCodeNotScannedStep.stories.tsx b/ts/components/installScreen/InstallScreenQrCodeNotScannedStep.stories.tsx index 83a33f64b..dc53d572b 100644 --- a/ts/components/installScreen/InstallScreenQrCodeNotScannedStep.stories.tsx +++ b/ts/components/installScreen/InstallScreenQrCodeNotScannedStep.stories.tsx @@ -4,16 +4,14 @@ import React, { useEffect, useState } from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta, StoryFn } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; import { DialogType } from '../../types/Dialogs'; import { InstallScreenQRCodeError } from '../../types/InstallScreen'; -import enMessages from '../../../_locales/en/messages.json'; import type { Loadable } from '../../util/loadable'; import { LoadingState } from '../../util/loadable'; import type { PropsType } from './InstallScreenQrCodeNotScannedStep'; import { InstallScreenQrCodeNotScannedStep } from './InstallScreenQrCodeNotScannedStep'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; const LOADED_URL = { loadingState: LoadingState.Loaded as const, diff --git a/ts/components/stickers/StickerButton.stories.tsx b/ts/components/stickers/StickerButton.stories.tsx index b8c2ac50f..dd9510751 100644 --- a/ts/components/stickers/StickerButton.stories.tsx +++ b/ts/components/stickers/StickerButton.stories.tsx @@ -4,8 +4,6 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './StickerButton'; import { StickerButton } from './StickerButton'; import { @@ -16,7 +14,7 @@ import { wideSticker, } from './mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Stickers/StickerButton', diff --git a/ts/components/stickers/StickerManager.stories.tsx b/ts/components/stickers/StickerManager.stories.tsx index cba68a01b..117c922c5 100644 --- a/ts/components/stickers/StickerManager.stories.tsx +++ b/ts/components/stickers/StickerManager.stories.tsx @@ -4,13 +4,11 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './StickerManager'; import { StickerManager } from './StickerManager'; import { createPack, sticker1, sticker2 } from './mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Stickers/StickerManager', diff --git a/ts/components/stickers/StickerPicker.stories.tsx b/ts/components/stickers/StickerPicker.stories.tsx index f9dcbf9ec..fd17c8b2c 100644 --- a/ts/components/stickers/StickerPicker.stories.tsx +++ b/ts/components/stickers/StickerPicker.stories.tsx @@ -4,13 +4,11 @@ import * as React from 'react'; import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import type { Props } from './StickerPicker'; import { StickerPicker } from './StickerPicker'; import { abeSticker, createPack, packs, recentStickers } from './mocks'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Stickers/StickerPicker', diff --git a/ts/components/stickers/StickerPreviewModal.stories.tsx b/ts/components/stickers/StickerPreviewModal.stories.tsx index 62025cac7..3b650125c 100644 --- a/ts/components/stickers/StickerPreviewModal.stories.tsx +++ b/ts/components/stickers/StickerPreviewModal.stories.tsx @@ -6,15 +6,13 @@ import { action } from '@storybook/addon-actions'; import type { Meta } from '@storybook/react'; import type { Props } from './StickerPreviewModal'; import { StickerPreviewModal } from './StickerPreviewModal'; -import { setupI18n } from '../../util/setupI18n'; -import enMessages from '../../../_locales/en/messages.json'; import { landscapeGreenUrl, portraitTealUrl, squareStickerUrl, } from '../../storybook/Fixtures'; -const i18n = setupI18n('en', enMessages); +const { i18n } = window.SignalContext; export default { title: 'Components/Stickers/StickerPreviewModal', diff --git a/ts/scripts/compile-stories-icu-lookup.ts b/ts/scripts/compile-stories-icu-lookup.ts new file mode 100644 index 000000000..8fc6430cf --- /dev/null +++ b/ts/scripts/compile-stories-icu-lookup.ts @@ -0,0 +1,69 @@ +// Copyright 2025 Signal Messenger, LLC +// SPDX-License-Identifier: AGPL-3.0-only + +import { readdir, readFile, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import pMap from 'p-map'; +import z from 'zod'; + +import { drop } from '../util/drop'; + +const jsonSchema = z.string().array(); + +async function main(): Promise { + const source = process.argv[2]; + if (!source) { + throw new Error('Missing required source directory argument'); + } + + const ids = await readdir(join(source, 'data'), { withFileTypes: true }); + + const enMessages = JSON.parse( + await readFile( + join(__dirname, '..', '..', '_locales', 'en', 'messages.json'), + 'utf8' + ) + ); + + const icuToStory: Record> = Object.create(null); + + await pMap( + ids, + async entity => { + if (!entity.isDirectory()) { + return; + } + + const storyId = entity.name; + const dir = join(source, 'data', storyId); + + const strings = jsonSchema.parse( + JSON.parse(await readFile(join(dir, 'strings.json'), 'utf8')) + ); + + for (const icuId of strings) { + let list = icuToStory[icuId]; + if (list == null) { + list = []; + icuToStory[icuId] = list; + } + list.push(storyId); + } + }, + { concurrency: 20 } + ); + + const index = Object.entries(icuToStory).map(([key, icuIds]) => { + return [key, enMessages[key]?.messageformat, icuIds]; + }); + const html = await readFile( + join(__dirname, '..', '..', '.storybook', 'icu-lookup.html'), + 'utf8' + ); + await writeFile( + join(source, 'index.html'), + html.replace('%INDEX%', JSON.stringify(index)) + ); +} + +drop(main()); diff --git a/ts/state/ducks/user.ts b/ts/state/ducks/user.ts index 63c54356c..20535dc02 100644 --- a/ts/state/ducks/user.ts +++ b/ts/state/ducks/user.ts @@ -137,6 +137,8 @@ export function getEmptyState(): UserStateType { getLocaleMessages: intlNotSetup, getLocaleDirection: intlNotSetup, getHourCyclePreference: intlNotSetup, + trackUsage: intlNotSetup, + stopTrackingUsage: intlNotSetup, }), interactionMode: 'mouse', isMainWindowMaximized: false, diff --git a/ts/types/Util.ts b/ts/types/Util.ts index 27fa6b2f4..cbc8ed659 100644 --- a/ts/types/Util.ts +++ b/ts/types/Util.ts @@ -48,6 +48,10 @@ export type LocalizerType = { getLocaleMessages(): LocaleMessagesType; getLocaleDirection(): LocaleDirection; getHourCyclePreference(): HourCyclePreference; + + // Storybook + trackUsage(): void; + stopTrackingUsage(): Array; }; export enum SentMediaQualityType { diff --git a/ts/util/setupI18nMain.ts b/ts/util/setupI18nMain.ts index cee447a3c..4f1259a5c 100644 --- a/ts/util/setupI18nMain.ts +++ b/ts/util/setupI18nMain.ts @@ -121,6 +121,8 @@ export function setupI18n( renderEmojify, }); + let usedStrings: Set | undefined; + const localizer: LocalizerType = (< Key extends keyof ICUStringMessageParamsByKeyType, >( @@ -128,6 +130,8 @@ export function setupI18n( substitutions: ICUStringMessageParamsByKeyType[Key], options?: LocalizerOptions ) => { + usedStrings?.add(key); + const result = intl.formatMessage( { id: key }, normalizeSubstitutions(substitutions, options) @@ -150,5 +154,21 @@ export function setupI18n( return window.SignalContext.getHourCyclePreference(); }; + // Storybook + localizer.trackUsage = () => { + if (usedStrings !== undefined) { + throw new Error('Already tracking usage'); + } + usedStrings = new Set(); + }; + localizer.stopTrackingUsage = () => { + if (usedStrings === undefined) { + throw new Error('Not tracking usage'); + } + const result = Array.from(usedStrings); + usedStrings = undefined; + return result; + }; + return localizer; }