Skip to content

Commit

Permalink
moved logs folder
Browse files Browse the repository at this point in the history
added translation system
fixed typos
  • Loading branch information
giordanidev committed May 21, 2023
1 parent 86ab1b2 commit 53f6e38
Show file tree
Hide file tree
Showing 8 changed files with 558 additions and 71 deletions.
69 changes: 55 additions & 14 deletions app_functions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,61 @@
from configparser import ConfigParser
from tkinter import messagebox, filedialog
import os, os.path, hashlib, winreg, sys, json, logging, threading
import os, os.path, hashlib, winreg, sys, json, logging, threading, ctypes, locale

logging.basicConfig(filename='.\\config\\logs\\logs.log', format='%(asctime)s [%(threadName)s] -> [%(levelname)s] -> :: %(message)s', encoding='utf-8', level=logging.DEBUG, filemode='w')
logging.basicConfig(filename='.\\logs\\logs.log', format='%(asctime)s [%(threadName)s] -> [%(levelname)s] -> :: %(message)s', encoding='utf-8', level=logging.DEBUG, filemode='w')
logging.getLogger().addHandler(logging.StreamHandler())

logging.debug(f"{sys._getframe().f_code.co_name}() -> App initialized.")
logging.debug(f"{sys._getframe().f_code.co_name}() -> app_functions.py imported.")

# Gets system language to load the correct "lang" file for app translation
def get_language():
try:
windll = ctypes.windll.kernel32
windll.GetUserDefaultUILanguage()
app_lang = locale.windows_locale[windll.GetUserDefaultUILanguage()]
lang_path = f".\\config\\lang\\{app_lang}.json"
with open(".\\config\\lang\\en_US.json", encoding='utf-8') as f:
en_translated_text = json.load(f)
f.close
if os.path.isfile(lang_path):
with open(lang_path, encoding='utf-8') as f:
translated_text = json.load(f)
f.close
logging.debug(f"{sys._getframe().f_code.co_name}() -> ({app_lang}) translation loaded.")
else:
translated_text = en_translated_text
logging.debug(f"{sys._getframe().f_code.co_name}() -> ({app_lang}) translation not found. Loaded default (en_US).")
return translated_text, en_translated_text
except Exception as e:
get_exception(e)
return
load_translated_text = get_language()
translated_text = load_translated_text[0]
en_translated_text = load_translated_text[1]

def get_english_name(value):
try:
for key in translated_text:
if translated_text[key] == value:
english_name = en_translated_text[key]
return english_name
return False
except Exception as e:
get_exception(e)
return

def get_lang_name(value):
try:
for key in en_translated_text:
if en_translated_text[key] == value:
lang_name = translated_text[key]
return lang_name
return False
except Exception as e:
get_exception(e)
return

def app_config_read():
try:
app_config = ConfigParser()
Expand All @@ -19,7 +67,7 @@ def app_config_read():
return (app_config, config_full_path)
except Exception as e:
get_exception(e)
return
return False

load_configs = app_config_read()
app_config = load_configs[0]
Expand Down Expand Up @@ -165,16 +213,15 @@ def check_files_thread(file_type, type_count):
else:
delete_buttons_list[type_count].configure(state="normal", font=font_regular_bold)
install_backup_buttons_list[type_count].configure(text="Restore", state="normal", font=font_regular_bold)
file_type_label_list[type_count].configure(text=f"'{file_type.capitalize()}' backups found", text_color=text_color_success)
file_type_label_list[type_count].configure(text=f"'{file_type.capitalize()}' backups found.", text_color=text_color_success)
return False

