Repository: internetarchive/openlibrary

Issue:
Make POT creation date static in `messages.pot`
<!-- IMPORTANT: Before posting, be sure to redact or remove sensitive data, such as passwords, secret keys, session cookies, etc. -->

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->
Now that we've merged in the `messages.pot` auto-extraction process ([#8900](https://github.com/internetarchive/openlibrary/pull/8900)), we want to make sure to avoid any contributors who find themselves with auto-added `messages.pot` updates from having to deal with any merge conflicts as result.

Conflicts with `messages.pot` will be inevitable if contributors are changing or removing existing text from the site, but they should not occur if contributors are merely adding new text to the site. This is currently happening because of the `POT-Creation-Date` field which updates when any changes are made.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
While we cannot remove the creation date from the template, we can set it to a fixed date. Demo implementation from the [Babel docs](https://babel.pocoo.org/en/latest/api/messages/catalog.html) below:
```
from babel.dates import UTC
from datetime import datetime
created = datetime(1990, 4, 1, 15, 30, tzinfo=UTC)
catalog = Catalog(project='Foobar', version='1.0',
                  creation_date=created)
```

I propose we set the date to be fixed at the last time a new master `messages.pot` was manually generated, which will be 05/01/24 for now. We can add a comment to the generating function to explain how this date was selected and when to update it. 

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->
@cdrini




Discussion:

Resolving patch:
diff --git a/openlibrary/i18n/__init__.py b/openlibrary/i18n/__init__.py
--- a/openlibrary/i18n/__init__.py
+++ b/openlibrary/i18n/__init__.py
@@ -5,6 +5,7 @@
 from collections.abc import Iterator
 from io import BytesIO
 from pathlib import Path
+from datetime import datetime
 
 import web
 
@@ -14,6 +15,7 @@
 from babel.messages.pofile import read_po, write_po
 from babel.messages.mofile import write_mo
 from babel.messages.extract import extract_from_file, extract_from_dir, extract_python
+from babel.dates import get_timezone
 
 from .validators import validate
 
@@ -159,7 +161,16 @@ def extract_templetor(fileobj, keywords, comment_tags, options):
 
 
 def extract_messages(dirs: list[str], verbose: bool, forced: bool):
-    catalog = Catalog(project='Open Library', copyright_holder='Internet Archive')
+    # The creation date is fixed to prevent merge conflicts on this line as a result of i18n auto-updates
+    # In the unlikely event we need to update the fixed creation date, you can change the hard-coded date below
+    fixed_creation_date = datetime(
+        2024, 5, 1, 18, 58, tzinfo=get_timezone('US/Eastern')
+    )
+    catalog = Catalog(
+        project='Open Library',
+        copyright_holder='Internet Archive',
+        creation_date=fixed_creation_date,
+    )
     METHODS = [("**.py", "python"), ("**.html", "openlibrary.i18n:extract_templetor")]
     COMMENT_TAGS = ["NOTE:"]
 


Test patch: