Opened 6 years ago

Closed 6 years ago

#29362 closed Uncategorized (invalid)

makemessages ignores implicitly concatenated string literals

Reported by: Chris Bailey Owned by: nobody
Component: Uncategorized Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In our company we use python's implicit joining of string literals to break long lines in our codebase.
We just realised these are being ignored by makemessages.
Don't think this is a bug so much as a comment worth mentioning - maybe the docs could be updated?

So for example, on an initial site with the following in mysite/mysite/__init__.py:

from django.utils.translation import pgettext

var_1 = pgettext(
   'context1',
   'a singleline string',
)

var_2 = pgettext(
    'context2',
    (
         'A '
        'multiline '
        'string'
    )
)

django-admin makemessages -l es_ES produces:

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-04-25 17:05+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: mysite/mysite/__init__.py:5
msgctxt "context1"
msgid "a singleline string"
msgstr ""

Change History (1)

comment:1 by Claude Paroz, 6 years ago

Resolution: invalid
Status: newclosed

It will work if you simply remove the parentheses around the second parameter. Anyway, this is gettext behavior, Django cannot do anything about it.

Note: See TracTickets for help on using tickets.
Back to Top