Add server side validation, new auto-reload method, and save po files with FileLock #299
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
pip install tox && tox
)This is based on #296, which needs to be merged first but I thought I might as well add a new PR already.
This adds the following:
ROSETTA_VALIDATE
: Server side validation that shows the same errors thatcompilemessages
does. But this includes errors in fuzzy entries as well, because I guess there's no reason not to review those asap too.ROSETTA_AUTO_RELOAD
: New auto-reload option to make the translation changes automatically visible without restarting anything (see docs for details).AUTO_RELOAD
but now alsoAUTO_COMPILE
requires that validation should pass. Except ifROSETTA_VALIDATE
is disabled then these are allowed to go ahead regardless, mainly for backwards compatibility and just to give users more control.logger.exception()
s for errors during save/reload.Notes:
compilemessages
is a bit broken: https://code.djangoproject.com/ticket/36010 - In case you'd want to compare the output then currently you need totouch
the po file first: that gets around this bug.I haven't tested it yet but looks like the handling of f-strings is changing: https://code.djangoproject.com/ticket/35993 So with newer versions of gettext I guess it might start showing errors related to these too.
To test auto-reload I've used another private project that already had
nginx
andgunicorn
set up, which is very close to what many production environments look like too.pip uninstall django-rosetta -y && pip install git+https://github.com/balazs-endresz/django-rosetta.git@extend-django-admin-validate-auto-reload#egg=django-rosetta
'rosetta.middleware.AutoReloadMiddleware'
tosettings.MIDDLEWARE
import os; os.getpid()