Skip to content

Commit

Permalink
Added a try-catch to prevent crashes when a language has no translators
Browse files Browse the repository at this point in the history
  • Loading branch information
marticliment committed Dec 28, 2022
1 parent cfa13a4 commit c59731d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions wingetui/uiSections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2009,17 +2009,21 @@ def __init__(self, parent = None):
translators = "<ul>"
translatorList: dict[str, str] = {}
for key in list(languageCredits.keys()):
for singleuser in languageCredits[key].split(","):
if singleuser != "":
user = singleuser.strip()
userPrefixed = (user[0] == "@")
if (userPrefixed):
user = user[1:]
translatorUser = user
if (userPrefixed or user in GHcontributorsList):
translatorUser = f"<a style=\"color:{blueColor}\" href=\"https://github.com/{user}\">{user}</a>"
translatorKey = f"{user}{languageReference[key]}" # for sort
translatorList[translatorKey] = f"{translatorUser} ({languageReference[key]})"
try:
for singleuser in languageCredits[key].split(","):
if singleuser != "":
user = singleuser.strip()
userPrefixed = (user[0] == "@")
if (userPrefixed):
user = user[1:]
translatorUser = user
if (userPrefixed or user in GHcontributorsList):
translatorUser = f"<a style=\"color:{blueColor}\" href=\"https://github.com/{user}\">{user}</a>"
cprint(user, key, languageReference[key])
translatorKey = f"{user}{languageReference[key]}" # for sort
translatorList[translatorKey] = f"{translatorUser} ({languageReference[key]})"
except KeyError:
pass
for userLine in dict(sorted(translatorList.items())).values():
translators += f"<li>{userLine}</li>"
translators += "</ul><br>"
Expand Down

2 comments on commit c59731d

@panther7
Copy link
Contributor

@panther7 panther7 commented on c59731d Dec 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not solution... you must add missing language to languageReference ...

@panther7
Copy link
Contributor

@panther7 panther7 commented on c59731d Dec 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.