[Django] #34848: Updating translations catalog for javascript files fails with CommandError

70 views
Skip to first unread message

Django

unread,
Sep 18, 2023, 5:53:35 PM9/18/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
------------------------------------------------+------------------------
Reporter: Natalia Bidart | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Running the command to update the translations catalog for the `djangojs`
domain fails with the following error:

{{{
xgettext: warning: msgid '' is used without plural and with plural.
./views/templates/i18n_catalog.js:52: Here is the
occurrence without plural.
./views/templates/i18n_catalog.js:60: Here is the
occurrence with plural.
Workaround: If the msgid is a sentence, change the
wording of the sentence; otherwise, use contexts for disambiguation.
CommandError: errors happened while running msguniq
/home/nessita/fellowship/django/django/conf/locale/djangojs.pot:22:
context separator <EOT> within string
/home/nessita/fellowship/django/django/conf/locale/djangojs.pot:23:
context separator <EOT> within string
msguniq: found 2 fatal errors
}}}

As far as I have been able to debug, these errors come from these two
lines from the `django/views/templates/i18n_catalog.js` file:

{{{
let value = django.gettext(context + '\x04' + msgid);
}}}

and

{{{
let value = django.ngettext(context + '\x04' + singular, context + '\x04'
+ plural, count);
}}}

This file
[https://github.com/ngnpope/django/blob/main/django/views/templates/i18n_catalog.js
django/views/templates/i18n_catalog.js] was upgraded to a "full
javascript" file in [https://github.com/django/django/pull/16562/files
#diff-1b9c97f5db01b8f98f017fc8727caa7c7328f1c9147a906b652127148a698ba8 PR
#16562]: before this change, the javascript for the `i18n_catalog` was
inline in the `i18n.py` module.

The generated `pot` for this file looks like this:

{{{
# 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: 2023-09-18 14:48-0300\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=INTEGER; plural=EXPRESSION;\n"

#: views/templates/i18n_catalog.js:52 views/templates/i18n_catalog.js:60
msgid ""
msgid_plural ""
msgstr[0] ""
msgstr[1] ""
}}}

It seems that we need to have a way to skip fetching translations for the
`i18n_catalog.js` file. An immediate workaround is to use this command:

{{{
django-admin makemessages -l en --domain=djangojs -i
views/templates/i18n_catalog.js
}}}

But I think we may need to provide a more standard/common way to generate
this catalogs so future contributors do not need to go thru this
debugging. One option would be to provide a toplevel `Makefile` with a
rule to update translations catalogs.

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

Django

unread,
Sep 18, 2023, 11:23:42 PM9/18/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
Type: | Bidart
Cleanup/optimization | Status: assigned
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: nobody => Natalia Bidart
* status: new => assigned
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


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

Django

unread,
Sep 19, 2023, 12:30:30 PM9/19/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
Type: | Bidart
Cleanup/optimization | Status: assigned
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

We already have a section in the command where we detect usage for Django
itself (setting `invoked_for_django = True`), so one solution would be to
add that specific path to `self.ignore_patterns` in that same section of
the code.

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

Django

unread,
Sep 20, 2023, 4:53:29 PM9/20/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
Type: | Bidart
Cleanup/optimization | Status: assigned
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

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

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/17293 PR]

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

Django

unread,
Sep 20, 2023, 11:48:43 PM9/20/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
| Bidart
Type: Bug | Status: assigned

Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* needs_better_patch: 0 => 1
* type: Cleanup/optimization => Bug


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

Django

unread,
Sep 21, 2023, 9:52:24 PM9/21/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
| Bidart
Type: Bug | Status: assigned
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/34848#comment:5>

Django

unread,
Sep 22, 2023, 2:20:53 AM9/22/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
| Bidart
Type: Bug | Status: assigned
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/34848#comment:6>

Django

unread,
Sep 22, 2023, 2:55:12 AM9/22/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
| Bidart
Type: Bug | Status: closed
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"d7972436639bacada0f94d3b9818446343af59ad" d7972436]:
{{{
#!CommitTicketReference repository=""
revision="d7972436639bacada0f94d3b9818446343af59ad"
Fixed #34848 -- Ignored i18n_catalog.js file when building Django's
translations catalog.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34848#comment:7>

Django

unread,
Sep 22, 2023, 2:55:30 AM9/22/23
to django-...@googlegroups.com
#34848: Updating translations catalog for javascript files fails with CommandError
-------------------------------------+-------------------------------------
Reporter: Natalia Bidart | Owner: Natalia
| Bidart
Type: Bug | Status: closed
Component: | Version: 5.0
Internationalization |
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"88992c5ac62f4170bc502adb8a9d7304ce6dccc3" 88992c5]:
{{{
#!CommitTicketReference repository=""
revision="88992c5ac62f4170bc502adb8a9d7304ce6dccc3"
[5.0.x] Fixed #34848 -- Ignored i18n_catalog.js file when building
Django's translations catalog.

Backport of d7972436639bacada0f94d3b9818446343af59ad from main
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/34848#comment:8>

Reply all
Reply to author
Forward
0 new messages