Option to skip POT-Creation-Date
Could we get an option to skip adding/updating the POT-Creation-Date header when running pybabel extract?
Use case is that we want a pre-commit hook that updates the translations, to ensure our translations are always in sync with the code base. But, because it changes this header every time, it results in a merge conflict with every single branch.
I would love this!
We've got a GitHub Action step that runs pybabel extract on every push to master that opens a Pull Request to update the message catalog. This option would allow us to skip creating Pull Requests that only contain changes to the POT-Creation-Date (or any other header changes like Generated-By, etc).
We ended up adding a post-process step to strip out this line (and a couple more bespoke things). So we have a script which basically runs the extract function, then runs some others functions which post-process the files. Given that we've been using it since I opened this issue with little issues, it seems to be pretty stable.
@Dreamsorcerer would you mind sharing some of that if possible? I started writing some bash to do this but it got unwieldily fairly quickly 😅
Slightly modified, but this should work (if you change project_path to the correct directory).
https://gist.github.com/Dreamsorcerer/9355fd2a308121589d7c2fa5ffaa3e8a
We ended up using the extract function in a pre-commit hook to ensure that translations were always in-sync with the code.
@Dreamsorcerer thank you!
This feature would be very useful. Is there any updates on it?
This feature can be to keep the creation date when updating, change it only on creation.
PRs are very much welcome :)
@akx Any interest in my PR? https://github.com/python-babel/babel/pull/999
@akx When will this be published into a new release?
@akx When will this be published into a new release?
This just got released in 2.13.0!
@joeportela @akx
I have just tested the PO update functionality using the new option --ignore-pot-creation-date and it looks good (no creation date differences):
What I am missing now is something similar for the POT extract functionality:
There is nothing left to do here and this should not be added for extract, its extracting, not updating.
This should be closed @akx
@akx @StanFromIreland
POT-Creation-Date is still being modified on extract using Babel 2.17.0.
Yes and it will be.
extract doesn't read the file it's writing to, so it can't exactly "not update" a thing it doesn't know about.
If you need functionality to force the POT-Creation-Date to a value you'd prefer (or elide it altogether), that could be considered, but I'd like to know what the usecase is.
To elide it altogether there is always --omit-header
If you need functionality to force the
POT-Creation-Dateto a value you'd prefer (or elide it altogether), that could be considered, but I'd like to know what the usecase is.
I think my report clearly says on extract and explains the usecase. I think --omit-header didn't exist at the time though, so maybe that does the job we needed (at the time we just created a post-processing step to get the output we needed, and I'm no longer involved on that project).
@akx
I believe it may know about the file used in -o. We create it by:
pybabel -v extract \
--mapping-file "../babel.cfg" \
-o "../${POT_FILE}" \
--input-dirs "${role_path}/tasks" \
--copyright-holder "${COPYRIGHT_HOLDER}" \
--msgid-bugs-address "${MSGID_BUGS_ADDRESS}" \
--project "${PROJECT}" \
--version "${VERSION}"
Hi @akx ,
The usecase would be the same as exposed @Dreamsorcerer at the beginning: If we just added/removed/updated some strings, we don't want all the files to be updated. In the current way, the commits and Pull Requests get much more complicated than what it should be if we'd omit the POT-Creation-Date. And, also, this is misleading, as the file was created before that. Even if you want to add a POT-Update-Date, that should only be updated if anything changed in the POT file, not just because we searched for strings changes.