You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add full translation support for UI and log messages
Refactored the application to use translation keys for all UI labels, combo box items, tooltips, and log messages. Updated MainWindow and BrowserThread to use the selected language's translations throughout the UI and logging. Extended translation files (en, fil, ja, ko, zh) with new keys for combo box items, system info, log messages, and about/license sections. Improved language/theme combo box handling and ensured settings load/apply with proper translation context.
self.log_message.emit(f"Attempting to reinitialize WebDriver for instance {self.instance_id}", "WARNING")
58
+
self.log_message.emit(self.translations.get("log_reinitialize_attempt", "Attempting to reinitialize WebDriver for instance {instance_id}").format(instance_id=self.instance_id), "WARNING")
self.log_message.emit(f"Starting browser thread for instance {self.instance_id} on port {self.port}", "INFO")
146
+
self.log_message.emit(self.translations.get("log_browser_thread_start", "Starting browser thread for instance {instance_id} on port {port}").format(instance_id=self.instance_id, port=self.port), "INFO")
146
147
147
148
# Create service in background thread to avoid blocking UI
148
149
ifself.browser_type=='chrome':
@@ -155,7 +156,7 @@ def run(self):
155
156
ifself.is_port_in_use(self.port):
156
157
self.port=self.find_available_port()
157
158
self.service.port=self.port
158
-
self.log_message.emit(f"Port {self.port} was in use, switching to new port {self.port}", "WARNING")
159
+
self.log_message.emit(self.translations.get("log_port_in_use", "Port {old_port} was in use, switching to new port {new_port}").format(old_port=self.port, new_port=self.port), "WARNING")
159
160
160
161
self.service.start()
161
162
@@ -178,20 +179,20 @@ def run(self):
178
179
error_msg=str(e).lower()
179
180
# Provide more specific error messages for common issues
180
181
if"chrome instance exited"inerror_msg:
181
-
self.log_message.emit(f"Chrome browser instance exited immediately. This usually indicates:", "ERROR")
182
-
self.log_message.emit(f" - Chrome binary not found at: {getattr(self.browser_options, 'binary_location', 'Not set')}", "ERROR")
183
-
self.log_message.emit(f" - Chrome version incompatible with ChromeDriver", "ERROR")
184
-
self.log_message.emit(f" - Conflicting Chrome command line arguments", "ERROR")
185
-
self.log_message.emit(f" - Chrome already running with conflicting profile", "ERROR")
182
+
self.log_message.emit(self.translations.get("log_browser_exited_immediately", "Chrome browser instance exited immediately. This usually indicates:"), "ERROR")
183
+
self.log_message.emit(self.translations.get("log_chrome_binary_not_found_error", " - Chrome binary not found at: {binary}").format(binary=getattr(self.browser_options, 'binary_location', 'Not set')), "ERROR")
184
+
self.log_message.emit(self.translations.get("log_chrome_version_incompatible", " - Chrome version incompatible with ChromeDriver"), "ERROR")
185
+
self.log_message.emit(self.translations.get("log_conflicting_arguments", " - Conflicting Chrome command line arguments"), "ERROR")
186
+
self.log_message.emit(self.translations.get("log_conflicting_profile", " - Chrome already running with conflicting profile"), "ERROR")
186
187
elif"session not created"inerror_msg:
187
-
self.log_message.emit(f"WebDriver session creation failed. Check browser version compatibility.", "ERROR")
188
+
self.log_message.emit(self.translations.get("log_session_creation_failed", "WebDriver session creation failed. Check browser version compatibility."), "ERROR")
188
189
elif"executable needs to be in path"inerror_msg:
189
-
self.log_message.emit(f"Browser executable not found in PATH or specified location.", "ERROR")
190
+
self.log_message.emit(self.translations.get("log_executable_not_found", "Browser executable not found in PATH or specified location."), "ERROR")
self.log_message.emit(f"Could not track browser process for instance {self.instance_id}: {str(e)}", "WARNING")
227
+
self.log_message.emit(self.translations.get("log_cannot_track_process", "Could not track browser process for instance {instance_id}: {error}").format(instance_id=self.instance_id, error=str(e)), "WARNING")
self.log_message.emit(f"Opened initial tab with URL: {self.url} for instance {self.instance_id}", "INFO")
233
+
self.log_message.emit(self.translations.get("log_opened_initial_tab", "Opened initial tab with URL: {url} for instance {instance_id}").format(url=self.url, instance_id=self.instance_id), "INFO")
233
234
234
235
iteration=0
235
236
consecutive_errors=0# Track consecutive errors for performance optimization
@@ -240,7 +241,7 @@ def run(self):
240
241
241
242
ifnotself.is_driver_valid():
242
243
self.error_occurred.emit(f"WebDriver is invalid or None for instance {self.instance_id}, cannot proceed with tab operations")
243
-
self.log_message.emit(f"WebDriver is invalid or None for instance {self.instance_id}, cannot proceed with tab operations", "ERROR")
244
+
self.log_message.emit(self.translations.get("log_webdriver_invalid", "WebDriver is invalid or None for instance {instance_id}, cannot proceed with tab operations").format(instance_id=self.instance_id), "ERROR")
244
245
break
245
246
246
247
try:
@@ -256,7 +257,7 @@ def run(self):
256
257
ifnotself.is_driver_valid():
257
258
ifnotself.stop_requested:
258
259
self.error_occurred.emit(f"WebDriver became invalid before script execution for instance {self.instance_id}")
259
-
self.log_message.emit(f"WebDriver became invalid before script execution for instance {self.instance_id}", "ERROR")
260
+
self.log_message.emit(self.translations.get("log_webdriver_invalid_before_script", "WebDriver became invalid before script execution for instance {instance_id}").format(instance_id=self.instance_id), "ERROR")
260
261
# Try to reinitialize driver
261
262
ifself._try_reinitialize_driver():
262
263
continue# Skip this iteration and try again
@@ -269,7 +270,7 @@ def run(self):
269
270
ifnotself.is_driver_valid():
270
271
ifnotself.stop_requested:
271
272
self.error_occurred.emit(f"WebDriver became invalid after script execution for instance {self.instance_id}")
272
-
self.log_message.emit(f"WebDriver became invalid after script execution for instance {self.instance_id}", "ERROR")
273
+
self.log_message.emit(self.translations.get("log_webdriver_invalid_after_script", "WebDriver became invalid after script execution for instance {instance_id}").format(instance_id=self.instance_id), "ERROR")
273
274
# Try to reinitialize driver
274
275
ifself._try_reinitialize_driver():
275
276
continue# Skip this iteration and try again
@@ -278,7 +279,7 @@ def run(self):
278
279
279
280
handles=self.driver.window_handles
280
281
ifnothandles:
281
-
self.log_message.emit(f"No window handles found for instance {self.instance_id}, skipping tab operation", "WARNING")
282
+
self.log_message.emit(self.translations.get("log_no_window_handles", "No window handles found for instance {instance_id}, skipping tab operation").format(instance_id=self.instance_id), "WARNING")
282
283
continue
283
284
284
285
new_tab_handle=handles[-1]
@@ -295,7 +296,7 @@ def run(self):
295
296
suppress_keywords= ['browsing context has been discarded', 'session does not exist', 'invalid session', 'marionette', 'no such window']
self.log_message.emit(f"Timeout waiting for page to load in instance {self.instance_id}: {str(e)}", "WARNING")
299
+
self.log_message.emit(self.translations.get("log_timeout_waiting_page_load", "Timeout waiting for page to load in instance {instance_id}: {error}").format(instance_id=self.instance_id, error=str(e)), "WARNING")
299
300
300
301
ifnew_tab_handle!=first_tab_handle:
301
302
# Double-check driver is still valid before closing tab
"log_failed_init_webdriver": "Failed to initialize WebDriver for instance {instance_id}: {error}",
279
+
"log_cannot_track_process": "Could not track browser process for instance {instance_id}: {error}",
280
+
"log_opened_initial_tab": "Opened initial tab with URL: {url} for instance {instance_id}",
281
+
"log_webdriver_invalid": "WebDriver is invalid or None for instance {instance_id}, cannot proceed with tab operations",
282
+
"log_webdriver_invalid_before_script": "WebDriver became invalid before script execution for instance {instance_id}",
283
+
"log_webdriver_invalid_after_script": "WebDriver became invalid after script execution for instance {instance_id}",
284
+
"log_no_window_handles": "No window handles found for instance {instance_id}, skipping tab operation",
285
+
"log_timeout_waiting_page_load": "Timeout waiting for page to load in instance {instance_id}: {error}",
286
+
"system_info_cpu_usage": "CPU Usage:",
287
+
"system_info_memory_usage": "Memory Usage:",
288
+
"about_support": "Support:",
289
+
"about_issues_page": "Issues Page",
290
+
"about_license_text": "This software is licensed under the {license}. See {license} for details.",
291
+
"about_description": "Advanced Tab Manager is a Python-based desktop application built with PyQt6 and Selenium. It provides a user-friendly interface to automate browser tab management, allowing users to open and close Chrome tabs programmatically with extensive customization options. This tool is ideal for testing, simulation, or repetitive browser automation tasks.",
292
+
"update_check_no_internet": "No internet connection. Update check failed.",
293
+
"update_check_failed": "Failed to check for updates: {error}",
0 commit comments