Skip to content

Commit

Permalink
Update utils.py - wrong translations-path when run through wsgi (#80)
Browse files Browse the repository at this point in the history
when run through wsgi, pathlib.Path().absolute() points to the apache-folder, not to the folder where utils.py is located.

I don't know if this still works when run in docker, but i assume it does.
  • Loading branch information
tobias-brunner authored Jan 23, 2024
1 parent 138acbc commit a19f50f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
translations = {}
try:
locale = DEFAULT_LOCALE
path = pathlib.Path().absolute() / 'translations/{}.json'.format(locale)
# Get the directory of utils.py
script_directory = pathlib.Path(__file__).resolve().parent
# Adjust the path based on the script directory
path = script_directory / 'translations/{}.json'.format(locale)
with open(path, 'r') as f:
translations[locale] = json.load(f)
except Exception as e:
Expand All @@ -32,4 +35,4 @@ def i18n(value, args = [],locale = DEFAULT_LOCALE) :
# return input value if not found
lookup = value
break
return lookup.format(*args)
return lookup.format(*args)

0 comments on commit a19f50f

Please sign in to comment.