diff --git a/AKModel/management/__init__.py b/AKModel/management/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AKModel/management/commands/__init__.py b/AKModel/management/commands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/AKModel/management/commands/makemessages.py b/AKModel/management/commands/makemessages.py new file mode 100644 index 0000000000000000000000000000000000000000..d3e9149ef15610ba54f67e1629283e927e831cdd --- /dev/null +++ b/AKModel/management/commands/makemessages.py @@ -0,0 +1,39 @@ +""" +Ensure PO files are generated using forward slashes in the location comments on all operating systems +""" +import os + +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