Opened 8 years ago

Closed 6 years ago

#8124 closed (wontfix)

Proposal: load translations from settings.TEMPLATE_DIRS

Reported by: Joost Cassee Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords:
Cc: joost@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Template paths from settings.TEMPLATE_DIRS are not always (often not?) located within the Python project directory. These directories contain site-wide templates that may contain i18n strings that should be translated. It makes sense to locate the message catalogs for these string with the templates. I propose the following additional convention for translations:

  • Look for a locale directory in every path in settings.TEMPLATE_DIRS. If Django finds a translation, the translation will be installed.

This set-up is already possible by setting settings.LOCALE_PATHS, but this ticket is about proposing a new convention for templates.

If this ticket is accepted I am willing to do the patch.

Change History (6)

comment:1 Changed 8 years ago by Joost Cassee

As a reference, automatically getting translations from template directories requires the following in settings:

LOCALE_PATHS = []
for path in TEMPLATE_DIRS:
    LOCALE_PATHS.append(path + '/locale')
LOCALE_PATHS = tuple(LOCALE_PATHS)

(The conversion to a tuple is necessary to avoid an error in compile_messages.)

comment:2 Changed 8 years ago by Jeff Anderson

Triage Stage: UnreviewedDesign decision needed

comment:3 Changed 8 years ago by Malcolm Tredinnick

milestone: post-1.0
Triage Stage: Design decision neededAccepted

We should fix that requirement to convert to a tuple. Would you mind to open a ticket for that? It's not a very nice requirements.

The proposal itself looks reasonable. It's something for after 1.0, however.

comment:4 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

comment:5 Changed 6 years ago by Ramiro Morales

I'm not convinced standalone templates with associated translations are a common enough deployment scenario to justify adding even another path setting to the list of locations translations will be searched for at runtime.

Isn't enough that this requirement can be solved by using the Python code snippet described in comment:1 in the settings module of projects needing something like this?

comment:6 in reply to:  5 Changed 6 years ago by Joost Cassee

Resolution: wontfix
Status: newclosed

Replying to ramiro:

I'm not convinced standalone templates with associated translations are a common enough deployment scenario to justify adding even another path setting to the list of locations translations will be searched for at runtime.

I usually bundle translation files with templates in private projects. If this is not a common practice, let's close this ticket.

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