diff --git a/src/core/i18n/default.json b/src/core/i18n/default.json index 29150a8..bbf7d39 100644 --- a/src/core/i18n/default.json +++ b/src/core/i18n/default.json @@ -3,6 +3,7 @@ "ARE_YOU_SURE_TO_CLEAR_DATA": "Are you sure you wish to clear the data of {name}?", "ARE_YOU_SURE_TO_DELETE_PLUGIN": "Are you sure you wish to delete {name}? This will clear all of the plugin's data.", "ARE_YOU_SURE_TO_DELETE_THEME": "Are you sure you wish to delete {name}?", + "ASSET_BROWSER": "Asset Browser", "BRAND": "Brand", "BUNNY": "Bunny", "BUNNY_URL": "Bunny URL", @@ -20,10 +21,14 @@ "COMMAND_EVAL_OPT_CODE": "The code to evaluate.", "COMMAND_PLUGINS_DESC": "Send list of installed plugins.", "COMMAND_PLUGINS_OPT_EPHEMERALLY": "Send plugins list ephemerally.", + "COMPONENT": "Component", "CONFIRMATION_LINK_IS_A_TYPE": "This link is a **{urlType, select, plugin {Plugin} theme {Theme} other {Add-on}}**, would you like to install it?", "CONNECT_TO_DEBUG_WEBSOCKET": "Connect to debug websocket", "CONNECT_TO_REACT_DEVTOOLS": "Connect to React DevTools", + "COPIED_TO_CLIPBOARD": "Copied plugin URL to clipboard", "COPY_URL": "Copy URL", + "DEBUG": "Debug", + "DEBUGGER_URL": "Debugger URL", "DELETE": "Delete", "DEVELOPER": "Developer", "DEVELOPER_SETTINGS": "Developer Settings", @@ -31,26 +36,31 @@ "DISABLE_UPDATES": "Disable updates", "DISCORD_SERVER": "Discord Server", "ENABLE_UPDATES": "Enable updates", + "ERROR_BOUNDARY_TOOLS_LABEL": "ErrorBoundary Tools", "GENERAL": "General", "GITHUB": "GitHub", "HOLD_UP": "Hold Up", "INFO": "Info", "INSTALL": "Install", + "INSTALL_ADDON": "Install Add-on", "INSTALL_PLUGIN": "Install Plugin", "INSTALL_THEME": "Install Theme", - "INSTALL_TITLE": "Install {title}", "LINKS": "Links", + "LOAD_FROM_CUSTOM_URL": "Load from custom url", + "LOAD_FROM_CUSTOM_URL_DEC": "Load Bunny from a custom endpoint.", + "LOAD_REACT_DEVTOOLS": "Load React DevTools", "LOADER": "Loader", "MACHINE_ID": "Machine ID", "MANUFACTURER": "Manufacturer", + "MESSAGE": "Message", "MODAL_THEME_REFETCHED": "Theme refetched", "MODAL_THEME_REFETCHED_DESC": "A reload is required to see the changes. Do you want to reload now?", "MODAL_UNPROXIED_PLUGIN_DESC": "The plugin you are trying to install has not been proxied/verified by staffs. Are you sure you want to continue?", "MODAL_UNPROXIED_PLUGIN_HEADER": "Unproxied Plugin", + "MODEL": "Model", "OPEN_IN_BROWSER": "Open in Browser", "OPERATING_SYSTEM": "Operating System", "OVERFLOW_PLUGIN_SETTINGS": "Plugin settings", - "PHONE_MODEL": "Model", "PLATFORM": "Platform", "PLUGINS": "Plugins", "REFETCH": "Refetch", @@ -61,20 +71,22 @@ "RELOAD_IN_SAFE_MODE": "Reload in Safe Mode", "RELOAD_IN_SAFE_MODE_DESC": "This will reload Discord without loading addons", "RETRY": "Retry", + "RETRY_RENDER": "Retry Render", "SAFE_MODE": "Safe Mode", "SAFE_MODE_NOTICE_PLUGINS": "You are in Safe Mode, so plugins cannot be loaded. Disable any misbehaving plugins, then return to Normal Mode from the General settings page.", - "SAFE_MODE_NOTICE_THEMES": "You are in Safe Mode, meaning themes have been temporarily disabled.", - "SAFE_MODE_NOTICE_THEMES_EXTEND": "If a theme appears to be causing the issue, you can press below to disable it persistently.", + "SAFE_MODE_NOTICE_THEMES": "You are in Safe Mode, meaning themes have been temporarily disabled.{enabled, select, true { If a theme appears to be causing the issue, you can press below to disable it persistently.}}", "SEARCH": "Search", + "STACK_TRACE": "Stack Trace", + "SUCCESSFULLY_INSTALLED": "Successfully installed", "THEME_REFETCH_FAILED": "Failed to refetch theme!", "THEME_REFETCH_SUCCESSFUL": "Successfully refetched theme.", "THEMES": "Themes", "THEMES_RELOAD_FOR_CHANGES": "Reload the app to fully apply changes!", "TOASTS_INSTALLED_PLUGIN": "Installed plugin", - "TOASTS_SUCCESSFULLY_INSTALLED": "Successfully installed", - "TOASTS_COPIED_TO_CLIPBOARD": "Copied plugin URL to clipboard", "UH_OH": "Uh oh.", "UNINSTALL": "Uninstall", "UNINSTALL_TITLE": "Uninstall {title}", + "URL_PLACEHOLDER": "https://example.com", + "VERSION": "Version", "VERSIONS": "Versions" } \ No newline at end of file diff --git a/src/core/i18n/index.ts b/src/core/i18n/index.ts index c008ab4..2e97e3c 100644 --- a/src/core/i18n/index.ts +++ b/src/core/i18n/index.ts @@ -1,4 +1,5 @@ import { findByName } from "@lib/metro/filters"; +import { PrimitiveType } from "intl-messageformat"; import langDefault from "./default.json"; @@ -12,9 +13,9 @@ export const Strings = new Proxy({}, { } }) as Record; -type FRet = T extends string ? string : string | T | (string | T)[]; +type FormatStringRet = T extends PrimitiveType ? string : string | T | (string | T)[]; -export function formatString(key: I18nKey, val: Record): FRet { +export function formatString(key: I18nKey, val: Record): FormatStringRet { const str = Strings[key]; // @ts-ignore return new IntlMessageFormat(str).format(val); diff --git a/src/core/plugins/quickInstall/url.tsx b/src/core/plugins/quickInstall/url.tsx index 62148f5..d1b0f3b 100644 --- a/src/core/plugins/quickInstall/url.tsx +++ b/src/core/plugins/quickInstall/url.tsx @@ -27,7 +27,7 @@ function typeFromUrl(url: string) { function installWithToast(type: "plugin" | "theme", url: string) { (type === "plugin" ? installPlugin : installTheme)(url) .then(() => { - showToast(Strings.TOASTS_SUCCESSFULLY_INSTALLED, getAssetIDByName("Check")); + showToast(Strings.SUCCESSFULLY_INSTALLED, getAssetIDByName("Check")); }) .catch((e: Error) => { showToast(e.message, getAssetIDByName("Small")); @@ -49,7 +49,7 @@ export default () => { if (!urlType) return; options.push({ - label: formatString("INSTALL_TITLE", { urlType }), + label: Strings.INSTALL_ADDON, onPress: () => installWithToast(urlType, url), }); }) diff --git a/src/core/ui/components/AddonPage.tsx b/src/core/ui/components/AddonPage.tsx index 4353fc1..97a3e2d 100644 --- a/src/core/ui/components/AddonPage.tsx +++ b/src/core/ui/components/AddonPage.tsx @@ -1,4 +1,4 @@ -import { formatString, Strings } from "@core/i18n"; +import { Strings } from "@core/i18n"; import { CardWrapper } from "@core/ui/components/Card"; import { getAssetIDByName } from "@lib/api/assets"; import { useProxy } from "@lib/api/storage"; @@ -14,6 +14,7 @@ import { FlatList, View } from "react-native"; interface AddonPageProps { title: string; + floatingButtonText: string; fetchFunction: (url: string) => Promise; items: Record; safeModeMessage: string; @@ -38,7 +39,7 @@ function getItemsByQuery(items: T[], query: string): const reanimated = findByProps("useSharedValue"); const { FloatingActionButton } = findByProps("FloatingActionButton"); -export default function AddonPage({ title, fetchFunction, items, safeModeMessage, safeModeExtras, card: CardComponent }: AddonPageProps) { +export default function AddonPage({ title, floatingButtonText, fetchFunction, items, safeModeMessage, safeModeExtras, card: CardComponent }: AddonPageProps) { useProxy(settings); useProxy(items); @@ -73,16 +74,16 @@ export default function AddonPage({ title, fetchFunction, items, safeModeMess renderItem={({ item, index }) => } /> { // from ./InstallButton.tsx clipboard.getString().then(content => showInputAlert({ - title: formatString("INSTALL_TITLE", { title }), + title: floatingButtonText, initialValue: content.match(HTTP_REGEX_MULTI)?.[0] ?? "", - placeholder: "https://example.com/", + placeholder: Strings.URL_PLACEHOLDER, onConfirm: (input: string) => fetchFunction(input), confirmText: Strings.INSTALL, cancelText: Strings.CANCEL, diff --git a/src/core/ui/components/InstallButton.tsx b/src/core/ui/components/InstallButton.tsx index 1166f6a..40c3a60 100644 --- a/src/core/ui/components/InstallButton.tsx +++ b/src/core/ui/components/InstallButton.tsx @@ -28,7 +28,7 @@ export default function InstallButton({ alertTitle, installFunction: fetchFuncti showInputAlert({ title: alertTitle, initialValue: content.match(HTTP_REGEX_MULTI)?.[0] ?? "", - placeholder: "https://example.com/", + placeholder: Strings.URL_PLACEHOLDER, onConfirm: (input: string) => fetchFunction(input), confirmText: Strings.INSTALL, cancelText: Strings.CANCEL, diff --git a/src/core/ui/settings/pages/AssetBrowser.tsx b/src/core/ui/settings/pages/AssetBrowser.tsx index 0cabe5e..09ce8d6 100644 --- a/src/core/ui/settings/pages/AssetBrowser.tsx +++ b/src/core/ui/settings/pages/AssetBrowser.tsx @@ -13,7 +13,6 @@ export default function AssetBrowser() { setSearch(v)} - placeholder="Search" /> a.name.includes(search) || a.id.toString() === search)} diff --git a/src/core/ui/settings/pages/Developer.tsx b/src/core/ui/settings/pages/Developer.tsx index 5872902..bb41f4d 100644 --- a/src/core/ui/settings/pages/Developer.tsx +++ b/src/core/ui/settings/pages/Developer.tsx @@ -37,14 +37,14 @@ export default function Developer() { ws://} defaultValue={settings.debuggerUrl} onChange={(v: string) => settings.debuggerUrl = v} /> - + } @@ -64,8 +64,8 @@ export default function Developer() { {isLoaderConfigSupported() && <> } value={loaderConfig.customLoadUrl.enabled} onValueChange={(v: boolean) => { @@ -80,8 +80,8 @@ export default function Developer() { label={Strings.BUNNY_URL} />} />} {isReactDevToolsPreloaded() && } value={loaderConfig.loadReactDevTools} onValueChange={(v: boolean) => { @@ -93,17 +93,17 @@ export default function Developer() { } trailing={TableRow.Arrow} onPress={() => navigation.push("VendettaCustomPage", { - title: "Asset Browser", + title: Strings.ASSET_BROWSER, render: AssetBrowser, })} /> } onPress={() => showSimpleActionSheet({ key: "ErrorBoundaryTools", diff --git a/src/core/ui/settings/pages/General.tsx b/src/core/ui/settings/pages/General.tsx index 8e0ee64..cd3584b 100644 --- a/src/core/ui/settings/pages/General.tsx +++ b/src/core/ui/settings/pages/General.tsx @@ -80,7 +80,7 @@ export default function General() { icon: "ic_settings_boost_24px" }, { - label: Strings.PHONE_MODEL, + label: Strings.MODEL, version: debugInfo.device.model, icon: "ic_phonelink_24px" }, diff --git a/src/core/ui/settings/pages/Plugins.tsx b/src/core/ui/settings/pages/Plugins.tsx index e353756..566ba03 100644 --- a/src/core/ui/settings/pages/Plugins.tsx +++ b/src/core/ui/settings/pages/Plugins.tsx @@ -11,6 +11,7 @@ export default function Plugins() { return ( title={Strings.PLUGINS} + floatingButtonText={Strings.INSTALL_PLUGIN} fetchFunction={installPlugin} items={plugins} safeModeMessage={Strings.SAFE_MODE_NOTICE_PLUGINS} diff --git a/src/core/ui/settings/pages/Themes.tsx b/src/core/ui/settings/pages/Themes.tsx index 351ad35..4897fb9 100644 --- a/src/core/ui/settings/pages/Themes.tsx +++ b/src/core/ui/settings/pages/Themes.tsx @@ -1,4 +1,4 @@ -import { Strings } from "@core/i18n"; +import { formatString, Strings } from "@core/i18n"; import AddonPage from "@core/ui/components/AddonPage"; import ThemeCard from "@core/ui/components/ThemeCard"; import { useProxy } from "@lib/api/storage"; @@ -13,9 +13,10 @@ export default function Themes() { return ( title={Strings.THEMES} + floatingButtonText={Strings.INSTALL_THEME} fetchFunction={installTheme} items={themes} - safeModeMessage={`${Strings.SAFE_MODE_NOTICE_THEMES}${settings.safeMode?.currentThemeId ? ` ${Strings.SAFE_MODE_NOTICE_THEMES_EXTEND}` : ""}`} + safeModeMessage={formatString("SAFE_MODE_NOTICE_THEMES", { enabled: Boolean(settings.safeMode?.currentThemeId) })} safeModeExtras={settings.safeMode?.currentThemeId ?