Opened 2 years ago

Closed 2 years ago

#33863 closed Bug (fixed)

Strings from default locale missing from Django JavaScript catalog

Reported by: Carlos Mermingas Owned by: Claude Paroz
Component: Internationalization Version: 4.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

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?

Change History (6)

comment:1 by Claude Paroz, 2 years ago

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

comment:2 by Carlos Mermingas, 2 years ago

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

comment:3 by Claude Paroz, 2 years ago

Owner: changed from nobody to Claude Paroz
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Thanks for your test, I spotted the issue.

comment:4 by Claude Paroz, 2 years ago

Has patch: set

comment:5 by Mariusz Felisiak, 2 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In f2dd6522:

Fixed #33863 -- Fixed JavaScriptCatalog with more than 1 level of fallback translations.

Co-authored-by: Carlos Mermingas <cmermingas@…>

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