|
| 1 | +const fs = require('fs'); |
| 2 | +const os = require('os'); |
| 3 | + |
| 4 | +let lang = 'en'; |
| 5 | +let enableGamescope = false; |
| 6 | +let enableMangohud = false; |
| 7 | +let enableVkbasalt = false; |
| 8 | + |
| 9 | +const translations = { |
| 10 | + 'en': { |
| 11 | + 'title': 'Hacker Mode', |
| 12 | + 'settings': 'Settings', |
| 13 | + 'hacker_menu': 'Hacker Menu', |
| 14 | + 'steam': 'Steam', |
| 15 | + 'heroic': 'Heroic', |
| 16 | + 'hyperplay': 'HyperPlay', |
| 17 | + 'lutris': 'Lutris', |
| 18 | + 'audio': 'Audio', |
| 19 | + 'increase_volume': 'Increase Volume', |
| 20 | + 'decrease_volume': 'Decrease Volume', |
| 21 | + 'toggle_mute': 'Toggle Mute', |
| 22 | + 'display': 'Display', |
| 23 | + 'increase_brightness': 'Increase Brightness', |
| 24 | + 'decrease_brightness': 'Decrease Brightness', |
| 25 | + 'toggle_theme': 'Toggle Dark/Light Mode', |
| 26 | + 'network': 'Network', |
| 27 | + 'wifi_settings': 'Wi-Fi Settings', |
| 28 | + 'toggle_wifi': 'Toggle Wi-Fi', |
| 29 | + 'bluetooth': 'Bluetooth', |
| 30 | + 'power': 'Power', |
| 31 | + 'power_saving': 'Power Saving', |
| 32 | + 'balanced': 'Balanced', |
| 33 | + 'performance': 'Performance', |
| 34 | + 'general': 'General', |
| 35 | + 'gaming_tools': 'Gaming Tools', |
| 36 | + 'enable_gamescope': 'Enable Gamescope', |
| 37 | + 'enable_mangohud': 'Enable MangoHUD', |
| 38 | + 'enable_vkbasalt': 'Enable vkBasalt', |
| 39 | + 'app_not_installed': 'To install missing applications, use the package manager.', |
| 40 | + 'launch_cooldown': 'Please wait {seconds} seconds before launching {app} again.', |
| 41 | + 'no_internet': 'No internet connection. Please enable Wi-Fi.', |
| 42 | + 'wifi_list': 'Available Wi-Fi Networks', |
| 43 | + 'connect': 'Connect', |
| 44 | + 'bluetooth_devices': 'Bluetooth Devices', |
| 45 | + 'scan': 'Scan', |
| 46 | + 'pair': 'Pair', |
| 47 | + 'no_networks': 'No networks found', |
| 48 | + 'connection_failed': 'Connection failed: {error}', |
| 49 | + 'connecting': 'Connecting to {ssid}...', |
| 50 | + 'wifi_toggle_success': 'Wi-Fi turned {state}', |
| 51 | + 'wifi_toggle_failed': 'Failed to toggle Wi-Fi: {error}', |
| 52 | + 'no_selection': 'Please select an item', |
| 53 | + 'pairing': 'Pairing {device}...', |
| 54 | + 'pairing_failed': 'Pairing failed: {error}', |
| 55 | + 'switch_plasma': 'Switch to Plasma', |
| 56 | + 'switch_to_plasma': 'Switch to Plasma', |
| 57 | + 'shutdown': 'Shutdown', |
| 58 | + 'restart': 'Restart', |
| 59 | + 'sleep': 'Sleep', |
| 60 | + 'restart_apps': 'Restart Apps', |
| 61 | + 'restart_sway': 'Restart Sway', |
| 62 | + 'close': 'Close', |
| 63 | + 'back': 'Back' |
| 64 | + }, |
| 65 | + 'pl': { |
| 66 | + 'title': 'Tryb Hakera', |
| 67 | + 'settings': 'Ustawienia', |
| 68 | + 'hacker_menu': 'Menu Hakera', |
| 69 | + 'steam': 'Steam', |
| 70 | + 'heroic': 'Heroic', |
| 71 | + 'hyperplay': 'HyperPlay', |
| 72 | + 'lutris': 'Lutris', |
| 73 | + 'audio': 'Dźwięk', |
| 74 | + 'increase_volume': 'Zwiększ głośność', |
| 75 | + 'decrease_volume': 'Zmniejsz głośność', |
| 76 | + 'toggle_mute': 'Wycisz/Włącz dźwięk', |
| 77 | + 'display': 'Wyświetlacz', |
| 78 | + 'increase_brightness': 'Zwiększ jasność', |
| 79 | + 'decrease_brightness': 'Zmniejsz jasność', |
| 80 | + 'toggle_theme': 'Przełącz tryb ciemny/jasny', |
| 81 | + 'network': 'Sieć', |
| 82 | + 'wifi_settings': 'Ustawienia Wi-Fi', |
| 83 | + 'toggle_wifi': 'Włącz/Wyłącz Wi-Fi', |
| 84 | + 'bluetooth': 'Bluetooth', |
| 85 | + 'power': 'Zasilanie', |
| 86 | + 'power_saving': 'Oszczędzanie energii', |
| 87 | + 'balanced': 'Zrównoważony', |
| 88 | + 'performance': 'Wydajność', |
| 89 | + 'general': 'Ogólne', |
| 90 | + 'gaming_tools': 'Narzędzia do gier', |
| 91 | + 'enable_gamescope': 'Włącz Gamescope', |
| 92 | + 'enable_mangohud': 'Włącz MangoHUD', |
| 93 | + 'enable_vkbasalt': 'Włącz vkBasalt', |
| 94 | + 'app_not_installed': 'Aby zainstalować brakujące aplikacje, użyj menedżera pakietów.', |
| 95 | + 'launch_cooldown': 'Proszę czekać {seconds} sekund przed ponownym uruchomieniem {app}.', |
| 96 | + 'no_internet': 'Brak połączenia z internetem. Proszę włączyć Wi-Fi.', |
| 97 | + 'wifi_list': 'Dostępne sieci Wi-Fi', |
| 98 | + 'connect': 'Połącz', |
| 99 | + 'bluetooth_devices': 'Urządzenia Bluetooth', |
| 100 | + 'scan': 'Skanuj', |
| 101 | + 'pair': 'Paruj', |
| 102 | + 'no_networks': 'Nie znaleziono sieci', |
| 103 | + 'connection_failed': 'Połączenie nieudane: {error}', |
| 104 | + 'connecting': 'Łączenie z {ssid}...', |
| 105 | + 'wifi_toggle_success': 'Wi-Fi przełączone na {state}', |
| 106 | + 'wifi_toggle_failed': 'Nie udało się przełączyć Wi-Fi: {error}', |
| 107 | + 'no_selection': 'Proszę wybrać element', |
| 108 | + 'pairing': 'Parowanie {device}...', |
| 109 | + 'pairing_failed': 'Parowanie nieudane: {error}', |
| 110 | + 'switch_plasma': 'Przełącz na Plasma', |
| 111 | + 'switch_to_plasma': 'Przełącz na Plasma', |
| 112 | + 'shutdown': 'Wyłącz', |
| 113 | + 'restart': 'Uruchom ponownie', |
| 114 | + 'sleep': 'Uśpij', |
| 115 | + 'restart_apps': 'Restartuj aplikacje', |
| 116 | + 'restart_sway': 'Restartuj sesję Sway', |
| 117 | + 'close': 'Zamknij', |
| 118 | + 'back': 'Wróć' |
| 119 | + } |
| 120 | +}; |
| 121 | + |
| 122 | +function setupLanguage() { |
| 123 | + try { |
| 124 | + const locale = os.locale || process.env.LANG || 'en_US'; |
| 125 | + lang = locale.split('_')[0]; |
| 126 | + if (!translations[lang]) lang = 'en'; |
| 127 | + log(`Language set to: ${lang}`); |
| 128 | + } catch (e) { |
| 129 | + log(`Error setting language: ${e}`, 'error'); |
| 130 | + lang = 'en'; |
| 131 | + } |
| 132 | + return lang; |
| 133 | +} |
| 134 | + |
| 135 | +function setLanguage(newLang) { |
| 136 | + if (translations[newLang]) { |
| 137 | + lang = newLang; |
| 138 | + log(`Language changed to: ${newLang}`, 'info'); |
| 139 | + } |
| 140 | +} |
| 141 | + |
| 142 | +function getText(key, params = {}) { |
| 143 | + let text = translations[lang][key] || key; |
| 144 | + for (const [k, v] of Object.entries(params)) { |
| 145 | + text = text.replace(`{${k}}`, v); |
| 146 | + } |
| 147 | + return text; |
| 148 | +} |
| 149 | + |
| 150 | +function setGamingTool(tool, enabled) { |
| 151 | + if (tool === 'gamescope') enableGamescope = enabled; |
| 152 | + if (tool === 'mangohud') enableMangohud = enabled; |
| 153 | + if (tool === 'vkbasalt') enableVkbasalt = enabled; |
| 154 | +} |
| 155 | + |
| 156 | +function getGamingTool(tool) { |
| 157 | + if (tool === 'gamescope') return enableGamescope; |
| 158 | + if (tool === 'mangohud') return enableMangohud; |
| 159 | + if (tool === 'vkbasalt') return enableVkbasalt; |
| 160 | + return false; |
| 161 | +} |
| 162 | + |
| 163 | +function log(message, level = 'info') { |
| 164 | + const logMessage = `${new Date().toISOString()} - ${level.toUpperCase()} - ${message}\n`; |
| 165 | + fs.appendFileSync('/tmp/hacker-mode.log', logMessage); |
| 166 | +} |
| 167 | + |
| 168 | +module.exports = { setupLanguage, setLanguage, getText, setGamingTool, getGamingTool }; |
0 commit comments