Problem
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
Setup
LOCALE_PATHSset toPROJECT_ROOT/locale.Translations for all apps stored under
LOCALE_PATHS.JavaScriptCatalogconfigured without packages:
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog')
es_MXandestranslations that demonstrate the problem:- The string
"es - Not translated"is translated in theeslocale. - The string
"es_MX - Not translated"is translated in thees_MXlocale.
- The string
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?
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?