Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#34848 closed Bug (fixed)

Updating translations catalog for javascript files fails with CommandError

Reported by: Natalia Bidart Owned by: Natalia Bidart
Component: Internationalization Version: 5.0
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 django/views/templates/i18n_catalog.js was upgraded to a "full javascript" file in 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 <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=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.

Change History (8)

comment:1 by Mariusz Felisiak, 15 months ago

Owner: changed from nobody to Natalia Bidart
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

comment:2 by Claude Paroz, 15 months ago

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.

comment:3 by Natalia Bidart, 15 months ago

Has patch: set

comment:4 by Mariusz Felisiak, 15 months ago

Patch needs improvement: set
Type: Cleanup/optimizationBug

comment:5 by Natalia Bidart, 15 months ago

Patch needs improvement: unset

comment:6 by Mariusz Felisiak, 15 months ago

Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 15 months ago

Resolution: fixed
Status: assignedclosed

In d7972436:

Fixed #34848 -- Ignored i18n_catalog.js file when building Django's translations catalog.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 15 months ago

In 88992c5:

[5.0.x] Fixed #34848 -- Ignored i18n_catalog.js file when building Django's translations catalog.

Backport of d7972436639bacada0f94d3b9818446343af59ad from main

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