# Sends the file type and check for regular or backup files
# check_files() has to know which files it is going to look for
# TODO if backups already exist, return False
check_files_return = check_files(file_type, check_all_backup)
print(f"check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} check_files_return :: {check_files_return} ")
if check_files_return == True:
file_type_label_list[type_count].configure(text=f"'{file_type.capitalize()}' files are ready to update.", text_color=text_color_fail, font=font_regular)
file_type_label_list[type_count].configure(text=f"'{file_type.capitalize()}' files are ready to be backed up.", text_color=text_color_fail, font=font_regular)
if check_all_backup == "check_backup":
install_backup_buttons_list[type_count].configure(text="Create", state="normal", font=font_regular_bold)
else:
Expand All @@ -183,12 +230,6 @@ def check_files_thread(file_type, type_count):
else:
file_type_label_list[type_count].configure(text=f"There are no new '{file_type}' files to update.", text_color=text_color_success, font=font_regular)
install_backup_buttons_list[type_count].configure(text=f"Up to date", state="disabled")
#install_backup_buttons_list[type_count].configure(font=font_regular)
"""
if check_all_backup == "check_backup":
delete_buttons_list[type_count].configure(text=f"Delete", state="disabled")
#delete_buttons_list[type_count].configure(font=font_regular)
"""
check_files_thread_func = threading.Thread(target=check_files_thread, args=(file_type, type_count))
check_files_thread_func.start()
#check_files_thread_func.join() # crashes the app =(
Expand Down Expand Up @@ -227,12 +268,12 @@ def copy_files_button(file_type, copy_backup, return_label, return_button, delet
return_button.configure(text="Create", state="disabled", font=font_regular)
delete_button.configure(text="Delete", state="disabled", font=font_regular_bold)
else:
return_label.configure(text=f"Success! '{file_type.capitalize()}' files have been backed up.", text_color=text_color_success)
return_label.configure(text=f"Success! '{file_type.capitalize()}' backup files generated.", text_color=text_color_success)
return_button.configure(text="Create", state="disabled", font=font_regular)
delete_button.configure(text="Delete", state="normal", font=font_regular_bold)

elif copy_backup == "delete":
return_label.configure(text=f"Success! '{file_type.capitalize()}' backup files have been deleted.", text_color=text_color_success)
return_label.configure(text=f"Success! '{file_type.capitalize()}' backup files deleted.", text_color=text_color_success)
return_button.configure(text="Create", state="disabled", font=font_regular)
delete_button.configure(text="Delete", state="disabled", font=font_regular_bold)
else:
Expand Down
7 changes: 4 additions & 3 deletions config/config.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[app]
theme = System
color = Blue
region =
napath =
eupath =
region = 3
napath = E:\JOGOS\AION_CLASSIC
eupath = E:\JOGOS\aionclassic

48 changes: 48 additions & 0 deletions config/lang/en_US.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"app_title": "Aion Classic 'Mods' by Load",
"app_info_label": "Please choose an option to begin.",

"app_voice": "KR voices",
"app_filter": "Chat Filter",
"app_font": "JP fonts",

"app_voice_label": "KR Voices:",
"app_filter_label": "Chat Filter:",
"app_font_label": "JP Fonts:",

"app_return_label_waiting": "Waiting...",
"app_return_label_verifying": "Verifying '{_file_type_}' files, please wait!",
"app_return_label_uptodate": "There are no new '{_file_type_}' files to update.",

"app_return_label_backup_ready": "'{_file_type_}' files are ready to be backed up.",
"app_return_label_backup_found": "'{_file_type_}' backups found.",

"app_button_check_all": "Verify All",
"app_button_check_all_backups": "Verify Backups",
"app_button_verifying": "Verifying",
"app_button_install": "Install",
"app_button_create": "Create",
"app_button_restore": "Restore",
"app_button_delete": "Delete",
"app_button_uptodate": "Up to date",

"config_theme_label": "Theme:",
"config_color_label": "Color:",
"config_region_label": "Region selection:",
"config_na_label": "NA Game Folder:",
"config_eu_label": "EU Game Folder",

"config_theme_system": "System",
"config_theme_dark": "Dark",
"config_theme_light": "Light",

"config_color_blue": "Blue",
"config_color_darkblue": "Dark-blue",
"config_color_green": "Green",

"config_region_radio_na": "Classic NA",
"config_region_radio_eu": "Classic EU",
"config_region_radio_both": "Both",

"config_select_folder_button": "Select Folder"
}
48 changes: 48 additions & 0 deletions config/lang/pt_BR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"app_title": "Aion Classic 'Mods' por Load",
"app_info_label": "Por favor, escolha uma ação para começar!",

"app_voice": "Vozes KR",
"app_filter": "Filtro de Bate-papo",
"app_font": "Letras JP",

"app_voice_label": "Vozes KR:",
"app_filter_label": "Filtro de Bate-papo:",
"app_font_label": "Letras JP:",

"app_return_label_waiting": "Esperando...",
"app_return_label_verifying": "Verificando arquivos '{_file_type_}', por favor aguarde!",
"app_return_label_uptodate": "Não há novos arquivos de '{_file_type_}' para atualizar.",

"app_return_label_backup_ready": "Arquivos de '{_file_type_}' estão prontos para 'backup'.",
"app_return_label_backup_found": "'Backups' de '{_file_type_}' encontrados.",

"app_button_check_all": "Verificar Todos",
"app_button_check_all_backups": "Verificar Backups",
"app_button_verifying": "Verificando",
"app_button_install": "Instalar",
"app_button_create": "Criar",
"app_button_restore": "Restaurar",
"app_button_delete": "Deletar",
"app_button_uptodate": "Atualizado",

"config_theme_label": "Tema:",
"config_color_label": "Cor:",
"config_region_label": "Seleção de região:",
"config_na_label": "Pasta do Jogo NA:",
"config_eu_label": "Pasta do Jogo EU",

"config_theme_system": "Sistema",
"config_theme_dark": "Escuro",
"config_theme_light": "Claro",

"config_color_blue": "Azul",
"config_color_darkblue": "Azul-escuro",
"config_color_green": "Verde",

"config_region_radio_na": "Clássico NA",
"config_region_radio_eu": "Clássico EU",
"config_region_radio_both": "Ambos",

"config_select_folder_button": "Selecionar Pasta"
}
19 changes: 18 additions & 1 deletion config/lists/font_backup.json
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
{}
[
[
"E:\\JOGOS\\AION_CLASSIC\\l10n\\enu\\textures\\ui\\hit_number.pak",
"E:\\JOGOS\\AION_CLASSIC\\l10n\\enu\\textures\\ui\\hit_number.pak.bkp"
],
[
"E:\\JOGOS\\aionclassic\\l10n\\eng\\textures\\ui\\hit_number.pak",
"E:\\JOGOS\\aionclassic\\l10n\\eng\\textures\\ui\\hit_number.pak.bkp"
],
[
"E:\\JOGOS\\aionclassic\\l10n\\fra\\textures\\ui\\hit_number.pak",
"E:\\JOGOS\\aionclassic\\l10n\\fra\\textures\\ui\\hit_number.pak.bkp"
],
[
"E:\\JOGOS\\aionclassic\\l10n\\deu\\textures\\ui\\hit_number.pak",
"E:\\JOGOS\\aionclassic\\l10n\\deu\\textures\\ui\\hit_number.pak.bkp"
]
]
Empty file removed config/logs/logs.log
Empty file.
Loading

0 comments on commit 53f6e38

Please sign in to comment.