Skip to content

Commit

Permalink
fix: restore PO-Revision-Date but with fixed value
Browse files Browse the repository at this point in the history
External packages are forcing validation on PO-Revision-Date. We need to restore
the metadata to .po file. But we set a fixed value (1970-01-01 00:00:00.000000)
to avoid having a lot of false (git diff) lines
  • Loading branch information
shadinaif committed Sep 28, 2023
1 parent ac49869 commit 32c0738
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion i18n/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from . import config

__version__ = '1.2.0'
__version__ = '1.3.0'


class Runner:
Expand Down
4 changes: 2 additions & 2 deletions i18n/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ def fix_metadata(pofile):
'Last-Translator': '',
'Language-Team': 'openedx-translation <[email protected]>',
'Plural-Forms': 'nplurals=2; plural=(n != 1);',
'POT-Creation-Date': '2023-06-13 08:00+0000',
'PO-Revision-Date': '2023-06-13 09:00:00.000000',
}
pofile.metadata.pop('POT-Creation-Date', None)
pofile.metadata.pop('PO-Revision-Date', None)
pofile.metadata.update(fixes)


Expand Down
11 changes: 11 additions & 0 deletions tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ def test_metadata_no_create_date(self):
metadata = po.metadata
self.assertIsNone(metadata.get('POT-Creation-Date'))

@perform_extract_with_options()
def test_metadata_fixed_revision_date(self):
"""
Verify `POT-Creation-Date` and `PO-Revision-Date` metadata are always set to a fixed date-time
"""
for path in self.get_files():
po = polib.pofile(path)
metadata = po.metadata
self.assertEqual(metadata.get('POT-Creation-Date'), '2023-06-13 08:00+0000')
self.assertEqual(metadata.get('PO-Revision-Date'), '2023-06-13 09:00:00.000000')

@perform_extract_with_options()
def test_merge_po_files(self):
"""
Expand Down

0 comments on commit 32c0738

Please sign in to comment.