Skip to content

Instantly share code, notes, and snippets.

@WillsB3
Last active April 6, 2020 08:24
Show Gist options
  • Save WillsB3/f0012b98dbbed91a30fa1b23d9851caa to your computer and use it in GitHub Desktop.
Save WillsB3/f0012b98dbbed91a30fa1b23d9851caa to your computer and use it in GitHub Desktop.
Django patch to help with testing that content is correctly marked up for translation
# django/utils/translation/trans_real.py
#
# Add the following to the end of the `do_translate` method (~line 316 in Django 1.11.27), just after the eol_message assignment.
#
# This replaces characters within content marked up for translation with `#`. The idea is that, with this
# patch applied, you can browse the site and look for any copy that has not been replaced with `#`. Any
# copy you find will not yet have been marked up for translation.
import re
return re.sub(r'[^ ]', r'#', message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment