Skip to content

Commit

Permalink
fix: Update .po file handling to set a fixed creation date
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Jan 19, 2025
1 parent 2b72912 commit ebabd05
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions contests/management/commands/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,16 @@ def convert_to_po(self, translations, language, po_path):
if entry.msgstr == '':
entry.msgstr = entry.msgid

# Save the .po file
po.save(po_path)

# Edit the .po file to replace the creation date with an fixed date
with open(po_path, 'r', encoding='utf-8') as f:
content = f.read()
content = re.sub(r'"POT-Creation-Date:[^"]*"', '"POT-Creation-Date: 2021-01-01 00:00+0000"', content)
with open(po_path, 'w', encoding='utf-8') as f:
f.write(content)

print(f"Successfully converted to {po_path}")
return po

Expand Down

0 comments on commit ebabd05

Please sign in to comment.