django icon indicating copy to clipboard operation
django copied to clipboard

Added more Path usages in makemessages command.

Open claudep opened this issue 1 year ago • 1 comments

claudep avatar Jul 25 '22 21:07 claudep

I guess I would need support for Windows failures :-/

claudep avatar Jul 29 '22 12:07 claudep

@claudep Do you have time to keep working on this?

felixxm avatar Jul 04 '23 08:07 felixxm

Yes, but as I don't work on Windows, I need someone else to debug Windows failures.

claudep avatar Jul 04 '23 11:07 claudep

I can help have a look. I'll add it to my list 🗒️

smithdc1 avatar Jul 04 '23 12:07 smithdc1

Could you try re-basing this PR to main?

smithdc1 avatar Jul 04 '23 21:07 smithdc1

Sure, done!

claudep avatar Jul 05 '23 06:07 claudep

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):

smithdc1 avatar Jul 06 '23 20:07 smithdc1