Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7084 -- Fixed the "makemessages" command to handle line endings

correctly on Windows (previous behaviour was to explode when encountering a
multi-line messages). Patch and testing from Ramiro Morales.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8576 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fcf059d539d9065a09979bba81dcb7107e41f085 1 parent 73afcee
Malcolm Tredinnick authored August 26, 2008
12  django/core/management/commands/makemessages.py
@@ -97,10 +97,10 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False, extens
97 97
             if domain == 'djangojs' and file_ext == '.js':
98 98
                 if verbosity > 1:
99 99
                     sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
100  
-                src = open(os.path.join(dirpath, file), "rb").read()
  100
+                src = open(os.path.join(dirpath, file), "rU").read()
101 101
                 src = pythonize_re.sub('\n#', src)
102  
-                open(os.path.join(dirpath, '%s.py' % file), "wb").write(src)
103 102
                 thefile = '%s.py' % file
  103
+                open(os.path.join(dirpath, thefile), "w").write(src)
104 104
                 cmd = 'xgettext -d %s -L Perl --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (domain, os.path.join(dirpath, thefile))
105 105
                 (stdin, stdout, stderr) = os.popen3(cmd, 't')
106 106
                 msgs = stdout.read()
@@ -121,9 +121,9 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False, extens
121 121
             elif domain == 'django' and (file_ext == '.py' or file_ext in extensions):
122 122
                 thefile = file
123 123
                 if file_ext in extensions:
124  
-                    src = open(os.path.join(dirpath, file), "rb").read()
  124
+                    src = open(os.path.join(dirpath, file), "rU").read()
125 125
                     thefile = '%s.py' % file
126  
-                    open(os.path.join(dirpath, thefile), "wb").write(templatize(src))
  126
+                    open(os.path.join(dirpath, thefile), "w").write(templatize(src))
127 127
                 if verbosity > 1:
128 128
                     sys.stdout.write('processing file %s in %s\n' % (file, dirpath))
129 129
                 cmd = 'xgettext -d %s -L Python --keyword=gettext_noop --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --keyword=ugettext_noop --keyword=ugettext_lazy --keyword=ungettext_lazy:1,2 --from-code UTF-8 -o - "%s"' % (
@@ -148,14 +148,14 @@ def make_messages(locale=None, domain='django', verbosity='1', all=False, extens
148 148
                     os.unlink(os.path.join(dirpath, thefile))
149 149
 
150 150
         if os.path.exists(potfile):
151  
-            (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 'b')
  151
+            (stdin, stdout, stderr) = os.popen3('msguniq --to-code=utf-8 "%s"' % potfile, 't')
152 152
             msgs = stdout.read()
153 153
             errors = stderr.read()
154 154
             if errors:
155 155
                 raise CommandError("errors happened while running msguniq\n%s" % errors)
156 156
             open(potfile, 'w').write(msgs)
157 157
             if os.path.exists(pofile):
158  
-                (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 'b')
  158
+                (stdin, stdout, stderr) = os.popen3('msgmerge -q "%s" "%s"' % (pofile, potfile), 't')
159 159
                 msgs = stdout.read()
160 160
                 errors = stderr.read()
161 161
                 if errors:

0 notes on commit fcf059d

Please sign in to comment.
Something went wrong with that request. Please try again.