Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Gracefully handle exceptions during direct i18n loading #628

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions MCprep_addon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,21 @@ def __init__(self):
# i18n using Python's gettext module
#
# This only runs if translations.py does not exist
if not self.translations.exists():
self.languages: dict[str, gettext.NullTranslations] = {}
for language in self.languages_folder.iterdir():
self.languages[language.name] = gettext.translation("mcprep",
self.languages_folder,
fallback=True,
languages=[language.name])
try:
if not self.translations.exists():
self.languages: dict[str, gettext.NullTranslations] = {}
for language in self.languages_folder.iterdir():
self.languages[language.name] = gettext.translation("mcprep",
self.languages_folder,
fallback=True,
languages=[language.name])
self.use_direct_i18n = True
self.log("Loaded direct i18n!")

except Exception:
self.languages = {}
self.log("Exception occured while loading translations!")


# This allows us to translate strings on the fly
def _(self, msg: str) -> str:
Expand Down