Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
display lang name on load
Browse files Browse the repository at this point in the history
  • Loading branch information
RealistikDash committed Oct 8, 2020
1 parent 73d1550 commit 5622825
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions helpers/lang.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import json
import os
from helpers.generalhelper import JsonFile
from config import user_config
from constants import Paths
from exceptions import LangNotFound
import logging

class Lang():
def __init__(self, language : str = "en"):
def __init__(self):
"""Idk how else to make it wait for config."""
pass
def load_langs(self, language : str = "en"):
"""Loads the given language."""
self.text_find_msg = "Failed to find translated text for {}|{}"
self.main_lang = language
Expand All @@ -18,6 +21,8 @@ def __init__(self, language : str = "en"):
if self.lang is None:
raise LangNotFound

logging.info(self.info("LOADED_LANG", self.lang.get("formal_name", f"{language}.json")))

def _format_string(self, text : str, format_args : tuple) -> str:
"""Formats a string according to the format args provided."""
return text.format(*format_args)
Expand Down
3 changes: 2 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"formal_name" : "German - Deutsch",
"errors": {
"START_LVLPATH": "Level / Save Pfad existiert nicht! Bitte erstellen Sie es, bevor Sie GDPyS starten."
},
"info": {
"SET_LVLPATH": "Festlegen des Ebenenpfads: {0} \ nSetzen Sie den Sicherungspfad: {1}"
"SET_LVLPATH": "Festlegen des Ebenenpfads: {0} \nSetzen Sie den Sicherungspfad: {1}"
},
"warning": {
"no_daily": "Kein tägliches Level eingestellt! Bitte setzen Sie eine."
Expand Down
4 changes: 3 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"formal_name" : "British English - English",
"errors": {
"START_LVLPATH": "Level/Save path does not exist! Please create it before starting GDPyS.",
"CRON_FAIL" : "Job {0} failed with error {1}. Enable GDPyS debug mode for the full traceback.",
Expand All @@ -7,7 +8,8 @@
"info": {
"SET_LVLPATH": "Set level path: {0}\nSet save path: {1}",
"CRON_FINISH" : "Finished cron job {0} in {1}",
"CRON_ALL_FINISH" : "Finished all cron jobs in {0}"
"CRON_ALL_FINISH" : "Finished all cron jobs in {0}",
"LOADED_LANG" : "Loaded {0}."
},
"warning": {
"no_daily": "No daily level set! Please set one.",
Expand Down
1 change: 1 addition & 0 deletions lang/ru.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"formal_name" : "Russian - Русский",
"errors": {
"START_LVLPATH": "Пути к сохранению или уровням не найдено! Пожалуйста, создайте его перед запуском GDPyS."
},
Expand Down
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ async def init(loop):
return app

if __name__ == "__main__":
start_plugins()
load_config()
# Configures the logger.
logging_level = logging.DEBUG if user_config["debug"] else logging.INFO
logging.basicConfig(level = logging_level)
lang.load_langs(user_config["lang"])
start_plugins()
welcome_sequence()
pre_run_checks()
# Inits the app.
Expand Down

0 comments on commit 5622825

Please sign in to comment.