Where should I put JavaScript files that should be internationalized in a Django project?

Currently, all JavaScript files are served from our static / media directory in the top-level project directory. When makemassages -d djangojs it will generate a locale directory at the top level.

However, javascript_catalog will only consider locale directories created in applications, that is, those listed in the INSTALLED_APPS setting.

What is the correct way to create makemessages and javascript_catalog to work in tandem to actually use the i18n JavaScript functionality?

Move js files to application directory and some static directories (not attractive imho, I am currently serving static files via nginx and this, by the way, clutter up conf)?

I am using Django 1.1

+4
source share
2 answers

I worked around this a few weeks ago in creating symbolic links in every dir project for media files, and it worked fine for me :-)

config hell, but "some" DRY

+2
source

The cleanest solution is to simply add the locale (for example, to the top-level project directory located above the applications) in LOCALE_PATH in the settings file:

eg,

 LOCALE_PATHS = ( '/somepath/project/locale', ) 
+1
source

Source: https://habr.com/ru/post/1308353/


All Articles