[Django] #29074: django-admin makemessages messes up .po file when fed with empty strings

15 views
Skip to first unread message

Django

unread,
Jan 26, 2018, 10:31:05 PM1/26/18
to django-...@googlegroups.com
#29074: django-admin makemessages messes up .po file when fed with empty strings
-------------------------------------+-------------------------------------
Reporter: | Owner: nobody
instantname |
Type: Bug | Status: new
Component: Core | Version: 1.11
(Management commands) |
Severity: Normal | Keywords: i18n
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Django 1.11.9

== Steps to reproduce

{{{
django-admin startproject mysite
cd mysite/mysite
mkdir locale
}}}

Edit urls.py to add this line at the end:

{{{
_('hello')
}}}

Create messages:

{{{
django-admin makemessages -l de
}}}

Edit urls.py again to add this line at the end:

{{{
pgettext_lazy('context', '')
}}}

Update messages:

{{{
django-admin makemessages
}}}

== Result

The locale/de/django.po file obtained is the following:

{{{
# 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-01-27 03:50+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <L...@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: urls.py:23
msgid "hello"
msgstr ""

# 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.
#
#: urls.py:24
#, fuzzy
msgctxt "context"
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-01-27 03:49+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <L...@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
}}}

The unexpected behavior is the repetition of some header lines. This seems
to only happen with empty strings in the Python code. While a bit odd, I
think empty strings are valid strings (at least with a context) that may
sometimes need translation.

--
Ticket URL: <https://code.djangoproject.com/ticket/29074>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 28, 2018, 2:01:29 PM1/28/18
to django-...@googlegroups.com
#29074: django-admin makemessages messes up .po file when fed with empty strings
-------------------------------------+-------------------------------------
Reporter: instantname | Owner: Manthan
| Sharma
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: i18n | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Manthan Sharma):

* owner: nobody => Manthan Sharma
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29074#comment:1>

Django

unread,
Feb 3, 2018, 6:08:24 PM2/3/18
to django-...@googlegroups.com
#29074: makemessages duplicates .po file headers when fed with empty strings
-------------------------------------+-------------------------------------

Reporter: instantname | Owner: Manthan
| Sharma
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: i18n | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29074#comment:2>

Django

unread,
Mar 17, 2018, 3:26:53 PM3/17/18
to django-...@googlegroups.com
#29074: makemessages duplicates .po file headers when fed with empty strings
-------------------------------------+-------------------------------------

Reporter: instantname | Owner: Manthan
| Sharma
Type: Bug | Status: assigned
Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution:
Keywords: i18n | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Hasan Ramezani):

It seems the problem goes from `msgmerge` in `def write_po_file`. I think
merge process destroy the file structure.

--
Ticket URL: <https://code.djangoproject.com/ticket/29074#comment:3>

Django

unread,
Jun 26, 2018, 5:03:05 PM6/26/18
to django-...@googlegroups.com
#29074: makemessages duplicates .po file headers when fed with empty strings
-------------------------------------+-------------------------------------

Reporter: instantname | Owner: Manthan
| Sharma
Type: Bug | Status: closed

Component: Core (Management | Version: 1.11
commands) |
Severity: Normal | Resolution: wontfix

Keywords: i18n | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* status: assigned => closed
* resolution: => wontfix


Comment:

`gettext` does not like when one tries to translate the empty string, as
it has a special meaning in the PO file format. See #23196 for another
case where we had to workaround a similar issue.

In this case, the header duplication is produced by `msgmerge` itself. I'm
of the opinion that we should consider translating an empty string as an
unsupported functionality of the underlying `gettext` library.

--
Ticket URL: <https://code.djangoproject.com/ticket/29074#comment:4>

Reply all
Reply to author
Forward
0 new messages