diff --git a/build.mjs b/build.mjs index 422cc3b..737ba5d 100644 --- a/build.mjs +++ b/build.mjs @@ -65,7 +65,7 @@ try { console.log(`swc plugin: time-string="${timeString}"`); }) - build.onLoad({ filter: /\.[jt]sx?/ }, async args => { + build.onLoad({ filter: /\.[jt]sx?$/ }, async args => { const result = await swc.transformFile(args.path, { jsc: { externalHelpers: true, diff --git a/src/lib/i18n/default.json b/src/lib/i18n/default.json new file mode 100644 index 0000000..44f0071 --- /dev/null +++ b/src/lib/i18n/default.json @@ -0,0 +1,70 @@ +{ + "ACTIONS": "Actions", + "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}?", + "BRAND": "Brand", + "BUNNY": "Bunny", + "BUNNY_URL": "Bunny URL", + "BYTECODE": "Bytecode", + "CANCEL": "Cancel", + "CLEAR": "Clear", + "CLEAR_DATA": "Clear data", + "CLEAR_DATA_FAILED": "Failed to clear data for {name}!", + "CLEAR_DATA_SUCCESSFUL": "Cleared data for {name}.", + "CODENAME": "Codename", + "CONFIRMATION_LINK_IS_A_TYPE": "This link is a {urlType}, would you like to install it?", + "COPY_URL": "Copy URL", + "DELETE": "Delete", + "DEVELOPER": "Developer", + "DEVELOPER_SETTINGS": "Developer Settings", + "DISABLE_THEME": "Disable Theme", + "DISABLE_UPDATES": "Disable updates", + "DISCORD_SERVER": "Discord Server", + "ENABLE_UPDATES": "Enable updates", + "GENERAL": "General", + "GITHUB": "GitHub", + "HOLD_UP": "Hold Up", + "INFO": "Info", + "INSTALL": "Install", + "INSTALL_PLUGIN": "Install Plugin", + "INSTALL_THEME": "Install Theme", + "INSTALL_TITLE": "Install {title}", + "LINKS": "Links", + "LOADER": "Loader", + "MACHINE_ID": "Machine ID", + "MANUFACTURER": "Manufacturer", + "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 Vendetta staff. Are you sure you want to continue?", + "MODAL_UNPROXIED_PLUGIN_HEADER": "Unproxied Plugin", + "OPEN_IN_BROWSER": "Open in Browser", + "OPERATING_SYSTEM": "Operating System", + "OVERFLOW_PLUGIN_SETTINGS": "Plugin settings", + "PHONE_MODEL": "Model", + "PLATFORM": "Platform", + "PLUGINS": "Plugins", + "REFETCH": "Refetch", + "RELOAD": "Reload", + "RELOAD_DISCORD": "Reload Discord", + "RELOAD_IN_NORMAL_MODE": "Reload in Normal Mode", + "RELOAD_IN_NORMAL_MODE_DESC": "This will reload Discord normally", + "RELOAD_IN_SAFE_MODE": "Reload in Safe Mode", + "RELOAD_IN_SAFE_MODE_DESC": "This will reload Discord without loading addons", + "RETRY": "Retry", + "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.", + "SEARCH": "Search", + "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", + "UH_OH": "Uh oh.", + "UNINSTALL": "Uninstall", + "UNINSTALL_TITLE": "Uninstall {title}", + "VERSIONS": "Versions" +} \ No newline at end of file diff --git a/src/lib/i18n/index.ts b/src/lib/i18n/index.ts new file mode 100644 index 0000000..4bcf3a9 --- /dev/null +++ b/src/lib/i18n/index.ts @@ -0,0 +1,33 @@ +import langDefault from "./default.json"; + +type I18nKey = keyof typeof langDefault; + +export const Strings = new Proxy({}, { + get: (_t, prop: keyof typeof langDefault) => { + return langDefault[prop]; + } +}) as Record; + +export function formatString(key: I18nKey, val: Record) { + const str = Strings[key]; + + return str.replaceAll(/{(.*)}/g, (_, cap) => { + return val[cap] ?? cap; + }); +} + +export function formatStringSplit(key: I18nKey, val: Record) { + const str = Strings[key]; + + const splitted = str.split(/({[^}]+})/); + + for (const inp in val) { + for (let i = 0; i < splitted.length; i++) { + if (splitted[i] === `{${inp}}`) { + splitted[i] = val[inp]; + } + } + } + + return splitted; +} \ No newline at end of file diff --git a/src/ui/components/ErrorBoundary.tsx b/src/ui/components/ErrorBoundary.tsx index 4929501..dadb569 100644 --- a/src/ui/components/ErrorBoundary.tsx +++ b/src/ui/components/ErrorBoundary.tsx @@ -1,3 +1,4 @@ +import { Strings } from "@/lib/i18n"; import { React, ReactNative as RN, stylesheet } from "@metro/common"; import { Forms, Button, Codeblock } from "@ui/components"; @@ -36,14 +37,14 @@ export default class ErrorBoundary extends React.Component - Uh oh. + {Strings.UH_OH} {this.state.errText}