Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
App settings config
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneStamp authored Nov 5, 2024
1 parent 55d7750 commit 8a7ad20
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
Binary file not shown.
13 changes: 13 additions & 0 deletions App/lib/settings/locales/arabic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"welcome": "مرحبًا بكم في BlackMiscellen! أدوات شاملة.",
"menu_option_1": "1. المحول (غير متوفر)",
"menu_option_2": "2. التنزيل (تنزيل الوسائط)",
"menu_option_3": "3. أوسينت (غير متوفر)",
"menu_option_4": "4. مترجم اللغات (غير متوفر)",
"menu_option_5": "5. تصفية الصور / الفيديوهات (غير متوفر)",
"menu_option_6": "6. التوليد (غير متوفر)",
"menu_option_7": "7. الإعدادات",
"menu_option_8": "8. تحديث",
"menu_option_9": "9. خروج",
"You selected Language: ": "اللغة المختارة"
}
36 changes: 36 additions & 0 deletions App/lib/settings/locales/arabic_setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import json
import os
import sys

def load_translations(language):
"""Load existing translations from a JSON file based on the given language."""
translate_file = f'./App/settings/locales/{language}.json'
if os.path.exists(translate_file):
with open(translate_file, 'r', encoding='utf-8') as f:
return json.load(f)
return {}

def translate_text(translations, text):
"""Retrieve the translated text from the loaded translations."""
return translations.get(text, text) # Return original text if not found

class ConsoleOutputInterceptor:
"""Intercepts console output and translates it."""
def __init__(self, translations):
self.original_stdout = sys.stdout
self.translations = translations

def write(self, message):
# Strip whitespace from the message
stripped_message = message.strip()
# Translate the message before writing it to the original stdout
translated_message = translate_text(self.translations, stripped_message)
# Call the original stdout's write method directly
self.original_stdout.write(translated_message + "\n")

def flush(self):
pass # For compatibility with Python's I/O

def enable_translation(translations):
"""Enable the translation of all console output."""
sys.stdout = ConsoleOutputInterceptor(translations)
Binary file not shown.
33 changes: 33 additions & 0 deletions App/lib/settings/theme/color_scheme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# color_scheme.py

# Define ANSI color codes
COLOR_SCHEMES = {
'1': ('\033[31m', 'Red'), # Red
'2': ('\033[33m', 'Yellow'), # Yellow
'3': ('\033[36m', 'Neon Blue'), # Neon Blue (Cyan)
'4': ('\033[32m', 'Green'), # Green
'reset': '\033[0m' # Reset to default color
}

def display_color_options():
"""Display available color schemes for user selection."""
print("\nSelect a Color Scheme:")
for key, value in COLOR_SCHEMES.items():
if key != 'reset' and isinstance(value, tuple): # Skip 'reset' and check for tuples
_, name = value
print(f"{key}. {name}")

def get_color_choice():
"""Prompt the user to choose a color scheme and return the color code."""
display_color_options()
choice = input("Enter the number of your choice (1-4): ")
color_code = COLOR_SCHEMES.get(choice, ('', 'Invalid choice'))[0]
if color_code:
print(f"\nYou selected Color Scheme: {COLOR_SCHEMES[choice][1]}")
else:
print("Invalid choice, using default color.")
return color_code or COLOR_SCHEMES['reset']

def apply_color(text, color_code):
"""Apply the chosen color code to the provided text."""
return f"{color_code}{text}{COLOR_SCHEMES['reset']}"

0 comments on commit 8a7ad20

Please sign in to comment.