From 9c12eb55ceb2dff6e31399f5e258e4355e883930 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sun, 1 May 2016 19:21:43 +0200 Subject: [PATCH] [1.9.x] Fixed #26341 (again) -- Addressed multiple occurrences per line use case Backport of 4731e9d8 from master. --- django/core/management/commands/makemessages.py | 2 +- tests/i18n/commands/templates/test.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index f200a58784..0df47d306e 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -155,7 +155,7 @@ class BuildFile(object): return re.sub( r'^(#: .*)(' + re.escape(old_path) + r')', - r'\1' + new_path, + lambda match: match.group().replace(old_path, new_path), msgs, flags=re.MULTILINE ) diff --git a/tests/i18n/commands/templates/test.html b/tests/i18n/commands/templates/test.html index 90970598b9..23523db7fd 100644 --- a/tests/i18n/commands/templates/test.html +++ b/tests/i18n/commands/templates/test.html @@ -72,6 +72,8 @@ continued here.{% endcomment %} {% trans "#: templates/test.html.py" %} + +{% trans "This literal should be included." %} {% blocktrans context "Special blocktrans context #1" %}Translatable literal #8a{% endblocktrans %} {% blocktrans count 2 context "Special blocktrans context #2" %}Translatable literal #8b-singular{% plural %}Translatable literal #8b-plural{% endblocktrans %}