The problem I am having is that 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
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:
"es - Not translated"
is translated in the es
locale."es_MX - Not translated"
is translated in the es_MX
locale.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?
I tried this answer, which suggests adding domain="django"
, but it didn't work for me.
What am I doing wrong or is this an issue?
This was identified as a bug in issue #33863 and a fix was submitted. The solution will be to update Django when this fix is released.
As a workaround, I suggest what I noted in the question (pass packages
to JavaScriptCatalog
):
path(
'jsi18n/',
JavaScriptCatalog.as_view(packages=["<your-app-here>"]),
name='javascript-catalog'
)