-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d33b6fb
commit f0d8264
Showing
10 changed files
with
697 additions
and
694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
from flask import session | ||
from flask_babel import gettext, force_locale | ||
|
||
|
||
def gettext_with_fallback(x): | ||
locale = session['lang'] | ||
res = gettext(x) | ||
if locale != 'en' and res == x: | ||
with force_locale('en'): | ||
res = gettext(x) | ||
return res | ||
from flask_babel import gettext | ||
from website.flask_helpers import gettext_with_fallback | ||
|
||
|
||
# Explicitly substitute the flask_babel function gettext with our own implementation that | ||
# adds a fallback language. Note that we need to monkey-patch instead of use the gettext_with_fallback | ||
# directly because the extract function requires us to use gettext with literal strings. | ||
gettext = gettext_with_fallback | ||
# directly because the Babel extract function works if we use gettext with literal strings. | ||
gettext = gettext_with_fallback # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.