File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
7
7
## [ Unreleased]
8
8
9
+ ### Fixed
10
+
11
+ - Don't fail if compiled translation files (.mo) don't exist, and Django isn't installed
12
+
9
13
## [ 0.15.1] - 2020-10-21
10
14
11
15
### Fixed
Original file line number Diff line number Diff line change 14
14
except ImproperlyConfigured :
15
15
raise ImportError
16
16
17
- # We set up the translations ourselves, instead of using Django's gettext
18
- # function, so that we can have a custom domain and locale directory.
19
- translations = {}
20
- translations ["en" ] = gettext .translation (domain , locale_dir , languages = ["en" ])
21
- translations ["es" ] = gettext .translation (domain , locale_dir , languages = ["es" ])
17
+ try :
18
+ # We set up the translations ourselves, instead of using Django's gettext
19
+ # function, so that we can have a custom domain and locale directory.
20
+ translations = {}
21
+ translations ["en" ] = gettext .translation (domain , locale_dir , languages = ["en" ])
22
+ translations ["es" ] = gettext .translation (domain , locale_dir , languages = ["es" ])
22
23
23
- def _ (text ):
24
- lang = get_language ()
25
- if lang not in translations :
26
- lang = "en"
27
- return translations [lang ].gettext (text )
24
+ def _ (text ):
25
+ lang = get_language ()
26
+ if lang not in translations :
27
+ lang = "en"
28
+ return translations [lang ].gettext (text )
29
+ except FileNotFoundError :
30
+ # If .mo files don't exist, pass a fake gettext function instead
31
+ _ = lambda x : x
28
32
29
33
30
34
except ImportError :
You can’t perform that action at this time.
0 commit comments