Skip to content

Commit

Permalink
Merge pull request #288 from mrf345/staging
Browse files Browse the repository at this point in the history
Fix missing default language, and improve translator
  • Loading branch information
mrf345 authored Mar 17, 2023
2 parents 7223105 + 8f60d2d commit bd4baa0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def inject_vars():
ar=ar,
version=VERSION,
str=str,
defLang=session.get('lang'),
defLang=session.get('lang', 'en'),
getattr=getattr,
settings=get_settings_cached(),
Serial=Serial,
Expand Down
12 changes: 9 additions & 3 deletions app/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ def _handle_exception(self, exception):
raise exception


class FasterTranslator(translator):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.languages = set(self.languages)


# NOTE: Work around for flask imports and registering blueprints
# currently needed for sql alchemy, login manager and flask-uploads

Expand All @@ -113,9 +119,9 @@ def _handle_exception(self, exception):
login_manager = LoginManager()
login_manager.login_view = "login"
files = UploadSet('files', ALL)
gtranslator = translator(cache=True,
skip_app=True,
service_urls=['translate.googleapis.com'])
gtranslator = FasterTranslator(cache=True,
skip_app=True,
service_urls=['translate.googleapis.com'])
gTTs = RedisGtts(route=True, failsafe=True, logging=False)
celery_app = LazyCelery()
redis = Redis('redis', db=3)

0 comments on commit bd4baa0

Please sign in to comment.