[Django] #16493: winodws: makemessages generate django.po should use forward slashes too

70 views
Skip to first unread message

Django

unread,
Jul 20, 2011, 2:25:29 PM7/20/11
to django-...@googlegroups.com
#16493: winodws: makemessages generate django.po should use forward slashes too
-------------------------+--------------------------------------------
Reporter: raidsan@… | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: Core (Management commands)
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 1
UI/UX: 0 |
-------------------------+--------------------------------------------
develope under windows, run "python manage.py makemessages ...", will
write file path use "\" in django.po,[[BR]]
the files copy to product linux server, should not be valid, because
unix/linux use "/" as path seperater.[[BR]]
the solution should be use the same "/" in path string even under
windows.[[BR]]
so, I add a function "normpath" to ensure use "/" under windows:

{{{
def normpath(filepath):
p = os.path.normpath(filepath)
if os.name=='nt':
p = p.replace("\\", "/")
return p
}}}

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

Django

unread,
Jul 20, 2011, 2:39:57 PM7/20/11
to django-...@googlegroups.com
#16493: winodws: makemessages generate django.po should use forward slashes too
-------------------------------------+-------------------------------------
Reporter: raidsan@… | Owner: nobody
Type: New | Status: closed
feature | Component: Core (Management
Milestone: | commands)
Version: 1.3 | Severity: Normal
Resolution: needsinfo | Keywords:
Triage Stage: | Has patch: 1
Unreviewed | Needs tests: 0
Needs documentation: 0 | Easy pickings: 1
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by aaugustin):

* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0


Comment:

The only paths in .po files are comments, so I don't understand why you
say that the resulting file "should not be valid".

Do you really get an error? If yes, can you provide the traceback?

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:1>

Django

unread,
Jan 16, 2013, 6:56:38 PM1/16/13
to django-...@googlegroups.com
#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) | Resolution: needsinfo
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:2>

Django

unread,
May 30, 2013, 4:34:09 AM5/30/13
to django-...@googlegroups.com
#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) | Resolution: needsinfo
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by mithuntnt@…):

The problem i had here was merging between developers using windows and
linux. The windows version change everything to backslash and linux
version changes it to slash. The end result is we need end merging all
comments.

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:3>

Django

unread,
May 30, 2013, 5:13:57 AM5/30/13
to django-...@googlegroups.com
#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) | Resolution: needsinfo
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

makemessages gained a '--no-location' option since this ticket was
initially filed. That probably resolves your problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:4>

Django

unread,
Sep 15, 2021, 4:13:24 AM9/15/21
to django-...@googlegroups.com
#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):

This makes it difficult for Unix and Windows developers to be working on
the same project. The .po file will switch back and forth each time. The
file in the comment is useful information, so using `--no-location` is not
a great solution.

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:5>

Django

unread,
Sep 22, 2021, 8:07:18 AM9/22/21
to django-...@googlegroups.com
#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 Vipul Chaudhary):

I agree with John. Removing information from the document is not the
solution to a problem which is easily fixable within the makemessages
command.

--
Ticket URL: <https://code.djangoproject.com/ticket/16493#comment:6>

Django

unread,
Oct 10, 2021, 11:02:53 PM10/10/21
to django-...@googlegroups.com
#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>

Reply all
Reply to author
Forward
0 new messages