django
django copied to clipboard
Added more Path usages in makemessages command.
I guess I would need support for Windows failures :-/
@claudep Do you have time to keep working on this?
Yes, but as I don't work on Windows, I need someone else to debug Windows failures.
I can help have a look. I'll add it to my list 🗒️
Could you try re-basing this PR to main
?
Sure, done!
With this patch file names no longer have the leading .\
Before
#: .\__init__.py:3
msgid "This is a translatable string."
msgstr "And this has been translated."
After
#: __init__.py:3
msgid "This is a translatable string."
msgstr "And this has been translated."
How important is it to keep this exactly the same? After all they are only comments to help translators understand the context?
If this change is acceptable a couple of edits to the tests to no longer special case Windows systems would be required.
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index 8ee35656bd..cd474799d8 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -67,14 +67,7 @@ class ExtractorTests(POFileAssertionMixin, RunInTmpDirMixin, SimpleTestCase):
):
with open(po_filename) as fp:
po_contents = fp.read()
- if os.name == "nt":
- # #: .\path\to\file.html:123
- cwd_prefix = "%s%s" % (os.curdir, os.sep)
- else:
- # #: path/to/file.html:123
- cwd_prefix = ""
-
- path = os.path.join(cwd_prefix, *comment_parts)
+ path = os.path.join("", *comment_parts)
parts = [path]
if isinstance(line_number, str):
@@ -1030,15 +1023,7 @@ class UnchangedPoExtractionTests(ExtractorTests):
super().setUp()
po_file = Path(self.PO_FILE)
po_file_tmp = Path(self.PO_FILE + ".tmp")
- if os.name == "nt":
- # msgmerge outputs Windows style paths on Windows.
- po_contents = po_file_tmp.read_text().replace(
- "#: __init__.py",
- "#: .\\__init__.py",
- )
- po_file.write_text(po_contents)
- else:
- po_file_tmp.rename(po_file)
+ po_file_tmp.rename(po_file)
self.original_po_contents = po_file.read_text()
def test_po_remains_unchanged(self):