summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorBouke Haarsma <bouke@webatoom.nl>2013-11-02 10:28:22 +0100
committerBouke Haarsma <bouke@webatoom.nl>2013-11-02 10:29:07 +0100
commitc3936c0d79d79aced25ceba8beff0c91a6b5c2ed (patch)
tree56d78bc607633365059a9e7b3a99ed7ce5f200f6 /django
parent090315f5dfb9b0a6539daaec6cb88ad93e6e77af (diff)
Fixed #9523 -- Restart runserver after translation MO files change
Thanks to Krzysztof Kulewski for the initial patch.
Diffstat (limited to 'django')
-rw-r--r--django/utils/autoreload.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 75d794e80d..66ffd0db4d 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -28,13 +28,13 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-import datetime
import os
import signal
import sys
import time
import traceback
+from django.conf import settings
from django.core.signals import request_finished
try:
from django.utils.six.moves import _thread as thread
@@ -86,13 +86,28 @@ _win = (sys.platform == "win32")
_error_files = []
-
def gen_filenames():
"""
- Yields a generator over filenames referenced in sys.modules.
+ Yields a generator over filenames referenced in sys.modules and translation
+ files.
"""
filenames = [filename.__file__ for filename in sys.modules.values()
if hasattr(filename, '__file__')]
+
+ # Add the names of the .mo files that can be generated
+ # by compilemessages management command to the list of files watched.
+ basedirs = [os.path.join(os.path.dirname(os.path.dirname(__file__)),
+ 'conf', 'locale'),
+ 'locale']
+ basedirs.extend(settings.LOCALE_PATHS)
+ basedirs = [os.path.abspath(basedir) for basedir in basedirs
+ if os.path.isdir(basedir)]
+ for basedir in basedirs:
+ for dirpath, dirnames, locale_filenames in os.walk(basedir):
+ for filename in locale_filenames:
+ if filename.endswith('.mo'):
+ filenames.append(os.path.join(dirpath, filename))
+
for filename in filenames + _error_files:
if not filename:
continue