diff --git a/package.json b/package.json index a3bb228b4aa..c87faff2a9e 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "UserFriendlyError" ], "scripts": { - "i18n": "matrix-gen-i18n src res packages/shared-components/src && yarn i18n:sort && yarn i18n:lint", + "i18n": "matrix-gen-i18n src res && yarn i18n:sort && yarn i18n:lint", "i18n:sort": "jq --sort-keys '.' src/i18n/strings/en_EN.json > src/i18n/strings/en_EN.json.tmp && mv src/i18n/strings/en_EN.json.tmp src/i18n/strings/en_EN.json", "i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null", "i18n:diff": "cp src/i18n/strings/en_EN.json src/i18n/strings/en_EN_orig.json && yarn i18n && matrix-compare-i18n-files src/i18n/strings/en_EN_orig.json src/i18n/strings/en_EN.json", diff --git a/packages/shared-components/package.json b/packages/shared-components/package.json index 1847ed2dd03..802037c2363 100644 --- a/packages/shared-components/package.json +++ b/packages/shared-components/package.json @@ -34,8 +34,11 @@ "package.json" ], "scripts": { + "i18n": "matrix-gen-i18n src && yarn i18n:sort && yarn i18n:lint", + "i18n:sort": "jq --sort-keys '.' src/i18n/strings/en_EN.json > src/i18n/strings/en_EN.json.tmp && mv src/i18n/strings/en_EN.json.tmp src/i18n/strings/en_EN.json", + "i18n:lint": "matrix-i18n-lint && prettier --log-level=silent --write src/i18n/strings/ --ignore-path /dev/null", "test": "jest", - "prepare": "patch-package && yarn --cwd ../.. build:res && node scripts/gatherTranslationKeys.ts && vite build", + "prepare": "patch-package && yarn --cwd ../.. build:res && vite build", "storybook": "storybook dev -p 6007", "build-storybook": "storybook build", "lint": "yarn lint:types && yarn lint:js", diff --git a/packages/shared-components/scripts/gatherTranslationKeys.ts b/packages/shared-components/scripts/gatherTranslationKeys.ts deleted file mode 100644 index 37812df33b3..00000000000 --- a/packages/shared-components/scripts/gatherTranslationKeys.ts +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2025 Element Creations Ltd. - -SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial -Please see LICENSE files in the repository root for full details. -*/ - -// Gathers all the translation keys from element-web's en_EN.json into a TypeScript type definition file -// that exports a type `TranslationKey` which is a union of all supported translation keys. -// This prevents having to import the json file and make typescript do the work as this results in vite-dts -// generating an import to the json file in the .d.ts which doesn't work at runtime: this way, the type -// gets put into the bundle. -// XXX: It should *not* be in the 'src' directory, being a generated file, but if it isn't then the type -// bundler won't bundle the types and will leave the file as a relative import, which will break. - -import * as fs from "fs"; -import * as path from "path"; -import { dirname } from "node:path"; -import { fileURLToPath } from "node:url"; - -const __dirname = dirname(fileURLToPath(import.meta.url)); -const i18nStringsPath = path.resolve(__dirname, "../../../src/i18n/strings/en_EN.json"); -const outPath = path.resolve(__dirname, "../src/i18nKeys.d.ts"); - -function gatherKeys(obj: any, prefix: string[] = []): string[] { - if (typeof obj !== "object" || obj === null) return []; - let keys: string[] = []; - for (const key of Object.keys(obj)) { - const value = obj[key]; - - // add the path (for both leaves and intermediates as then we include plurals) - keys.push([...prefix, key].join("|")); - if (typeof value === "object" && value !== null) { - // If the value is an object, recurse - keys = keys.concat(gatherKeys(value, [...prefix, key])); - } - } - return keys; -} - -function main() { - const json = JSON.parse(fs.readFileSync(i18nStringsPath, "utf8")); - const keys = gatherKeys(json); - const typeDef = - "/*\n" + - " * Copyright 2025 Element Creations Ltd.\n" + - " *\n" + - " * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\n" + - " * Please see LICENSE files in the repository root for full details.\n" + - " */\n" + - "\n" + - "// This file is auto-generated by gatherTranslationKeys.ts\n" + - "// Do not edit manually.\n\n" + - "export type TranslationKey =\n" + - keys.map((k) => ` | \"${k}\"`).join("\n") + - ";\n"; - fs.mkdirSync(path.dirname(outPath), { recursive: true }); - fs.writeFileSync(outPath, typeDef, "utf8"); - console.log(`Wrote ${keys.length} keys to ${outPath}`); -} - -if (import.meta.url.startsWith("file:")) { - const modulePath = fileURLToPath(import.meta.url); - if (process.argv[1] === modulePath) { - main(); - } -} diff --git a/packages/shared-components/src/@types/i18n.d.ts b/packages/shared-components/src/@types/i18n.d.ts new file mode 100644 index 00000000000..04531d8954a --- /dev/null +++ b/packages/shared-components/src/@types/i18n.d.ts @@ -0,0 +1,14 @@ +/* +Copyright 2025 Element Creations Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +import { type TranslationKey as _TranslationKey } from "matrix-web-i18n"; + +import type Translations from "../i18n/strings/en_EN.json"; + +declare global { + type TranslationKey = _TranslationKey; +} diff --git a/packages/shared-components/src/i18n/strings/en_EN.json b/packages/shared-components/src/i18n/strings/en_EN.json new file mode 100644 index 00000000000..46b77998f6a --- /dev/null +++ b/packages/shared-components/src/i18n/strings/en_EN.json @@ -0,0 +1,38 @@ +{ + "a11y": { + "seek_bar_label": "Audio seek bar" + }, + "action": { + "delete": "Delete", + "dismiss": "Dismiss", + "pause": "Pause", + "play": "Play" + }, + "encryption": { + "pinned_identity_changed": "%(displayName)s's (%(userId)s) identity was reset. Learn more", + "withdraw_verification_action": "Withdraw verification" + }, + "time": { + "about_day_ago": "about a day ago", + "about_hour_ago": "about an hour ago", + "about_minute_ago": "about a minute ago", + "few_seconds_ago": "a few seconds ago", + "in_about_day": "about a day from now", + "in_about_hour": "about an hour from now", + "in_about_minute": "about a minute from now", + "in_few_seconds": "a few seconds from now", + "in_n_days": "%(num)s days from now", + "in_n_hours": "%(num)s hours from now", + "in_n_minutes": "%(num)s minutes from now", + "n_days_ago": "%(num)s days ago", + "n_hours_ago": "%(num)s hours ago", + "n_minutes_ago": "%(num)s minutes ago" + }, + "timeline": { + "m.audio": { + "audio_player": "Audio player", + "error_downloading_audio": "Error downloading audio", + "unnamed_audio": "Unnamed audio" + } + } +} diff --git a/packages/shared-components/src/index.ts b/packages/shared-components/src/index.ts index 849634e9da8..346f92ef35a 100644 --- a/packages/shared-components/src/index.ts +++ b/packages/shared-components/src/index.ts @@ -36,7 +36,3 @@ export * from "./utils/I18nApi"; export * from "./viewmodel"; export * from "./useMockedViewModel"; export * from "./useViewModel"; - -// i18n (we must export this directly in order to not confuse the type bundler, it seems, -// otherwise it will leave it as a relative import rather than bundling it) -export type * from "./i18nKeys.d.ts"; diff --git a/packages/shared-components/src/utils/I18nApi.ts b/packages/shared-components/src/utils/I18nApi.ts index 20d641f5ce5..df474e2775b 100644 --- a/packages/shared-components/src/utils/I18nApi.ts +++ b/packages/shared-components/src/utils/I18nApi.ts @@ -9,7 +9,6 @@ import { type I18nApi as II18nApi, type Variables, type Translations } from "@el import { humanizeTime } from "./humanize"; import { _t, getLocale, registerTranslations } from "./i18n"; -import { type TranslationKey } from "../i18nKeys"; export class I18nApi implements II18nApi { /** @@ -24,10 +23,11 @@ export class I18nApi implements II18nApi { */ public register(translations: Partial): void { const langs: Record> = {}; + for (const key in translations) { - for (const lang in translations[key]) { + for (const lang in translations[key as keyof Translations]) { langs[lang] = langs[lang] || {}; - langs[lang][key] = translations[key][lang]; + langs[lang][key] = translations[key as keyof Translations]![lang]; } } diff --git a/packages/shared-components/src/utils/i18n.tsx b/packages/shared-components/src/utils/i18n.tsx index 2ce1f780057..38bf7bab8bd 100644 --- a/packages/shared-components/src/utils/i18n.tsx +++ b/packages/shared-components/src/utils/i18n.tsx @@ -25,8 +25,6 @@ import React from "react"; import { KEY_SEPARATOR } from "matrix-web-i18n"; import counterpart from "counterpart"; -import type { TranslationKey } from "../index"; - // @ts-ignore - $webapp is a webpack resolve alias pointing to the output directory, see webpack config import webpackLangJsonUrl from "$webapp/i18n/languages.json"; diff --git a/src/@types/i18n.d.ts b/src/@types/i18n.d.ts new file mode 100644 index 00000000000..04531d8954a --- /dev/null +++ b/src/@types/i18n.d.ts @@ -0,0 +1,14 @@ +/* +Copyright 2025 Element Creations Ltd. + +SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial +Please see LICENSE files in the repository root for full details. +*/ + +import { type TranslationKey as _TranslationKey } from "matrix-web-i18n"; + +import type Translations from "../i18n/strings/en_EN.json"; + +declare global { + type TranslationKey = _TranslationKey; +} diff --git a/src/accessibility/KeyboardShortcuts.ts b/src/accessibility/KeyboardShortcuts.ts index 2872e1a1a22..9d4222d92f9 100644 --- a/src/accessibility/KeyboardShortcuts.ts +++ b/src/accessibility/KeyboardShortcuts.ts @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. */ // Import i18n.tsx instead of languageHandler to avoid circular deps -import { _td, type TranslationKey } from "@element-hq/web-shared-components"; +import { _td } from "@element-hq/web-shared-components"; import { IS_MAC, IS_ELECTRON, Key } from "../Keyboard"; import { type IBaseSetting } from "../settings/Settings"; diff --git a/src/components/structures/EmbeddedPage.tsx b/src/components/structures/EmbeddedPage.tsx index 53a5d7d5373..8ea20d3cb33 100644 --- a/src/components/structures/EmbeddedPage.tsx +++ b/src/components/structures/EmbeddedPage.tsx @@ -12,7 +12,7 @@ import sanitizeHtml from "sanitize-html"; import classnames from "classnames"; import { logger } from "matrix-js-sdk/src/logger"; -import { _t, type TranslationKey } from "../../languageHandler"; +import { _t } from "../../languageHandler"; import dis from "../../dispatcher/dispatcher"; import { MatrixClientPeg } from "../../MatrixClientPeg"; import MatrixClientContext from "../../contexts/MatrixClientContext"; diff --git a/src/components/structures/TabbedView.tsx b/src/components/structures/TabbedView.tsx index 7b11b92e9cf..1746c136529 100644 --- a/src/components/structures/TabbedView.tsx +++ b/src/components/structures/TabbedView.tsx @@ -11,7 +11,7 @@ Please see LICENSE files in the repository root for full details. import React, { type JSX } from "react"; import classNames from "classnames"; -import { _t, type TranslationKey } from "../../languageHandler"; +import { _t } from "../../languageHandler"; import AutoHideScrollbar from "./AutoHideScrollbar"; import { PosthogScreenTracker, type ScreenName } from "../../PosthogTrackers"; import { type NonEmptyArray } from "../../@types/common"; diff --git a/src/components/viewmodels/memberlist/tiles/MemberTileViewModel.tsx b/src/components/viewmodels/memberlist/tiles/MemberTileViewModel.tsx index d99c127d851..1cb29029ea6 100644 --- a/src/components/viewmodels/memberlist/tiles/MemberTileViewModel.tsx +++ b/src/components/viewmodels/memberlist/tiles/MemberTileViewModel.tsx @@ -15,7 +15,7 @@ import { Action } from "../../../../dispatcher/actions"; import { asyncSome } from "../../../../utils/arrays"; import { getUserDeviceIds } from "../../../../utils/crypto/deviceInfo"; import { type RoomMember } from "../../../../models/rooms/RoomMember"; -import { _t, _td, type TranslationKey } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import { E2EStatus } from "../../../../utils/ShieldUtils"; interface MemberTileViewModelProps { diff --git a/src/components/viewmodels/roomlist/useFilteredRooms.tsx b/src/components/viewmodels/roomlist/useFilteredRooms.tsx index 4e311f39dba..a0e36dc668e 100644 --- a/src/components/viewmodels/roomlist/useFilteredRooms.tsx +++ b/src/components/viewmodels/roomlist/useFilteredRooms.tsx @@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details. import { useCallback, useEffect, useMemo, useState } from "react"; import { FilterKey } from "../../../stores/room-list-v3/skip-list/filters"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import RoomListStoreV3, { LISTS_LOADED_EVENT, LISTS_UPDATE_EVENT, diff --git a/src/components/views/auth/EmailField.tsx b/src/components/views/auth/EmailField.tsx index fb420ed459b..a8388f7ad9e 100644 --- a/src/components/views/auth/EmailField.tsx +++ b/src/components/views/auth/EmailField.tsx @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. import React, { type ComponentProps, PureComponent, type Ref } from "react"; import Field, { type IInputProps } from "../elements/Field"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import withValidation, { type IFieldState, type IValidationResult } from "../elements/Validation"; import * as Email from "../../../email"; diff --git a/src/components/views/auth/PassphraseConfirmField.tsx b/src/components/views/auth/PassphraseConfirmField.tsx index 4dc720e8aff..0eb0ce79b05 100644 --- a/src/components/views/auth/PassphraseConfirmField.tsx +++ b/src/components/views/auth/PassphraseConfirmField.tsx @@ -10,7 +10,7 @@ import React, { type ComponentProps, PureComponent, type Ref } from "react"; import Field, { type IInputProps } from "../elements/Field"; import withValidation, { type IFieldState, type IValidationResult } from "../elements/Validation"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; interface IProps extends Omit { id?: string; diff --git a/src/components/views/auth/PassphraseField.tsx b/src/components/views/auth/PassphraseField.tsx index 938e559fd71..d5cd27e401a 100644 --- a/src/components/views/auth/PassphraseField.tsx +++ b/src/components/views/auth/PassphraseField.tsx @@ -12,7 +12,7 @@ import classNames from "classnames"; import type { ZxcvbnResult } from "@zxcvbn-ts/core"; import SdkConfig from "../../../SdkConfig"; import withValidation, { type IFieldState, type IValidationResult } from "../elements/Validation"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import Field, { type IInputProps } from "../elements/Field"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; diff --git a/src/components/views/context_menus/DeviceContextMenu.tsx b/src/components/views/context_menus/DeviceContextMenu.tsx index 7560b4a7d58..e780449f123 100644 --- a/src/components/views/context_menus/DeviceContextMenu.tsx +++ b/src/components/views/context_menus/DeviceContextMenu.tsx @@ -11,7 +11,7 @@ import React, { useEffect, useState } from "react"; import MediaDeviceHandler, { MediaDeviceKindEnum } from "../../../MediaDeviceHandler"; import IconizedContextMenu, { IconizedContextMenuOptionList, IconizedContextMenuRadio } from "./IconizedContextMenu"; import { type IProps as IContextMenuProps } from "../../structures/ContextMenu"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; const SECTION_NAMES: Record = { [MediaDeviceKindEnum.AudioInput]: _td("voip|input_devices"), diff --git a/src/components/views/dialogs/AddExistingToSpaceDialog.tsx b/src/components/views/dialogs/AddExistingToSpaceDialog.tsx index c247c3aea97..4b6d031967d 100644 --- a/src/components/views/dialogs/AddExistingToSpaceDialog.tsx +++ b/src/components/views/dialogs/AddExistingToSpaceDialog.tsx @@ -14,7 +14,7 @@ import { sleep } from "matrix-js-sdk/src/utils"; import { logger } from "matrix-js-sdk/src/logger"; import { ErrorIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import BaseDialog from "./BaseDialog"; import Dropdown from "../elements/Dropdown"; import SearchBox from "../../structures/SearchBox"; diff --git a/src/components/views/dialogs/DevtoolsDialog.tsx b/src/components/views/dialogs/DevtoolsDialog.tsx index 5ac04780121..10986095ea7 100644 --- a/src/components/views/dialogs/DevtoolsDialog.tsx +++ b/src/components/views/dialogs/DevtoolsDialog.tsx @@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details. import React, { type JSX, useState } from "react"; import { Form } from "@vector-im/compound-web"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import BaseDialog from "./BaseDialog"; import { TimelineEventEditor } from "./devtools/Event"; diff --git a/src/components/views/dialogs/TextInputDialog.tsx b/src/components/views/dialogs/TextInputDialog.tsx index 1a86a40d144..ed076bc4720 100644 --- a/src/components/views/dialogs/TextInputDialog.tsx +++ b/src/components/views/dialogs/TextInputDialog.tsx @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. import React, { type ChangeEvent, createRef } from "react"; import Field from "../elements/Field"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import { type IFieldState, type IValidationResult } from "../elements/Validation"; import BaseDialog from "./BaseDialog"; import DialogButtons from "../elements/DialogButtons"; diff --git a/src/components/views/dialogs/devtools/AccountData.tsx b/src/components/views/dialogs/devtools/AccountData.tsx index d4dfe039fd3..6900a7097ee 100644 --- a/src/components/views/dialogs/devtools/AccountData.tsx +++ b/src/components/views/dialogs/devtools/AccountData.tsx @@ -14,7 +14,7 @@ import BaseTool, { DevtoolsContext, type IDevtoolsProps } from "./BaseTool"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; import { EventEditor, EventViewer, eventTypeField, type IEditorProps, stringify } from "./Event"; import FilteredList from "./FilteredList"; -import { _td, type TranslationKey } from "../../../../languageHandler"; +import { _td } from "../../../../languageHandler"; export const AccountDataEventEditor: React.FC = ({ mxEvent, onBack }) => { const cli = useContext(MatrixClientContext); diff --git a/src/components/views/dialogs/devtools/BaseTool.tsx b/src/components/views/dialogs/devtools/BaseTool.tsx index 8a923e26235..555d5b31ff4 100644 --- a/src/components/views/dialogs/devtools/BaseTool.tsx +++ b/src/components/views/dialogs/devtools/BaseTool.tsx @@ -11,7 +11,7 @@ import React, { createContext, type ReactNode, useState } from "react"; import { type Room } from "matrix-js-sdk/src/matrix"; import classNames from "classnames"; -import { _t, type TranslationKey } from "../../../../languageHandler"; +import { _t } from "../../../../languageHandler"; import { type XOR } from "../../../../@types/common"; import { type Tool } from "../DevtoolsDialog"; diff --git a/src/components/views/dialogs/devtools/Event.tsx b/src/components/views/dialogs/devtools/Event.tsx index 00669cd6143..63712b28d90 100644 --- a/src/components/views/dialogs/devtools/Event.tsx +++ b/src/components/views/dialogs/devtools/Event.tsx @@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details. import React, { type ChangeEvent, type ReactNode, useContext, useMemo, useRef, useState } from "react"; import { type IContent, type MatrixEvent, type TimelineEvents } from "matrix-js-sdk/src/matrix"; -import { _t, _td, type TranslationKey } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import Field from "../../elements/Field"; import BaseTool, { DevtoolsContext, type IDevtoolsProps } from "./BaseTool"; import MatrixClientContext from "../../../../contexts/MatrixClientContext"; diff --git a/src/components/views/elements/DesktopCapturerSourcePicker.tsx b/src/components/views/elements/DesktopCapturerSourcePicker.tsx index 636e37ccd0d..fd20db7ef61 100644 --- a/src/components/views/elements/DesktopCapturerSourcePicker.tsx +++ b/src/components/views/elements/DesktopCapturerSourcePicker.tsx @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. import React from "react"; import classNames from "classnames"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import BaseDialog from "..//dialogs/BaseDialog"; import DialogButtons from "./DialogButtons"; import AccessibleButton from "./AccessibleButton"; diff --git a/src/components/views/rooms/E2EIcon.tsx b/src/components/views/rooms/E2EIcon.tsx index 72b4b36bd37..e662b1d96ce 100644 --- a/src/components/views/rooms/E2EIcon.tsx +++ b/src/components/views/rooms/E2EIcon.tsx @@ -12,7 +12,7 @@ import classNames from "classnames"; import { Tooltip } from "@vector-im/compound-web"; import { ErrorSolidIcon, ShieldIcon, LockSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import AccessibleButton from "../elements/AccessibleButton"; import { E2EStatus } from "../../../utils/ShieldUtils"; diff --git a/src/components/views/rooms/LegacyRoomList.tsx b/src/components/views/rooms/LegacyRoomList.tsx index 95b62cf4c93..e8dd6c55747 100644 --- a/src/components/views/rooms/LegacyRoomList.tsx +++ b/src/components/views/rooms/LegacyRoomList.tsx @@ -25,7 +25,7 @@ import { type ActionPayload } from "../../../dispatcher/payloads.ts"; import { type ViewRoomDeltaPayload } from "../../../dispatcher/payloads/ViewRoomDeltaPayload.ts"; import { type ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload.ts"; import { useEventEmitterState } from "../../../hooks/useEventEmitter.ts"; -import { _t, _td, type TranslationKey } from "../../../languageHandler.tsx"; +import { _t, _td } from "../../../languageHandler.tsx"; import { MatrixClientPeg } from "../../../MatrixClientPeg.ts"; import PosthogTrackers from "../../../PosthogTrackers.ts"; import SettingsStore from "../../../settings/SettingsStore.ts"; diff --git a/src/components/views/rooms/NewRoomIntro.tsx b/src/components/views/rooms/NewRoomIntro.tsx index 67daec115df..82647559c95 100644 --- a/src/components/views/rooms/NewRoomIntro.tsx +++ b/src/components/views/rooms/NewRoomIntro.tsx @@ -12,7 +12,7 @@ import { KnownMembership } from "matrix-js-sdk/src/types"; import MatrixClientContext from "../../../contexts/MatrixClientContext"; import DMRoomMap from "../../../utils/DMRoomMap"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import AccessibleButton, { type ButtonEvent } from "../elements/AccessibleButton"; import MiniAvatarUploader, { AVATAR_SIZE } from "../elements/MiniAvatarUploader"; import RoomAvatar from "../avatars/RoomAvatar"; diff --git a/src/components/views/rooms/Stickerpicker.tsx b/src/components/views/rooms/Stickerpicker.tsx index bbf3f49685a..80d94223353 100644 --- a/src/components/views/rooms/Stickerpicker.tsx +++ b/src/components/views/rooms/Stickerpicker.tsx @@ -10,7 +10,7 @@ import { type Room, ClientEvent } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; import { type IWidget } from "matrix-widget-api"; -import { _t, _td, type TranslationKey } from "../../../languageHandler"; +import { _t, _td } from "../../../languageHandler"; import AppTile from "../elements/AppTile"; import { MatrixClientPeg } from "../../../MatrixClientPeg"; import dis from "../../../dispatcher/dispatcher"; diff --git a/src/components/views/settings/devices/DeviceTypeIcon.tsx b/src/components/views/settings/devices/DeviceTypeIcon.tsx index 8b716af1ee9..35db504682c 100644 --- a/src/components/views/settings/devices/DeviceTypeIcon.tsx +++ b/src/components/views/settings/devices/DeviceTypeIcon.tsx @@ -14,7 +14,7 @@ import { Icon as UnknownDeviceIcon } from "../../../../../res/img/element-icons/ import { Icon as DesktopIcon } from "../../../../../res/img/element-icons/settings/desktop.svg"; import { Icon as WebIcon } from "../../../../../res/img/element-icons/settings/web.svg"; import { Icon as MobileIcon } from "../../../../../res/img/element-icons/settings/mobile.svg"; -import { _t, _td, type TranslationKey } from "../../../../languageHandler"; +import { _t, _td } from "../../../../languageHandler"; import { type ExtendedDevice } from "./types"; import { DeviceType } from "../../../../utils/device/parseUserAgent"; diff --git a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx index 4c720a23721..308918e1b36 100644 --- a/src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx +++ b/src/components/views/settings/tabs/room/RolesRoomSettingsTab.tsx @@ -12,7 +12,7 @@ import { logger } from "matrix-js-sdk/src/logger"; import { throttle, get, set } from "lodash"; import { KnownMembership, type RoomPowerLevelsEventContent } from "matrix-js-sdk/src/types"; -import { _t, _td, type TranslationKey } from "../../../../../languageHandler"; +import { _t, _td } from "../../../../../languageHandler"; import AccessibleButton from "../../../elements/AccessibleButton"; import Modal from "../../../../../Modal"; import ErrorDialog from "../../../dialogs/ErrorDialog"; diff --git a/src/effects/effect.ts b/src/effects/effect.ts index 571ce494ed1..60f94b283f9 100644 --- a/src/effects/effect.ts +++ b/src/effects/effect.ts @@ -7,8 +7,6 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com Please see LICENSE files in the repository root for full details. */ -import { type TranslationKey } from "../languageHandler"; - export type Effect = { /** * one or more emojis that will trigger this effect diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index ddd45e35e52..a24a64daf9d 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -101,9 +101,7 @@ "ok": "OK", "open": "Open", "open_menu": "Open menu", - "pause": "Pause", "pin": "Pin", - "play": "Play", "proceed": "Proceed", "quote": "Quote", "react": "React", @@ -2123,7 +2121,6 @@ "status_bar": { "delete_all": "Delete all", "exceeded_resource_limit": "Your message wasn't sent because this homeserver has exceeded a resource limit. Please contact your service administrator to continue using the service.", - "history_visible": "Messages you send will be shared with new members invited to this room. Learn more", "homeserver_blocked": "Your message wasn't sent because this homeserver has been blocked by its administrator. Please contact your service administrator to continue using the service.", "monthly_user_limit_reached": "Your message wasn't sent because this homeserver has hit its Monthly Active User Limit. Please contact your service administrator to continue using the service.", "requires_consent_agreement": "You can't send any messages until you review and agree to our terms and conditions.", @@ -3408,24 +3405,10 @@ "no_rooms_with_unread_threads": "You don't have rooms with unread threads yet." }, "time": { - "about_day_ago": "about a day ago", - "about_hour_ago": "about an hour ago", - "about_minute_ago": "about a minute ago", "date_at_time": "%(date)s at %(time)s", - "few_seconds_ago": "a few seconds ago", "hours_minutes_seconds_left": "%(hours)sh %(minutes)sm %(seconds)ss left", - "in_about_day": "about a day from now", - "in_about_hour": "about an hour from now", - "in_about_minute": "about a minute from now", - "in_few_seconds": "a few seconds from now", - "in_n_days": "%(num)s days from now", - "in_n_hours": "%(num)s hours from now", - "in_n_minutes": "%(num)s minutes from now", "left": "%(timeRemaining)s left", "minutes_seconds_left": "%(minutes)sm %(seconds)ss left", - "n_days_ago": "%(num)s days ago", - "n_hours_ago": "%(num)s hours ago", - "n_minutes_ago": "%(num)s minutes ago", "seconds_left": "%(seconds)ss left", "short_days": "%(value)sd", "short_days_hours_minutes_seconds": "%(days)sd %(hours)sh %(minutes)sm %(seconds)ss", @@ -3480,11 +3463,9 @@ "unable_to_find": "Tried to load a specific point in this room's timeline, but was unable to find it." }, "m.audio": { - "audio_player": "Audio player", "error_downloading_audio": "Error downloading audio", "error_processing_audio": "Error processing audio message", - "error_processing_voice_message": "Error processing voice message", - "unnamed_audio": "Unnamed audio" + "error_processing_voice_message": "Error processing voice message" }, "m.beacon_info": { "view_live_location": "View live location" diff --git a/src/languageHandler.tsx b/src/languageHandler.tsx index abd26dda016..2effdb38564 100644 --- a/src/languageHandler.tsx +++ b/src/languageHandler.tsx @@ -12,7 +12,6 @@ import _ from "lodash"; import { _t, normalizeLanguageKey, - type TranslationKey, type IVariables, KEY_SEPARATOR, getLangsJson, @@ -33,7 +32,6 @@ export { _t, type IVariables, type Tags, - type TranslationKey, type TranslatedString, _td, _tDom, diff --git a/src/modules/ProxiedModuleApi.ts b/src/modules/ProxiedModuleApi.ts index f36b81dec2b..9bccf9f71ff 100644 --- a/src/modules/ProxiedModuleApi.ts +++ b/src/modules/ProxiedModuleApi.ts @@ -19,7 +19,7 @@ import { type ModuleUiDialogOptions } from "@matrix-org/react-sdk-module-api/lib import type React from "react"; import Modal from "../Modal"; -import { _t, type TranslationKey } from "../languageHandler"; +import { _t } from "../languageHandler"; import { ModuleUiDialog } from "../components/views/dialogs/ModuleUiDialog"; import SdkConfig from "../SdkConfig"; import PlatformPeg from "../PlatformPeg"; diff --git a/src/notifications/VectorPushRulesDefinitions.ts b/src/notifications/VectorPushRulesDefinitions.ts index 403efbc49b7..d496119f1ed 100644 --- a/src/notifications/VectorPushRulesDefinitions.ts +++ b/src/notifications/VectorPushRulesDefinitions.ts @@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details. import { type IAnnotatedPushRule, type PushRuleAction, RuleId } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; -import { _td, type TranslationKey } from "../languageHandler"; +import { _td } from "../languageHandler"; import { StandardActions } from "./StandardActions"; import { PushRuleVectorState, VectorState } from "./PushRuleVectorState"; import { NotificationUtils } from "./NotificationUtils"; diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index fe57708dfa1..389804160ec 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details. import React, { type ReactNode } from "react"; import { STABLE_MSC4133_EXTENDED_PROFILES, UNSTABLE_MSC4133_EXTENDED_PROFILES } from "matrix-js-sdk/src/matrix"; // Import these directly from shared-components to avoid circular deps -import { _t, _td, type TranslationKey } from "@element-hq/web-shared-components"; +import { _t, _td } from "@element-hq/web-shared-components"; import { type MediaPreviewConfig } from "../@types/media_preview.ts"; import DeviceIsolationModeController from "./controllers/DeviceIsolationModeController.ts"; diff --git a/src/settings/controllers/ServerSupportUnstableFeatureController.ts b/src/settings/controllers/ServerSupportUnstableFeatureController.ts index 058fdaae08e..1b212da6387 100644 --- a/src/settings/controllers/ServerSupportUnstableFeatureController.ts +++ b/src/settings/controllers/ServerSupportUnstableFeatureController.ts @@ -11,7 +11,7 @@ import MatrixClientBackedController from "./MatrixClientBackedController"; import { type WatchManager } from "../WatchManager"; import SettingsStore from "../SettingsStore"; import { type SettingKey } from "../Settings.tsx"; -import { _t, type TranslationKey } from "../../languageHandler.tsx"; +import { _t } from "../../languageHandler.tsx"; /** * Disables a given setting if the server unstable feature it requires is not supported diff --git a/src/slash-commands/command.ts b/src/slash-commands/command.ts index 9619c514dd8..f541f5ae986 100644 --- a/src/slash-commands/command.ts +++ b/src/slash-commands/command.ts @@ -14,7 +14,7 @@ import { type SlashCommand as SlashCommandEvent } from "@matrix-org/analytics-ev import { TimelineRenderingType } from "../contexts/RoomContext"; import { reject } from "./utils"; -import { _t, type TranslationKey, UserFriendlyError } from "../languageHandler"; +import { _t, UserFriendlyError } from "../languageHandler"; import { PosthogAnalytics } from "../PosthogAnalytics"; import { CommandCategories, type RunResult } from "./interface"; diff --git a/src/utils/AutoDiscoveryUtils.tsx b/src/utils/AutoDiscoveryUtils.tsx index e5359c48f83..32bd92df7ca 100644 --- a/src/utils/AutoDiscoveryUtils.tsx +++ b/src/utils/AutoDiscoveryUtils.tsx @@ -18,7 +18,7 @@ import { } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; -import { _t, _td, type TranslationKey, UserFriendlyError } from "../languageHandler"; +import { _t, _td, UserFriendlyError } from "../languageHandler"; import SdkConfig from "../SdkConfig"; import { type ValidatedServerConfig } from "./ValidatedServerConfig"; diff --git a/src/utils/ErrorUtils.tsx b/src/utils/ErrorUtils.tsx index 2772350a0c1..de3d0bfdf39 100644 --- a/src/utils/ErrorUtils.tsx +++ b/src/utils/ErrorUtils.tsx @@ -10,7 +10,7 @@ import React, { type ReactNode } from "react"; import { MatrixError, ConnectionError } from "matrix-js-sdk/src/matrix"; import { logger } from "matrix-js-sdk/src/logger"; -import { _t, _td, lookupString, type Tags, type TranslatedString, type TranslationKey } from "../languageHandler"; +import { _t, _td, lookupString, type Tags, type TranslatedString } from "../languageHandler"; import SdkConfig from "../SdkConfig"; import { type ValidatedServerConfig } from "./ValidatedServerConfig"; import ExternalLink from "../components/views/elements/ExternalLink"; diff --git a/src/widgets/CapabilityText.tsx b/src/widgets/CapabilityText.tsx index effaa0975ba..c64e7ffa0f2 100644 --- a/src/widgets/CapabilityText.tsx +++ b/src/widgets/CapabilityText.tsx @@ -21,7 +21,7 @@ import { import { EventType, MsgType } from "matrix-js-sdk/src/matrix"; import React from "react"; -import { _t, _td, type TranslatedString, type TranslationKey } from "../languageHandler"; +import { _t, _td, type TranslatedString } from "../languageHandler"; import { ElementWidgetCapabilities } from "../stores/widgets/ElementWidgetCapabilities"; import { MatrixClientPeg } from "../MatrixClientPeg"; import TextWithTooltip from "../components/views/elements/TextWithTooltip"; diff --git a/test/unit-tests/components/views/beta/BetaCard-test.tsx b/test/unit-tests/components/views/beta/BetaCard-test.tsx index 06ede990e6d..47c9b29230e 100644 --- a/test/unit-tests/components/views/beta/BetaCard-test.tsx +++ b/test/unit-tests/components/views/beta/BetaCard-test.tsx @@ -13,7 +13,6 @@ import { render, screen } from "jest-matrix-react"; import { shouldShowFeedback } from "../../../../../src/utils/Feedback"; import BetaCard from "../../../../../src/components/views/beta/BetaCard"; import SettingsStore from "../../../../../src/settings/SettingsStore"; -import { type TranslationKey } from "../../../../../src/languageHandler"; import { type FeatureSettingKey } from "../../../../../src/settings/Settings.tsx"; jest.mock("../../../../../src/utils/Feedback"); diff --git a/test/unit-tests/languageHandler-test.tsx b/test/unit-tests/languageHandler-test.tsx index de1a629608e..d4846969956 100644 --- a/test/unit-tests/languageHandler-test.tsx +++ b/test/unit-tests/languageHandler-test.tsx @@ -23,7 +23,6 @@ import { substitute, type TranslatedString, UserFriendlyError, - type TranslationKey, type IVariables, type Tags, getLanguagesFromBrowser, diff --git a/test/unit-tests/settings/controllers/ServerSupportUnstableFeatureController-test.ts b/test/unit-tests/settings/controllers/ServerSupportUnstableFeatureController-test.ts index cab82f8d323..1bd80e25353 100644 --- a/test/unit-tests/settings/controllers/ServerSupportUnstableFeatureController-test.ts +++ b/test/unit-tests/settings/controllers/ServerSupportUnstableFeatureController-test.ts @@ -14,7 +14,6 @@ import { type FeatureSettingKey, LabGroup, SETTINGS } from "../../../../src/sett import { stubClient } from "../../../test-utils"; import { WatchManager } from "../../../../src/settings/WatchManager"; import MatrixClientBackedController from "../../../../src/settings/controllers/MatrixClientBackedController"; -import { type TranslationKey } from "../../../../src/languageHandler"; describe("ServerSupportUnstableFeatureController", () => { const watchers = new WatchManager(); diff --git a/yarn.lock b/yarn.lock index 717ca08bf8e..b405c6236bd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1577,17 +1577,8 @@ yaml "^2.7.0" "@element-hq/web-shared-components@link:packages/shared-components": - version "0.0.0-test.12" - dependencies: - "@element-hq/element-web-module-api" "^1.8.0" - "@vector-im/compound-design-tokens" "^6.3.0" - classnames "^2.5.1" - counterpart "^0.18.6" - lodash "^4.17.21" - matrix-web-i18n "^3.4.0" - patch-package "^8.0.1" - react-merge-refs "^3.0.2" - temporal-polyfill "^0.3.0" + version "0.0.0" + uid "" "@emnapi/core@^1.4.3": version "1.7.0" @@ -4221,15 +4212,16 @@ classnames "^2.5.1" vaul "^1.0.0" -"@vector-im/matrix-wysiwyg-wasm@link:../../../.cache/yarn/v6/npm-@vector-im-matrix-wysiwyg-2.40.0-53c9ca5ea907d91e4515da64f20a82e5586b882c-integrity/node_modules/bindings/wysiwyg-wasm": +"@vector-im/matrix-wysiwyg-wasm@link:../../Library/Caches/Yarn/v6/npm-@vector-im-matrix-wysiwyg-2.40.0-53c9ca5ea907d91e4515da64f20a82e5586b882c-integrity/node_modules/bindings/wysiwyg-wasm": version "0.0.0" + uid "" "@vector-im/matrix-wysiwyg@2.40.0": version "2.40.0" resolved "https://registry.yarnpkg.com/@vector-im/matrix-wysiwyg/-/matrix-wysiwyg-2.40.0.tgz#53c9ca5ea907d91e4515da64f20a82e5586b882c" integrity sha512-8LRFLs5PEKYs4lOL7aJ4lL/hGCrvEvOYkCR3JggXYXDVMtX4LmfdlKYucSAe98pCmqAAbLRvlRcR1bTOYvM8ug== dependencies: - "@vector-im/matrix-wysiwyg-wasm" "link:../../../.cache/yarn/v6/npm-@vector-im-matrix-wysiwyg-2.40.0-53c9ca5ea907d91e4515da64f20a82e5586b882c-integrity/node_modules/bindings/wysiwyg-wasm" + "@vector-im/matrix-wysiwyg-wasm" "link:../../Library/Caches/Yarn/v6/npm-@vector-im-matrix-wysiwyg-2.40.0-53c9ca5ea907d91e4515da64f20a82e5586b882c-integrity/node_modules/bindings/wysiwyg-wasm" "@vitest/expect@3.2.4": version "3.2.4"