Code

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7706 closed (duplicate)

locale dir allowed in project dir, but views.i18n.javascript_catalog filters it out

Reported by: robbyd Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: javascript_catalog, i18n, jsi18n
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Back again. I found what seems to be a bit of a design inconsistency.

According to this link, the locale dir can be in the Django project directory (instead of being in a specific django app directory). That's all fine and good, and that's how we do it now.

Moreover, the docs state:

The main solution to these problems is the javascript_catalog view, which sends out a JavaScript code library with functions
that mimic the gettext interface, plus an array of translation strings. Those translation strings are taken from the application,
project or Django core, according to what you specify in either the info_dict or the URL.

This lead me to believe that translations under the project dir would work fine. So I began using the jsi18n view in our project, as:

jsInfoDict = {
    'packages': ('django.conf', 'bla.mydjangoproject'),
}
urlpatterns += patterns('',
    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', jsInfoDict),
)

We can get to the view fine, but our project's translations are not showing up. Going into the javascript_catalog code, I see that the problem seems to be with the line 124:

packages = [p for p in packages if p == 'django.conf' or p in settings.INSTALLED_APPS]

As I want to use locales under the project dir, that is not put into INSTALLED_APPS, as it's not a django app (obviously). So unless I am totally missing something here, this view needs to be enhanced to not filter out (in addition to INSTALLED_APPS):

  • The root project directory
  • Possibly any path specified in settings.LOCALE_PATHS

If this is acceptable, I can provide a patch if need be. That javascript_catalog section's docs will need to be updated as well.

Attachments (0)

Change History (5)

comment:1 Changed 6 years ago by jezdez

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

I can at least confirm that the code definitely doesn't appear to comply with the documentation, or the other way around.

The change is pretty old: http://code.djangoproject.com/changeset/1531/django/trunk/django/views/i18n.py

comment:2 Changed 6 years ago by telenieko

  • Component changed from Translations to Internationalization

The translations component is for Translations, that's for Internationalitzation ;)

comment:3 Changed 6 years ago by ericholscher

  • milestone set to 1.0 maybe
  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 6 years ago by trevor

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

This is the same issue as #5494.

comment:5 Changed 6 years ago by anonymous

  • milestone 1.0 maybe deleted

Milestone 1.0 maybe deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.