Skip to content

Commit

Permalink
fixed typos, changed how window-refresh was handled for lang file
Browse files Browse the repository at this point in the history
  • Loading branch information
chpoit committed Jun 15, 2021
1 parent 7164891 commit 94a6581
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ It's called Utsushi's charm because I thought it would be funny to make a comple

# New Update (Updated June 1st)
- 1.5.2
- Adds updated checking
- Adds update checking
- Allows for independent skills/auto-corrections/localization updates
- Adds initial support for localization (only through command line flags however (`-a` or `--app-language`))
- 1.5.1
Expand Down Expand Up @@ -92,7 +92,7 @@ It's called Utsushi's charm because I thought it would be funny to make a comple
## Supported App Language:
- English

Looking for people who can submit translations. Use (this file)[data/translations/eng.json] and replace the messages appropriately if you are interested in contributing. Create a pull request to show up as a contributor within Github. I can add you in this readme if you only want to create an issue with the translations.
Looking for people who can submit translations. Use [this file](data/translations/eng.json) and replace the messages appropriately if you are interested in contributing. Create a pull request to show up as a contributor within Github. I can add you in this readme if you only want to create an issue with the translations.

I am currently working on a translation to French.

Expand Down
8 changes: 4 additions & 4 deletions data/translations/eng.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"charms-to-fix": "Charms to fix:",
"repair-charms": "Fix Parsing Errors",
"new-version": "A New Version is Available",
"new-app-update": "A new version for Utsushi's Charm is available (You: {} vs New: {}), do you want to download it?",
"new-skill-update": "New skills were released in-game (You: {} vs New: {}), do you want to update your skill list?",
"new-app-language-update": "An updated language file for Utsushi's Charm is available (You: {} vs New: {}), do you want to download it?",
"new-skill-correction-update": "New automatic skill corrections were submitted (You: {} vs New: {}), do you download them?"
"new-app-update": "A new version for Utsushi's Charm is available (You: {}, New: {}), do you want to download it?",
"new-skill-update": "New skills were released in-game (You: {}, New: {}), do you want to update your skill list?",
"new-app-language-update": "An updated language file for Utsushi's Charm is available (You: {}, New: {}), do you want to download it?",
"new-skill-correction-update": "New automatic skill corrections were submitted (You: {}, New: {}), do you download them?"
}
7 changes: 3 additions & 4 deletions src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,15 @@ def main(args):
)

if new_lang_update:
main_window, translator = create_main_window(args, main_window)
translator = Translator(app_language_code)
main_window.refresh(translator)

main_window.mainloop()


def create_main_window(args, old_window=None):
def create_main_window(args):
app_language_code = get_language_code(args.app_language)
translator = Translator(app_language_code)
if old_window is not None:
old_window.destroy()
new_window = MainWindow(translator, args)
new_window.report_callback_exception = handle_exception
sys.stdout = new_window
Expand Down
2 changes: 1 addition & 1 deletion src/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def get_latest_url():


def get_language_url(language="eng"):
url = f"https://raw.githubusercontent.com/chpoit/utsushis-charm/master/data/translation/{language}.json"
url = f"https://raw.githubusercontent.com/chpoit/utsushis-charm/master/data/translations/{language}.json"
return url


Expand Down
7 changes: 7 additions & 0 deletions src/ui/MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class MainWindow(tk.Tk):
def __init__(self, _: Translator, args):
super().__init__()
self.charms = CharmList()
self.args = args

self.title(_("Utsushi's Charm"))
try:
Expand All @@ -44,6 +45,12 @@ def __init__(self, _: Translator, args):
self._regen_paths()
self._build_ui()

def refresh(self, _: Translator = None):
if not _:
_ = self._
self.destroy()
self.__init__(_, self.args)

def _build_ui(self, _: Translator = None):
if not _:
_ = self._
Expand Down
11 changes: 7 additions & 4 deletions src/updater/Updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def update_language(self, lang, new_version: SimpleSemVer):
except PermissionError as e:
logger.exception("Could not write language file")
print(_("lang-permission-denied"))
except Exception as e:
logger.exception("An error occurred")

def update_skill_corrections(self, lang, new_version: SimpleSemVer):
_ = self._
Expand All @@ -52,12 +54,12 @@ def update_skill_corrections(self, lang, new_version: SimpleSemVer):
Path(full_name_new).touch()
request.urlretrieve(url, filename=full_name_new, data=None)
self.version_checker.update_corrections_version(lang, new_version)
self.merge_corrections(full_name, full_name_new)
except PermissionError as e:
logger.exception("Could not write corrections file")
print(_("skill-cor-permission-denied"))
return

self.merge_corrections(full_name, full_name_new)
except Exception as e:
logger.exception("An error occurred")

def update_all_skills(self, new_version: SimpleSemVer):
url = get_english_skill_mapping_url()
Expand All @@ -70,7 +72,8 @@ def update_all_skills(self, new_version: SimpleSemVer):
except PermissionError as e:
logger.exception("Could not write skill file")
print(_("skill-permission-denied"))
return
except Exception as e:
logger.exception("An error occurred")

def merge_corrections(self, full_name, full_name_new):
with open(full_name, "r", encoding="utf-8") as old_f:
Expand Down

0 comments on commit 94a6581

Please sign in to comment.