From b7508896fbe19ec2cdeb81565cd587091b6b68d0 Mon Sep 17 00:00:00 2001 From: Doug Beck Date: Wed, 15 Apr 2015 17:01:11 -0400 Subject: Fixed #24257 -- Corrected i18n handling of percent signs. Refactored tests to use a sample project. Updated extraction: * Removed special handling of single percent signs. * When extracting messages from template text, doubled all percent signs so they are not interpreted by gettext as string format flags. All strings extracted by gettext, if containing a percent sign, will now be labeled "#, python-format". Updated translation: * Used "%%" for "%" in template text before calling gettext. * Updated {% trans %} rendering to restore "%" from "%%". --- django/utils/translation/trans_real.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'django/utils') diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 8a2527022d..e05b5613a5 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -534,7 +534,6 @@ block_re = re.compile(r"""^\s*blocktrans(\s+.*context\s+((?:"[^"]*?")|(?:'[^']*? endblock_re = re.compile(r"""^\s*endblocktrans$""") plural_re = re.compile(r"""^\s*plural$""") constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""") -one_percent_re = re.compile(r"""(?