chore: BIKESHEDDING IS OVER, T PREVAILS

This commit is contained in:
Lewis Crichton 2024-06-11 22:31:06 +01:00
parent 8c4aed699d
commit b92a21ac7d
No known key found for this signature in database
17 changed files with 139 additions and 139 deletions

View file

@ -95,7 +95,7 @@ function isTranslationExpression(node: Node): node is CallExpression {
const literal = node.expression as LiteralExpression;
if (literal.text !== "$t") return false;
if (literal.text !== "t") return false;
return true;
}

View file

@ -38,7 +38,7 @@ import { patches, PMLogger, startAllPlugins } from "./plugins";
import { localStorage } from "./utils/localStorage";
import { relaunch } from "./utils/native";
import { getCloudSettings, putCloudSettings } from "./utils/settingsSync";
import { $t } from "./utils/translation";
import { t } from "./utils/translation";
import { checkForUpdates, update, UpdateLogger } from "./utils/updater";
import { onceReady } from "./webpack";
import { SettingsRouter } from "./webpack/common";
@ -55,8 +55,8 @@ async function syncSettings() {
) {
// show a notification letting them know and tell them how to fix it
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.reauthenticate"),
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.reauthenticate"),
color: "var(--yellow-360)",
onClick: () => SettingsRouter.open("VencordCloud")
});
@ -76,8 +76,8 @@ async function syncSettings() {
// there was an error to notify the user, but besides that we only want to show one notification instead of all
// of the possible ones it has (such as when your settings are newer).
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.updated"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.updated"),
color: "var(--green-360)",
onClick: relaunch
});
@ -100,8 +100,8 @@ async function init() {
await update();
if (Settings.autoUpdateNotification)
setTimeout(() => showNotification({
title: $t("vencord.update.updated"),
body: $t("vencord.update.clickToRestart"),
title: t("vencord.update.updated"),
body: t("vencord.update.clickToRestart"),
permanent: true,
noPersist: true,
onClick: relaunch
@ -110,8 +110,8 @@ async function init() {
}
setTimeout(() => showNotification({
title: $t("vencord.update.available"),
body: $t("vencord.update.clickToView"),
title: t("vencord.update.available"),
body: t("vencord.update.clickToView"),
permanent: true,
noPersist: true,
onClick: openUpdaterModal!

View file

@ -19,7 +19,7 @@
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import { LazyComponent } from "@utils/react";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { React } from "@webpack/common";
import { ErrorCard } from "./ErrorCard";
@ -86,11 +86,11 @@ const ErrorBoundary = LazyComponent(() => {
{...this.state}
/>;
const msg = this.props.message || $t("vencord.errorBoundaryDescription");
const msg = this.props.message || t("vencord.errorBoundaryDescription");
return (
<ErrorCard style={{ overflow: "hidden" }}>
<h1>{$t("vencord.ohNo")}</h1>
<h1>{t("vencord.ohNo")}</h1>
<p>{msg}</p>
<code>
{this.state.message}

View file

@ -13,7 +13,7 @@ import { Link } from "@components/Link";
import { DevsById } from "@utils/constants";
import { fetchUserProfile, getTheme, Theme } from "@utils/discord";
import { ModalContent, ModalRoot, openModal } from "@utils/modal";
import { $t, Translate } from "@utils/translation";
import { t, Translate } from "@utils/translation";
import { Forms, MaskedLink, showToast, Tooltip, useEffect, useMemo, UserProfileStore, useStateFromStores } from "@webpack/common";
import { User } from "discord-types/general";
@ -119,7 +119,7 @@ function ContributorModal({ user }: { user: User; }) {
key={p.name}
plugin={p}
disabled={p.required ?? false}
onRestartNeeded={() => showToast($t("vencord.pluginRestart"))}
onRestartNeeded={() => showToast(t("vencord.pluginRestart"))}
/>
)}
</div>

View file

@ -24,7 +24,7 @@ import { proxyLazy } from "@utils/lazy";
import { Margins } from "@utils/margins";
import { classes, isObjectEmpty } from "@utils/misc";
import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { OptionType, Plugin } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { Button, Clickable, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
@ -130,7 +130,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
function renderSettings() {
if (!hasSettings || !plugin.options) {
return <Forms.FormText>{$t("vencord.noSettings")}</Forms.FormText>;
return <Forms.FormText>{t("vencord.noSettings")}</Forms.FormText>;
} else {
const options = Object.entries(plugin.options).map(([key, setting]) => {
if (setting.hidden) return null;
@ -228,7 +228,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
</div>
)}
<Forms.FormSection className={Margins.bottom16}>
<Forms.FormTitle tag="h3">{$t("vencord.settings")}</Forms.FormTitle>
<Forms.FormTitle tag="h3">{t("vencord.settings")}</Forms.FormTitle>
{renderSettings()}
</Forms.FormSection>
</ModalContent>
@ -243,7 +243,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
>
Cancel
</Button>
<Tooltip text={$t("vencord.settingsErrors")} shouldShow={!canSubmit()}>
<Tooltip text={t("vencord.settingsErrors")} shouldShow={!canSubmit()}>
{({ onMouseEnter, onMouseLeave }) => (
<Button
size={Button.Sizes.SMALL}
@ -253,12 +253,12 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
onMouseLeave={onMouseLeave}
disabled={!canSubmit()}
>
{$t("vencord.saveAndClose")}
{t("vencord.saveAndClose")}
</Button>
)}
</Tooltip>
</Flex>
{saveError && <Text variant="text-md/semibold" style={{ color: "var(--text-danger)" }}>{$t("vencord.settingsSaveError", { saveError })}</Text>}
{saveError && <Text variant="text-md/semibold" style={{ color: "var(--text-danger)" }}>{t("vencord.settingsSaveError", { saveError })}</Text>}
</Flex>
</ModalFooter>}
</ModalRoot>

View file

@ -33,7 +33,7 @@ import { Margins } from "@utils/margins";
import { classes, isObjectEmpty } from "@utils/misc";
import { openModalLazy } from "@utils/modal";
import { useAwaiter } from "@utils/react";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { Plugin } from "@utils/types";
import { findByPropsLazy } from "@webpack";
import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
@ -66,19 +66,19 @@ function ReloadRequiredCard({ required }: { required: boolean; }) {
<Card className={cl("info-card", { "restart-card": required })}>
{required ? (
<>
<Forms.FormTitle tag="h5">{$t("vencord.pluginHeader.reloadHeader")}</Forms.FormTitle>
<Forms.FormTitle tag="h5">{t("vencord.pluginHeader.reloadHeader")}</Forms.FormTitle>
<Forms.FormText className={cl("dep-text")}>
{$t("vencord.pluginHeader.reloadDescription")}
{t("vencord.pluginHeader.reloadDescription")}
</Forms.FormText>
<Button onClick={() => location.reload()}>
{$t("vencord.pluginHeader.restart")}
{t("vencord.pluginHeader.restart")}
</Button>
</>
) : (
<>
<Forms.FormTitle tag="h5">{$t("vencord.pluginHeader.managementHeader")}</Forms.FormTitle>
<Forms.FormText>{$t("vencord.pluginHeader.iconInformation")}</Forms.FormText>
<Forms.FormText>{$t("vencord.pluginHeader.cogWheel")}</Forms.FormText>
<Forms.FormTitle tag="h5">{t("vencord.pluginHeader.managementHeader")}</Forms.FormTitle>
<Forms.FormText>{t("vencord.pluginHeader.iconInformation")}</Forms.FormText>
<Forms.FormText>{t("vencord.pluginHeader.cogWheel")}</Forms.FormText>
</>
)}
</Card>
@ -184,7 +184,7 @@ export default function PluginSettings() {
React.useEffect(() => {
return () => void (changes.hasChanges && Alerts.show({
title: $t("vencord.restartRequired"),
title: t("vencord.restartRequired"),
body: (
<>
<p>$t("vencord.pluginsNeedRestart")</p>
@ -196,8 +196,8 @@ export default function PluginSettings() {
))}</div>
</>
),
confirmText: $t("vencord.restartNow"),
cancelText: $t("vencord.restartLater"),
confirmText: t("vencord.restartNow"),
cancelText: t("vencord.restartLater"),
onConfirm: () => location.reload()
}));
}, []);
@ -273,7 +273,7 @@ export default function PluginSettings() {
if (isRequired) {
const tooltipText = p.required
? $t("vencord.requiredPlugin")
? t("vencord.requiredPlugin")
: makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled));
requiredPlugins.push(
@ -303,7 +303,7 @@ export default function PluginSettings() {
}
} else {
plugins = requiredPlugins = <Text variant="text-md/normal">{$t("vencord.noSearchResults")}</Text>;
plugins = requiredPlugins = <Text variant="text-md/normal">{t("vencord.noSearchResults")}</Text>;
}
return (
@ -311,18 +311,18 @@ export default function PluginSettings() {
<ReloadRequiredCard required={changes.hasChanges} />
<Forms.FormTitle tag="h5" className={classes(Margins.top20, Margins.bottom8)}>
{$t("vencord.pluginFilters")}
{t("vencord.pluginFilters")}
</Forms.FormTitle>
<div className={cl("filter-controls")}>
<TextInput autoFocus value={searchValue.value} placeholder={$t("vencord.search.placeholder")} onChange={onSearch} className={Margins.bottom20} />
<TextInput autoFocus value={searchValue.value} placeholder={t("vencord.search.placeholder")} onChange={onSearch} className={Margins.bottom20} />
<div className={InputStyles.inputWrapper}>
<Select
options={[
{ label: $t("vencord.search.all"), value: SearchStatus.ALL, default: true },
{ label: $t("vencord.search.enabled"), value: SearchStatus.ENABLED },
{ label: $t("vencord.search.disabled"), value: SearchStatus.DISABLED },
{ label: $t("vencord.search.new"), value: SearchStatus.NEW }
{ label: t("vencord.search.all"), value: SearchStatus.ALL, default: true },
{ label: t("vencord.search.enabled"), value: SearchStatus.ENABLED },
{ label: t("vencord.search.disabled"), value: SearchStatus.DISABLED },
{ label: t("vencord.search.new"), value: SearchStatus.NEW }
]}
serialize={String}
select={onStatusChange}
@ -332,7 +332,7 @@ export default function PluginSettings() {
</div>
</div>
<Forms.FormTitle className={Margins.top20}>{$t("vencord.plugins")}</Forms.FormTitle>
<Forms.FormTitle className={Margins.top20}>{t("vencord.plugins")}</Forms.FormTitle>
<div className={cl("grid")}>
{plugins}
@ -341,7 +341,7 @@ export default function PluginSettings() {
<Forms.FormDivider className={Margins.top20} />
<Forms.FormTitle tag="h5" className={classes(Margins.top20, Margins.bottom8)}>
{$t("vencord.requiredPlugins")}
{t("vencord.requiredPlugins")}
</Forms.FormTitle>
<div className={cl("grid")}>
{requiredPlugins}
@ -353,7 +353,7 @@ export default function PluginSettings() {
function makeDependencyList(deps: string[]) {
return (
<React.Fragment>
<Forms.FormText>{$t("vencord.pluginRequiredBy")}</Forms.FormText>
<Forms.FormText>{t("vencord.pluginRequiredBy")}</Forms.FormText>
{deps.map((dep: string) => <Forms.FormText className={cl("dep-text")}>{dep}</Forms.FormText>)}
</React.Fragment>
);

View file

@ -21,7 +21,7 @@ import "./addonCard.css";
import { classNameFactory } from "@api/Styles";
import { Badge } from "@components/Badge";
import { Switch } from "@components/Switch";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { Text, useRef } from "@webpack/common";
import type { MouseEventHandler, ReactNode } from "react";
@ -68,7 +68,7 @@ export function AddonCard({ disabled, isNew, name, infoButton, footer, author, e
>
{name}
</div>
</div>{isNew && <Badge text={$t("vencord.new")} color="#ED4245" />}
</div>{isNew && <Badge text={t("vencord.new")} color="#ED4245" />}
</Text>
{!!author && (
<Text variant="text-md/normal" className={cl("author")}>

View file

@ -20,7 +20,7 @@ import { Flex } from "@components/Flex";
import { Margins } from "@utils/margins";
import { classes } from "@utils/misc";
import { downloadSettingsBackup, uploadSettingsBackup } from "@utils/settingsSync";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { Button, Card, Text } from "@webpack/common";
import { SettingsTab, wrapTab } from "./shared";
@ -30,19 +30,19 @@ function BackupRestoreTab() {
<SettingsTab title="Backup & Restore">
<Card className={classes("vc-settings-card", "vc-backup-restore-card")}>
<Flex flexDirection="column">
<strong>{$t("vencord.warning")}</strong>
<span>{$t("vencord.backupAndRestore.importWarning")}</span>
<strong>{t("vencord.warning")}</strong>
<span>{t("vencord.backupAndRestore.importWarning")}</span>
</Flex>
</Card>
<Text variant="text-md/normal" className={Margins.bottom8}>
{$t("vencord.backupAndRestore.description")}
{t("vencord.backupAndRestore.description")}
</Text>
<Text variant="text-md/normal" className={Margins.bottom8}>
{$t("vencord.backupAndRestore.exportContains")}
{t("vencord.backupAndRestore.exportContains")}
<ul>
<li>&mdash; {$t("vencord.backupAndRestore.customQuickcss")}</li>
<li>&mdash; {$t("vencord.backupAndRestore.themeLinks")}</li>
<li>&mdash; {$t("vencord.backupAndRestore.pluginSettings")}</li>
<li>&mdash; {t("vencord.backupAndRestore.customQuickcss")}</li>
<li>&mdash; {t("vencord.backupAndRestore.themeLinks")}</li>
<li>&mdash; {t("vencord.backupAndRestore.pluginSettings")}</li>
</ul>
</Text>
<Flex>
@ -50,13 +50,13 @@ function BackupRestoreTab() {
onClick={() => uploadSettingsBackup()}
size={Button.Sizes.SMALL}
>
{$t("vencord.backupAndRestore.importSettings")}
{t("vencord.backupAndRestore.importSettings")}
</Button>
<Button
onClick={downloadSettingsBackup}
size={Button.Sizes.SMALL}
>
{$t("vencord.backupAndRestore.exportSettings")}
{t("vencord.backupAndRestore.exportSettings")}
</Button>
</Flex>
</SettingsTab>

View file

@ -23,7 +23,7 @@ import { Link } from "@components/Link";
import { authorizeCloud, cloudLogger, deauthorizeCloud, getCloudAuth, getCloudUrl } from "@utils/cloud";
import { Margins } from "@utils/margins";
import { deleteCloudSettings, getCloudSettings, putCloudSettings } from "@utils/settingsSync";
import { $t, Translate } from "@utils/translation";
import { t, Translate } from "@utils/translation";
import { Alerts, Button, Forms, Switch, Tooltip } from "@webpack/common";
import { SettingsTab, wrapTab } from "./shared";
@ -46,8 +46,8 @@ async function eraseAllData() {
if (!res.ok) {
cloudLogger.error(`Failed to erase data, API returned ${res.status}`);
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.eraseError", { status: res.status }),
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.eraseError", { status: res.status }),
color: "var(--red-360)"
});
return;
@ -57,8 +57,8 @@ async function eraseAllData() {
await deauthorizeCloud();
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.eraseSuccess"),
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.eraseSuccess"),
color: "var(--green-360)"
});
}
@ -70,7 +70,7 @@ function SettingsSyncSection() {
return (
<Forms.FormSection title="Settings Sync" className={Margins.top16}>
<Forms.FormText variant="text-md/normal" className={Margins.bottom20}>
{$t("vencord.cloud.settings.description")}
{t("vencord.cloud.settings.description")}
</Forms.FormText>
<Switch
key="cloud-sync"
@ -78,15 +78,15 @@ function SettingsSyncSection() {
value={cloud.settingsSync}
onChange={v => { cloud.settingsSync = v; }}
>
{$t("vencord.settingsSync")}
{t("vencord.settingsSync")}
</Switch>
<div className="vc-cloud-settings-sync-grid">
<Button
size={Button.Sizes.SMALL}
disabled={!sectionEnabled}
onClick={() => putCloudSettings(true)}
>{$t("vencord.cloud.settings.syncToCloud")}</Button>
<Tooltip text={$t("vencord.cloud.settings.overwriteWarning")}>
>{t("vencord.cloud.settings.syncToCloud")}</Button>
<Tooltip text={t("vencord.cloud.settings.overwriteWarning")}>
{({ onMouseLeave, onMouseEnter }) => (
<Button
onMouseLeave={onMouseLeave}
@ -95,7 +95,7 @@ function SettingsSyncSection() {
color={Button.Colors.RED}
disabled={!sectionEnabled}
onClick={() => getCloudSettings(true, true)}
>{$t("vencord.cloud.settings.syncFromCloud")}</Button>
>{t("vencord.cloud.settings.syncFromCloud")}</Button>
)}
</Tooltip>
<Button
@ -103,7 +103,7 @@ function SettingsSyncSection() {
color={Button.Colors.RED}
disabled={!sectionEnabled}
onClick={() => deleteCloudSettings()}
>{$t("vencord.cloud.settings.deleteCloudSettings")}</Button>
>{t("vencord.cloud.settings.deleteCloudSettings")}</Button>
</div>
</Forms.FormSection>
);
@ -125,13 +125,13 @@ function CloudTab() {
key="backend"
value={settings.cloud.authenticated}
onChange={v => { v && authorizeCloud(); if (!v) settings.cloud.authenticated = v; }}
note={$t("vencord.cloud.integrations.authorizationNote")}
note={t("vencord.cloud.integrations.authorizationNote")}
>
{$t("vencord.cloud.integrations.enable")}
{t("vencord.cloud.integrations.enable")}
</Switch>
<Forms.FormTitle tag="h5">{$t("vencord.cloud.integrations.backendUrl")}</Forms.FormTitle>
<Forms.FormTitle tag="h5">{t("vencord.cloud.integrations.backendUrl")}</Forms.FormTitle>
<Forms.FormText className={Margins.bottom8}>
{$t("vencord.cloud.integrations.backendNote")}
{t("vencord.cloud.integrations.backendNote")}
</Forms.FormText>
<CheckedTextInput
key="backendUrl"
@ -145,14 +145,14 @@ function CloudTab() {
color={Button.Colors.RED}
disabled={!settings.cloud.authenticated}
onClick={() => Alerts.show({
title: $t("vencord.areYouSure"),
body: $t("vencord.cloud.integrations.eraseWarning"),
title: t("vencord.areYouSure"),
body: t("vencord.cloud.integrations.eraseWarning"),
onConfirm: eraseAllData,
confirmText: $t("vencord.cloud.integrations.eraseIt"),
confirmText: t("vencord.cloud.integrations.eraseIt"),
confirmColor: "vc-cloud-erase-data-danger-btn",
cancelText: $t("vencord.nevermind")
cancelText: t("vencord.nevermind")
})}
>{$t("vencord.cloud.integrations.eraseAllData")}</Button>
>{t("vencord.cloud.integrations.eraseAllData")}</Button>
<Forms.FormDivider className={Margins.top16} />
</Forms.FormSection >
<SettingsSyncSection />

View file

@ -29,7 +29,7 @@ import { classes } from "@utils/misc";
import { openModal } from "@utils/modal";
import { showItemInFolder } from "@utils/native";
import { useAwaiter } from "@utils/react";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { findByPropsLazy, findLazy } from "@webpack";
import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
import type { ComponentType, Ref, SyntheticEvent } from "react";
@ -203,17 +203,17 @@ function ThemesTab() {
return (
<>
<Card className="vc-settings-card">
<Forms.FormTitle tag="h5">{$t("vencord.themes.findThemes")}</Forms.FormTitle>
<Forms.FormTitle tag="h5">{t("vencord.themes.findThemes")}</Forms.FormTitle>
<div style={{ marginBottom: ".5em", display: "flex", flexDirection: "column" }}>
<Link style={{ marginRight: ".5em" }} href="https://betterdiscord.app/themes">
{$t("vencord.themes.betterDiscord")}
{t("vencord.themes.betterDiscord")}
</Link>
<Link href="https://github.com/search?q=discord+theme">GitHub</Link>
</div>
<Forms.FormText>{$t("vencord.themes.betterDiscordNote")}</Forms.FormText>
<Forms.FormText>{t("vencord.themes.betterDiscordNote")}</Forms.FormText>
</Card>
<Forms.FormSection title={$t("vencord.themes.local")}>
<Forms.FormSection title={t("vencord.themes.local")}>
<Card className="vc-settings-quick-actions-card">
<>
{IS_WEB ?
@ -222,7 +222,7 @@ function ThemesTab() {
size={Button.Sizes.SMALL}
disabled={themeDirPending}
>
{$t("vencord.themes.upload")}
{t("vencord.themes.upload")}
<FileInput
ref={fileInputRef}
onChange={onFileUpload}
@ -236,20 +236,20 @@ function ThemesTab() {
size={Button.Sizes.SMALL}
disabled={themeDirPending}
>
{$t("vencord.themes.openFolder")}
{t("vencord.themes.openFolder")}
</Button>
)}
<Button
onClick={refreshLocalThemes}
size={Button.Sizes.SMALL}
>
{$t("vencord.themes.loadMissing")}
{t("vencord.themes.loadMissing")}
</Button>
<Button
onClick={() => VencordNative.quickCss.openEditor()}
size={Button.Sizes.SMALL}
>
{$t("vencord.themes.editQuickCss")}
{t("vencord.themes.editQuickCss")}
</Button>
{Vencord.Settings.plugins.ClientTheme.enabled && (
@ -263,7 +263,7 @@ function ThemesTab() {
))}
size={Button.Sizes.SMALL}
>
{$t("clientTheme.edit")}
{t("clientTheme.edit")}
</Button>
)}
</>
@ -304,12 +304,12 @@ function ThemesTab() {
return (
<>
<Card className="vc-settings-card vc-text-selectable">
<Forms.FormTitle tag="h5">{$t("vencord.themes.pasteLinks")}</Forms.FormTitle>
<Forms.FormText>{$t("vencord.themes.oneLinkPerLine")}</Forms.FormText>
<Forms.FormText>{$t("vencord.themes.useDirect")}</Forms.FormText>
<Forms.FormTitle tag="h5">{t("vencord.themes.pasteLinks")}</Forms.FormTitle>
<Forms.FormText>{t("vencord.themes.oneLinkPerLine")}</Forms.FormText>
<Forms.FormText>{t("vencord.themes.useDirect")}</Forms.FormText>
</Card>
<Forms.FormSection title={$t("vencord.themes.online")} tag="h5">
<Forms.FormSection title={t("vencord.themes.online")} tag="h5">
<TextArea
value={themeText}
onChange={setThemeText}
@ -338,13 +338,13 @@ function ThemesTab() {
className="vc-settings-tab-bar-item"
id={ThemeTab.LOCAL}
>
{$t("vencord.themes.local")}
{t("vencord.themes.local")}
</TabBar.Item>
<TabBar.Item
className="vc-settings-tab-bar-item"
id={ThemeTab.ONLINE}
>
{$t("vencord.themes.online")}
{t("vencord.themes.online")}
</TabBar.Item>
</TabBar>

View file

@ -16,11 +16,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import { maybePromptToUpdate } from "@utils/updater";
export function handleComponentFailed() {
maybePromptToUpdate(
$t("vencord.failureUpdate")
t("vencord.failureUpdate")
);
}

View file

@ -10,7 +10,7 @@ import { definePluginSettings } from "@api/Settings";
import { Devs } from "@utils/constants";
import { Margins } from "@utils/margins";
import { classes } from "@utils/misc";
import { $t } from "@utils/translation";
import { t } from "@utils/translation";
import definePlugin, { OptionType, StartAt } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy, findStoreLazy } from "@webpack";
import { Button, Forms, useStateFromStores } from "@webpack/common";
@ -113,7 +113,7 @@ const settings = definePluginSettings({
export default definePlugin({
name: "ClientTheme",
authors: [Devs.F53, Devs.Nuckyz],
description: $t("clientTheme.description"),
description: t("clientTheme.description"),
settings,
startAt: StartAt.DOMContentLoaded,

View file

@ -23,7 +23,7 @@ import { OAuth2AuthorizeModal, UserStore } from "@webpack/common";
import { Logger } from "./Logger";
import { openModal } from "./modal";
import { $t } from "./translation";
import { t } from "./translation";
export const cloudLogger = new Logger("Cloud", "#39b7e0");
export const getCloudUrl = () => new URL(Settings.cloud.url);
@ -84,8 +84,8 @@ export async function authorizeCloud() {
var { clientId, redirectUri } = await oauthConfiguration.json();
} catch {
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.setupFailure.oauth")
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.setupFailure.oauth")
});
Settings.cloud.authenticated = false;
return;
@ -114,22 +114,22 @@ export async function authorizeCloud() {
cloudLogger.info("Authorized with secret");
await setAuthorization(secret);
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.enabled")
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.enabled")
});
Settings.cloud.authenticated = true;
} else {
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.setupFailure.missingSecret")
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.setupFailure.missingSecret")
});
Settings.cloud.authenticated = false;
}
} catch (e: any) {
cloudLogger.error("Failed to authorize", e);
showNotification({
title: $t("vencord.cloudIntegrations"),
body: $t("vencord.cloud.integrations.setupFailure.generic", { error: e.toString() })
title: t("vencord.cloudIntegrations"),
body: t("vencord.cloud.integrations.setupFailure.generic", { error: e.toString() })
});
Settings.cloud.authenticated = false;
}

View file

@ -19,7 +19,7 @@
import { Clipboard, Toasts } from "@webpack/common";
import { DevsById } from "./constants";
import { $t } from "./translation";
import { t } from "./translation";
/**
* Calls .join(" ") on the arguments
@ -37,12 +37,12 @@ export function sleep(ms: number): Promise<void> {
}
export function copyWithToast(text: string, toastMessage?: string) {
toastMessage ??= $t("vencord.copiedToClipboard");
toastMessage ??= t("vencord.copiedToClipboard");
if (Clipboard.SUPPORTS_COPY) {
Clipboard.copy(text);
} else {
toastMessage = $t("vencord.clipboardNotSupported");
toastMessage = t("vencord.clipboardNotSupported");
}
Toasts.show({
message: toastMessage,

View file

@ -24,7 +24,7 @@ import { deflateSync, inflateSync } from "fflate";
import { getCloudAuth, getCloudUrl } from "./cloud";
import { Logger } from "./Logger";
import { relaunch } from "./native";
import { $t } from "./translation";
import { t } from "./translation";
import { chooseFile, saveFile } from "./web";
export async function importSettings(data: string) {
@ -69,10 +69,10 @@ const toast = (type: number, message: string) =>
});
const toastSuccess = () =>
toast(Toasts.Type.SUCCESS, $t("vencord.importedSettings"));
toast(Toasts.Type.SUCCESS, t("vencord.importedSettings"));
const toastFailure = (err: any) =>
toast(Toasts.Type.FAILURE, $t("vencord.failedToImport", { error: String(err) }));
toast(Toasts.Type.FAILURE, t("vencord.failedToImport", { error: String(err) }));
export async function uploadSettingsBackup(showToast = true): Promise<void> {
if (IS_DISCORD_DESKTOP) {
@ -129,8 +129,8 @@ export async function putCloudSettings(manual?: boolean) {
if (!res.ok) {
cloudSettingsLogger.error(`Failed to sync up, API returned ${res.status}`);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.syncErrorUp.api", { status: res.status.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.syncErrorUp.api", { status: res.status.toString() }),
color: "var(--red-360)"
});
return;
@ -144,16 +144,16 @@ export async function putCloudSettings(manual?: boolean) {
if (manual) {
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.syncSuccess"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.syncSuccess"),
noPersist: true,
});
}
} catch (e: any) {
cloudSettingsLogger.error("Failed to sync up", e);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.syncErrorUp.generic", { error: e.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.syncErrorUp.generic", { error: e.toString() }),
color: "var(--red-360)"
});
}
@ -174,8 +174,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
cloudSettingsLogger.info("No settings on the cloud");
if (shouldNotify)
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.nothingOnline"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.nothingOnline"),
noPersist: true
});
return false;
@ -185,8 +185,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
cloudSettingsLogger.info("Settings up to date");
if (shouldNotify)
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.upToDate"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.upToDate"),
noPersist: true
});
return false;
@ -195,8 +195,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
if (!res.ok) {
cloudSettingsLogger.error(`Failed to sync down, API returned ${res.status}`);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.syncErrorDown.api", { status: res.status.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.syncErrorDown.api", { status: res.status.toString() }),
color: "var(--red-360)"
});
return false;
@ -209,8 +209,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
if (!force && written < localWritten) {
if (shouldNotify)
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.localNewer"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.localNewer"),
noPersist: true,
});
return;
@ -228,8 +228,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
cloudSettingsLogger.info("Settings loaded from cloud successfully");
if (shouldNotify)
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.updated"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.updated"),
color: "var(--green-360)",
onClick: IS_WEB ? () => location.reload() : relaunch,
noPersist: true
@ -239,8 +239,8 @@ export async function getCloudSettings(shouldNotify = true, force = false) {
} catch (e: any) {
cloudSettingsLogger.error("Failed to sync down", e);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.syncErrorDown.generic", { error: e.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.syncErrorDown.generic", { error: e.toString() }),
color: "var(--red-360)"
});
@ -258,8 +258,8 @@ export async function deleteCloudSettings() {
if (!res.ok) {
cloudSettingsLogger.error(`Failed to delete, API returned ${res.status}`);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.deleteError.api", { error: res.status.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.deleteError.api", { error: res.status.toString() }),
color: "var(--red-360)"
});
return;
@ -267,15 +267,15 @@ export async function deleteCloudSettings() {
cloudSettingsLogger.info("Settings deleted from cloud successfully");
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.deleted"),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.deleted"),
color: "var(--green-360)"
});
} catch (e: any) {
cloudSettingsLogger.error("Failed to delete", e);
showNotification({
title: $t("vencord.cloudSettings"),
body: $t("vencord.cloud.settings.deleteError.generic", { error: e.toString() }),
title: t("vencord.cloudSettings"),
body: t("vencord.cloud.settings.deleteError.generic", { error: e.toString() }),
color: "var(--red-360)"
});
}

View file

@ -100,7 +100,7 @@ function _t(key: string, bundle: any): Translation {
* @param variables The variables to interpolate into the resultant string. If dealing with plurals, `count` must be set.
* @returns A translated string.
*/
export function $t(key: string, variables?: Record<string, any>): string {
export function t(key: string, variables?: Record<string, any>): string {
const getter = (): string => {
const translation = _t(key, loadedLocale);
@ -153,13 +153,13 @@ interface TranslateProps {
}
/**
* A translation component. Follows the same rules as {@link $t}, but lets you add components to strings.
* A translation component. Follows the same rules as {@link t}, but lets you add components to strings.
* @param param0 Component props.
*/
export function Translate({ i18nKey, variables, children: trueChildren }: TranslateProps): JSX.Element {
const children = [trueChildren].flat();
const translation = $t(i18nKey, variables);
const translation = t(i18nKey, variables);
const parts = translation.split(/(<\d+>.*?<\/\d+>)/g);

View file

@ -20,7 +20,7 @@ import gitHash from "~git-hash";
import { Logger } from "./Logger";
import { relaunch } from "./native";
import { $t } from "./translation";
import { t } from "./translation";
import { IpcRes } from "./types";
export const UpdateLogger = /* #__PURE__*/ new Logger("Updater", "white");
@ -71,7 +71,7 @@ export async function maybePromptToUpdate(confirmMessage: string, checkForDev =
const isOutdated = await checkForUpdates();
if (isOutdated) {
const wantsUpdate = confirm(confirmMessage);
if (wantsUpdate && isNewer) return alert($t("vencord.gitCopyNewer"));
if (wantsUpdate && isNewer) return alert(t("vencord.gitCopyNewer"));
if (wantsUpdate) {
await update();
relaunch();
@ -79,6 +79,6 @@ export async function maybePromptToUpdate(confirmMessage: string, checkForDev =
}
} catch (err) {
UpdateLogger.error(err);
alert($t("vencord.updaterRepeatFailed"));
alert(t("vencord.updaterRepeatFailed"));
}
}