Opened 7 years ago

Closed 7 years ago

Last modified 7 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 7 years ago.
Simple project for example

Download all attachments as: .zip

Change History (7)

comment:1 Changed 7 years ago by Claude Paroz

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.

comment:2 in reply to:  1 Changed 7 years ago by Rignon Noël

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.
it's exctracted only in a template directory.

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

Last edited 7 years ago by Rignon Noël (previous) (diff)

Changed 7 years ago by Rignon Noël

Attachment: TableauDeBord - Copie.zip added

Simple project for example

comment:3 Changed 7 years ago by Rignon Noël

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 Changed 7 years ago by Rignon Noël

Resolution: worksforme
Status: closednew

comment:5 Changed 7 years ago by Claude Paroz

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 Changed 7 years ago by Rignon Noël

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