From 22e53966847b957fd07b1fc1c0373ab673dd262a Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 8 Jun 2024 19:51:56 +0100 Subject: [PATCH] chore: restructure locale keys --- src/Vencord.ts | 8 +- src/components/ErrorBoundary.tsx | 4 +- .../PluginSettings/ContributorModal.tsx | 8 +- src/components/PluginSettings/index.tsx | 3 +- src/components/VencordSettings/AddonCard.tsx | 2 +- src/components/handleComponentFailed.ts | 2 +- src/utils/cloud.tsx | 16 +-- src/utils/misc.tsx | 4 +- src/utils/settingsSync.ts | 52 ++++---- src/utils/updater.ts | 4 +- translations/de/vencord.json | 14 +- translations/en/vencord.json | 122 ++++++++---------- 12 files changed, 106 insertions(+), 133 deletions(-) diff --git a/src/Vencord.ts b/src/Vencord.ts index 973033a23..d2fd47c92 100644 --- a/src/Vencord.ts +++ b/src/Vencord.ts @@ -55,8 +55,8 @@ async function syncSettings() { ) { // show a notification letting them know and tell them how to fix it showNotification({ - title: $t("vencord.utils.cloud.integrations.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.cloud.settings.updated"), + title: $t("vencord.cloudSettings"), + body: $t("vencord.cloud.settings.updated"), color: "var(--green-360)", onClick: relaunch }); diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 6a492cf8e..445a303a3 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -86,11 +86,11 @@ const ErrorBoundary = LazyComponent(() => { {...this.state} />; - const msg = this.props.message || $t("vencord.components.errorBoundary.error"); + const msg = this.props.message || $t("vencord.errorBoundaryDescription"); return ( -

{$t("vencord.components.errorBoundary.ohNo")}

+

{$t("vencord.ohNo")}

{msg}

{this.state.message} diff --git a/src/components/PluginSettings/ContributorModal.tsx b/src/components/PluginSettings/ContributorModal.tsx index 2ab897d06..1de8b1b68 100644 --- a/src/components/PluginSettings/ContributorModal.tsx +++ b/src/components/PluginSettings/ContributorModal.tsx @@ -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 { 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"; @@ -74,8 +74,6 @@ function ContributorModal({ user }: { user: User; }) { .sort((a, b) => Number(a.required ?? false) - Number(b.required ?? false)); }, [user.id, user.username]); - const ContributedHyperLink = contributed; - return ( <>
@@ -109,7 +107,7 @@ function ContributorModal({ user }: { user: User; }) {
- + @@ -121,7 +119,7 @@ function ContributorModal({ user }: { user: User; }) { key={p.name} plugin={p} disabled={p.required ?? false} - onRestartNeeded={() => showToast("Restart to apply changes!")} + onRestartNeeded={() => showToast($t("vencord.pluginRestart"))} /> )} diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 978d2e85a..fa48bab86 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -33,6 +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 { Plugin } from "@utils/types"; import { findByPropsLazy } from "@webpack"; import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common"; @@ -272,7 +273,7 @@ export default function PluginSettings() { if (isRequired) { const tooltipText = p.required - ? "This plugin is required for Vencord to function." + ? $t("vencord.requiredPlugin") : makeDependencyList(depMap[p.name]?.filter(d => settings.plugins[d].enabled)); requiredPlugins.push( diff --git a/src/components/VencordSettings/AddonCard.tsx b/src/components/VencordSettings/AddonCard.tsx index 774cf39fa..171a06d48 100644 --- a/src/components/VencordSettings/AddonCard.tsx +++ b/src/components/VencordSettings/AddonCard.tsx @@ -68,7 +68,7 @@ export function AddonCard({ disabled, isNew, name, infoButton, footer, author, e > {name} - {isNew && } + {isNew && } {!!author && ( diff --git a/src/components/handleComponentFailed.ts b/src/components/handleComponentFailed.ts index 7e818c02e..281c915df 100644 --- a/src/components/handleComponentFailed.ts +++ b/src/components/handleComponentFailed.ts @@ -21,6 +21,6 @@ import { maybePromptToUpdate } from "@utils/updater"; export function handleComponentFailed() { maybePromptToUpdate( - $t("vencord.components.componentFailed") + $t("vencord.failureUpdate") ); } diff --git a/src/utils/cloud.tsx b/src/utils/cloud.tsx index feb3f2dad..a83c86337 100644 --- a/src/utils/cloud.tsx +++ b/src/utils/cloud.tsx @@ -84,8 +84,8 @@ export async function authorizeCloud() { var { clientId, redirectUri } = await oauthConfiguration.json(); } catch { showNotification({ - title: $t("vencord.utils.cloud.integrations.title"), - body: $t("vencord.utils.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.utils.cloud.integrations.title"), - body: $t("vencord.utils.cloud.integrations.enabled") + title: $t("vencord.cloudIntegrations"), + body: $t("vencord.cloud.integrations.enabled") }); Settings.cloud.authenticated = true; } else { showNotification({ - title: $t("vencord.utils.cloud.integrations.title"), - body: $t("vencord.utils.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.utils.cloud.integrations.title"), - body: $t("vencord.utils.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; } diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 4077fe576..f36b3beb0 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -37,12 +37,12 @@ export function sleep(ms: number): Promise { } export function copyWithToast(text: string, toastMessage?: string) { - toastMessage ??= $t("vencord.utils.misc.clipboard.copied"); + toastMessage ??= $t("vencord.copiedToClipboard"); if (Clipboard.SUPPORTS_COPY) { Clipboard.copy(text); } else { - toastMessage = $t("vencord.utils.misc.clipboard.noSupport"); + toastMessage = $t("vencord.clipboardNotSupported"); } Toasts.show({ message: toastMessage, diff --git a/src/utils/settingsSync.ts b/src/utils/settingsSync.ts index 81ca92bfc..a8e2141b2 100644 --- a/src/utils/settingsSync.ts +++ b/src/utils/settingsSync.ts @@ -69,10 +69,10 @@ const toast = (type: number, message: string) => }); const toastSuccess = () => - toast(Toasts.Type.SUCCESS, $t("vencord.utils.settingsSync.imported")); + toast(Toasts.Type.SUCCESS, $t("vencord.importedSettings")); const toastFailure = (err: any) => - toast(Toasts.Type.FAILURE, $t("vencord.utils.settingsSync.failedToImport", { error: String(err) })); + toast(Toasts.Type.FAILURE, $t("vencord.failedToImport", { error: String(err) })); export async function uploadSettingsBackup(showToast = true): Promise { 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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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.utils.cloud.settings.title"), - body: $t("vencord.utils.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)" }); } diff --git a/src/utils/updater.ts b/src/utils/updater.ts index 26d7e25f9..31b1cd20e 100644 --- a/src/utils/updater.ts +++ b/src/utils/updater.ts @@ -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.utils.updater.gitNewer")); + 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.utils.updater.failed")); + alert($t("vencord.updaterRepeatFailed")); } } diff --git a/translations/de/vencord.json b/translations/de/vencord.json index da9941495..12446e09d 100644 --- a/translations/de/vencord.json +++ b/translations/de/vencord.json @@ -1,13 +1,7 @@ { - "components": { - "pluginSettings": { - "contributorModal": { - "contributed": { - "zero": "Diese Person hat keine Plugins erstellt. Sie haben wahrscheinlich auf andere Weise <0>zu Vencord beigetragen!", - "one": "Diese Person hat zu einem Plugin <0>beigetragen!", - "other": "Diese Person hat zu {count} Plugins <0>beigetragen!" - } - } - } + "pluginContributed": { + "zero": "Diese Person hat keine Plugins erstellt. Sie haben wahrscheinlich auf andere Weise <0>zu Vencord beigetragen!", + "one": "Diese Person hat zu einem Plugin <0>beigetragen!", + "other": "Diese Person hat zu {count} Plugins <0>beigetragen!" } } diff --git a/translations/en/vencord.json b/translations/en/vencord.json index ca08ff5ed..8d74e4b39 100644 --- a/translations/en/vencord.json +++ b/translations/en/vencord.json @@ -1,78 +1,58 @@ { - "components": { - "componentFailed": "Uh Oh! Failed to render this Page. However, there is an update available that might fix it. Would you like to update and restart now?", - "errorBoundary": { - "error": "An error occurred while rendering this Component. More info can be found below and in your console.", - "ohNo": "Oh no!" + "ohNo": "Oh no!", + "errorBoundaryDescription": "An error occurred while rendering this Component. More info can be found below and in your console.", + "failureUpdate": "Uh Oh! Failed to render this Page. However, there is an update available that might fix it. Would you like to update and restart now?", + "pluginRestart": "Restart to apply changes!", + "requiredPlugin": "This plugin is required for Vencord to function.", + "new": "NEW", + "pluginContributed": { + "one": "This person has <0>contributed to one plugin!", + "other": "This person has <0>contributed to {count} plugins!", + "zero": "This person has not made any plugins. They likely <0>contributed to Vencord in other ways!" }, - "pluginSettings": { - "contributorModal": { - "contributed": { - "zero": "This person has not made any plugins. They likely <0>contributed to Vencord in other ways!", - "one": "This person has <0>contributed to one plugin!", - "other": "This person has <0>contributed to {count} plugins!" - } - } + "update": { + "available": "A Vencord update is available!", + "clickToRestart": "Click here to restart", + "clickToView": "Click here to view the update", + "updated": "Vencord has been updated!" }, - "vencordSettings": { - "addonCard": { - "new": "NEW" - } - } - }, - "update": { - "available": "A Vencord update is available!", - "clickToRestart": "Click here to restart", - "clickToView": "Click here to view the update", - "updated": "Vencord has been updated!" - }, - "utils": { + "cloudIntegrations": "Cloud Integrations", + "cloudSettings": "Cloud Settings", "cloud": { - "integrations": { - "enabled": "Cloud integrations enabled!", - "reauthenticate": "We've noticed you have cloud integrations enabled in another client! Due to limitations, you will need to re-authenticate to continue using them. Click here to go to the settings page to do so!", - "setupFailure": { - "generic": "Setup failed ({error}).", - "missingSecret": "Setup failed (no secret returned?).", - "oauth": "Setup failed (couldn't retrieve OAuth configuration)." + "integrations": { + "enabled": "Cloud integrations enabled!", + "reauthenticate": "We've noticed you have cloud integrations enabled in another client! Due to limitations, you will need to re-authenticate to continue using them. Click here to go to the settings page to do so!", + "setupFailure": { + "generic": "Setup failed ({error}).", + "missingSecret": "Setup failed (no secret returned?).", + "oauth": "Setup failed (couldn't retrieve OAuth configuration)." + } }, - "title": "Cloud Integrations" - }, - "settings": { - "deleteError": { - "api": "Could not delete settings (API returned {status}).", - "generic": "Could not delete settings ({error})." - }, - "deleted": "Settings deleted from cloud!", - "localNewer": "Your local settings are newer than the cloud ones.", - "nothingOnline": "There are no settings in the cloud.", - "syncErrorDown": { - "api": "Could not synchronize settings from the cloud (API returned {status}).", - "generic": "Could not synchronize settings from the cloud ({error})." - }, - "syncErrorUp": { - "api": "Could not synchronize settings to the cloud (API returned {status}).", - "generic": "Could not synchronize settings to the cloud ({error})." - }, - "syncSuccess": "Synchronized settings to the cloud!", - "title": "Cloud Settings", - "upToDate": "Your settings are up to date.", - "updated": "Your settings have been updated! Click here to restart to fully apply changes!" - } + "settings": { + "deleteError": { + "api": "Could not delete settings (API returned {status}).", + "generic": "Could not delete settings ({error})." + }, + "deleted": "Settings deleted from cloud!", + "localNewer": "Your local settings are newer than the cloud ones.", + "nothingOnline": "There are no settings in the cloud.", + "syncErrorDown": { + "api": "Could not synchronize settings from the cloud (API returned {status}).", + "generic": "Could not synchronize settings from the cloud ({error})." + }, + "syncErrorUp": { + "api": "Could not synchronize settings to the cloud (API returned {status}).", + "generic": "Could not synchronize settings to the cloud ({error})." + }, + "syncSuccess": "Synchronized settings to the cloud!", + "upToDate": "Your settings are up to date.", + "updated": "Your settings have been updated! Click here to restart to fully apply changes!" + } }, - "misc": { - "clipboard": { - "copied": "Copied to clipboard!", - "noSupport": "Your browser does not support copying to clipboard" - } - }, - "settingsSync": { - "failedToImport": "Failed to import settings: {error}", - "imported": "Settings successfully imported. Restart to apply changes!" - }, - "updater": { - "failed": "That also failed :( Try updating or re-installing with the installer!", - "gitNewer": "Your local copy has more recent commits. Please stash or reset them." - } - } + "copiedToClipboard": "Copied to clipboard!", + "clipboardNotSupported": "Your browser does not support copying to clipboard", + "failedToImport": "Failed to import settings: {error}", + "importedSettings": "Settings successfully imported. Restart to apply changes!", + "updaterRepeatFailed": "That also failed :( Try updating or re-installing with the installer!", + "gitCopyNewer": "Your local copy has more recent commits. Please stash or reset them." }