[Django] #33863: Strings from default locale missing from Django JavaScript catalog

17 views
Skip to first unread message

Django

unread,
Jul 22, 2022, 5:56:30 PM7/22/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
------------------------------------------------+------------------------
Reporter: Carlos Mermingas | Owner: nobody
Type: Uncategorized | Status: new
Component: Internationalization | Version: 4.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 |
------------------------------------------------+------------------------
== Problem
The JavaScript catalog doesn't include fallback strings in certain
scenarios. In other words: when string "A" is not translated in `es_MX`
but it is translated in `es`, the JavaScript catalog contains the default
or untranslated "A" string.

I set up an app that demonstrates this problem:
https://github.com/cmermingas/i18n_test

I believe that this is an issue but I asked in StackOverflow, in case it's
improper use: https://stackoverflow.com/questions/73086306/strings-from-
default-locale-missing-from-django-javascript-catalog

== Setup

* `LOCALE_PATHS` set to `PROJECT_ROOT/locale`.

* Translations for all apps stored under `LOCALE_PATHS`.

* `JavaScriptCatalog` configured without packages:

{{{
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog')
}}}

* `es_MX` and `es` translations that demonstrate the problem:

* The string `"es - Not translated"` is translated in the `es` locale.
* The string `"es_MX - Not translated"` is translated in the `es_MX`
locale.

== Workaround

This works if I pass `packages` to `JavaScriptCatalog`:

{{{
path(
'jsi18n/',
JavaScriptCatalog.as_view(packages=["testapp"]),
name='javascript-catalog'
)
}}}

But this is not required, is it?

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

Django

unread,
Jul 23, 2022, 9:13:25 AM7/23/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------

Reporter: Carlos Mermingas | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 4.0
Internationalization |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz):

I was not able to reproduce your issue with
https://github.com/claudep/django/commit/8941db68bef
Did I miss something?

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

Django

unread,
Jul 23, 2022, 11:50:09 AM7/23/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------
Reporter: Carlos Mermingas | Owner: nobody
Type: Uncategorized | Status: new
Component: | Version: 4.0
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlos Mermingas):

Thank you Claude. The only difference that I see in that test setup is
that the "locale" folder is under "view_tests", which is an installed app.

How about this?
https://github.com/cmermingas/django/commit/20f1a1a2f0d0a11f96f6c182b017230bf58ecfa6

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

Django

unread,
Jul 23, 2022, 2:03:23 PM7/23/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------
Reporter: Carlos Mermingas | Owner: Claude
| Paroz
Type: Bug | Status: assigned

Component: | Version: 4.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 Claude Paroz):

* owner: nobody => Claude Paroz
* status: new => assigned
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Thanks for your test, I spotted the issue.

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

Django

unread,
Jul 23, 2022, 2:28:03 PM7/23/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------
Reporter: Carlos Mermingas | Owner: Claude
| Paroz
Type: Bug | Status: assigned
Component: | Version: 4.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 Claude Paroz):

* has_patch: 0 => 1


Comment:

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

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

Django

unread,
Jul 25, 2022, 1:58:22 AM7/25/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------
Reporter: Carlos Mermingas | Owner: Claude
| Paroz
Type: Bug | Status: assigned
Component: | Version: 4.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/33863#comment:5>

Django

unread,
Jul 25, 2022, 3:12:03 AM7/25/22
to django-...@googlegroups.com
#33863: Strings from default locale missing from Django JavaScript catalog
-------------------------------------+-------------------------------------
Reporter: Carlos Mermingas | Owner: Claude
| Paroz
Type: Bug | Status: closed
Component: | Version: 4.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:"f2dd652245987465754c7242b60ccaba03a20f06" f2dd6522]:
{{{
#!CommitTicketReference repository=""
revision="f2dd652245987465754c7242b60ccaba03a20f06"
Fixed #33863 -- Fixed JavaScriptCatalog with more than 1 level of fallback
translations.

Co-authored-by: Carlos Mermingas <cmerm...@gmail.com>
}}}

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

Reply all
Reply to author
Forward
0 new messages