This repository has been archived by the owner on Nov 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ": "اللغة المختارة" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']}" |