Opened 7 years ago

Closed 5 years ago

#8124 closed (wontfix)

Proposal: load translations from settings.TEMPLATE_DIRS

Reported by: jcassee 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 7 years ago by jcassee

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 7 years ago by programmerq

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 7 years ago by mtredinnick

  • milestone set to post-1.0
  • Triage Stage changed from Design decision needed to Accepted

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 7 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:5 follow-up: Changed 5 years ago by 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.

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 5 years ago by jcassee

  • Resolution set to wontfix
  • Status changed from new to closed

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