Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25162 closed Uncategorized (invalid)

Internationalization of static JS

Reported by: Rignon Noël Owned by: nobody
Component: Internationalization Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I want to translate a part of my JS in Django.

I've try the command

python manage.py makemessages -d djangojs

but it take only file in TEMPLATE_DIRS in the settings.py

I've try to set a JS in a template directory, and it work perfectly.

I've the djangojs.po and i can generate the .mo when i compile.

So it's a bug or how make message in static file ?

My architecture:

  • myapp
    • locale
    • static
      • myapp
        • js
          • try.js
    • template
      • myapp
        • try.html
    • views.py
    • urls.py
    • [...]

Attachments (1)

TableauDeBord - Copie.zip (9.3 KB ) - added by Rignon Noël 9 years ago.
Simple project for example

Download all attachments as: .zip

Change History (7)

comment:1 by Claude Paroz, 9 years ago

Resolution: worksforme
Status: newclosed

The js files in your static directory should be extracted. Ensure that you didn't set STATIC_ROOT to myapp/static.
Please provide us with a sample project if you can reproduce this issue.

in reply to:  1 comment:2 by Rignon Noël, 9 years ago

Replying to claudep:

The js files in your static directory should be extracted. Ensure that you didn't set STATIC_ROOT to myapp/static.
Please provide us with a sample project if you can reproduce this issue.

I've set this STATIC_ROOT = os.path.join(BASE_DIR, 'app/home/static')

But my JS is not extracted even if I put it in app/home/static.

I'll create a simple project for you. I come back before next week.

Version 0, edited 9 years ago by Rignon Noël (next)

by Rignon Noël, 9 years ago

Attachment: TableauDeBord - Copie.zip added

Simple project for example

comment:3 by Rignon Noël, 9 years ago

You can try with this simple project :

python manage.py makemessages -d djangojs turn if the JS file is in app/home/template/home only

comment:4 by Rignon Noël, 9 years ago

Resolution: worksforme
Status: closednew

comment:5 by Claude Paroz, 9 years ago

Resolution: invalid
Status: newclosed

Thanks for the sample project. That's exactly what I tried to explain before. Setting STATIC_ROOT to an existing repository directory is a mistake. STATIC_ROOT is a directory where the collectstatic management command is going to copy all static files from all apps, and it should NOT point to any of your app static directory.

makemessages is purposefully excluding extraction from files inside STATIC_ROOT (as it's already extracting messages from the static files in their initial directory).

comment:6 by Rignon Noël, 9 years ago

No, it is me who thank you. You do a very good work ;)

Sorry for the bad ticket, thanks again !

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