开发者

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

开发者 https://www.devze.com 2022-12-29 03:06 出处:网络
开发者_开发问答Currently all JavaScript files are served from our static/media directory in the top level project directory. When running makemassages -d djangojs it will generate the locale directory

开发者_开发问答Currently all JavaScript files are served from our static/media directory in the top level project directory. When running makemassages -d djangojs it will generate the locale directory in the top level too.

However, javascript_catalog will only consider locale directories created in apps, i.e. listed in the INSTALLED_APPS setting.

What's the proper way of having makemessages and javascript_catalog work in tandem to actually use the JavaScript i18n functionality?

Move the js-files into the app dir and have multiple static directories (not appealing imho, I'm currently serving static files through nginx and this, among other things, will clutter the conf)?

I'm using Django 1.1


i worked around this some weeks ago in creating symlinks in each project dir to the media files and it worked fine for me :-)

config hell but "some sort of" DRY


The cleanest solution is to just add the locale (eg in your top-level project directory that sits above the apps) to LOCALE_PATH in your settings file:

eg

LOCALE_PATHS = (
  '/somepath/project/locale',
)
0

精彩评论

暂无评论...
验证码 换一张
取 消