Opened 7 years ago

Closed 6 years ago

#29074 closed Bug (wontfix)

makemessages duplicates .po file headers when fed with empty strings

Reported by: instantname Owned by: Manthan Sharma
Component: Core (Management commands) Version: 1.11
Severity: Normal Keywords: i18n
Cc: dgt-qzl@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 <LL@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 <LL@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.

Change History (4)

comment:1 by Manthan Sharma, 7 years ago

Owner: changed from nobody to Manthan Sharma
Status: newassigned

comment:2 by Tim Graham, 7 years ago

Summary: django-admin makemessages messes up .po file when fed with empty stringsmakemessages duplicates .po file headers when fed with empty strings
Triage Stage: UnreviewedAccepted

comment:3 by Hasan Ramezani, 7 years ago

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

comment:4 by Claude Paroz, 6 years ago

Resolution: wontfix
Status: assignedclosed

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.

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