Skip to content

Instantly share code, notes, and snippets.

@pierremonico
pierremonico / Localize Vue files with Django `makemessages`.md
Last active April 26, 2022 13:51
Localize Vue files with Django `makemessages`

NB: the whole approach of serving a Vue project through Django is less than ideal, so this can be seen as deprecated.

Intro

The goal of this gist is to be able to use the built-in makemessages command of Django on your Vue frontend. You can then expose a JavaScript catalog and localize your frontend using gettext.

Following assumptions are made:

  • The directory for the frontend lives in your Django project
  • You are using components (.vue files)

Include the JS Catalog view

Somewhere in urls.py: