#16493: Windows:  makemessages generate django.po should use forward slashes too
-------------------------------------+-------------------------------------
     Reporter:  raidsan@…            |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Core (Management     |                  Version:  1.3
  commands)                          |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by John Vandenberg):

 The following makemessages.py works around this problem:

 {{{#!python
 import os
 import sys

 from django.core.management.commands.makemessages import Command as
 MakeMessagesCommand


 class Command(MakeMessagesCommand):
     def find_files(self, root):
         all_files = super().find_files(root)
         if os.sep != "\\":
             return all_files

         for file_entry in all_files:
             if file_entry.dirpath == ".":
                 file_entry.dirpath = ""
             elif file_entry.dirpath.startswith(".\\"):
                 file_entry.dirpath = file_entry.dirpath[2:].replace("\\",
 "/")

         return all_files

     def build_potfiles(self):
         pot_files = super().build_potfiles()
         if os.sep != "\\":
             return pot_files

         for filename in pot_files:
             lines = open(filename, "r", encoding="utf-8").readlines()
             fixed_lines = []
             for line in lines:
                 if line.startswith("#: "):
                     line = line.replace("\\", "/")
                 fixed_lines.append(line)

             with open(filename, "w", encoding="utf-8") as f:
                 f.writelines(fixed_lines)

         return pot_files
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/075.4ae9124e22d916d31fe5140ddbf5c868%40djangoproject.com.

Reply via email to