Opened 14 years ago

Closed 5 years ago

#13896 closed New feature (duplicate)

Change language to dynamic attribute in syndication feed generator

Reported by: jedie Owned by: Jason Kotenko
Component: contrib.syndication Version: dev
Severity: Normal Keywords:
Cc: kotenko@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

In my project, the language is dynamic and not hardcoded in settings. IMHO there is no way to change the language in syndication feed generator without a hack.

Change language to dynamic attribute in syndication feed generator:

  • django/contrib/syndication/views.py

     
    104104            subtitle = self.__get_dynamic_attr('subtitle', obj),
    105105            link = link,
    106106            description = self.__get_dynamic_attr('description', obj),
    107             language = settings.LANGUAGE_CODE.decode(),
     107            language=self.__get_dynamic_attr('language', obj, settings.LANGUAGE_CODE.decode()),
    108108            feed_url = add_domain(current_site.domain,
    109109                    self.__get_dynamic_attr('feed_url', obj) or request.path),
    110110            author_name = self.__get_dynamic_attr('author_name', obj),

Attachments (3)

django_13896.diff (1.5 KB ) - added by Jason Kotenko 13 years ago.
SVN Diff
django_13896_2.diff (3.7 KB ) - added by Jason Kotenko 13 years ago.
SVN Diff
django_13896_20110506.diff (3.6 KB ) - added by Jason Kotenko 13 years ago.
Latest SVN Diff

Download all attachments as: .zip

Change History (16)

comment:1 by Matthias Kestenholz, 13 years ago

Needs documentation: set
Triage Stage: UnreviewedAccepted

I think this makes sense. The language of the feed might be encoded inside the URL too and isn't fixed to LANGUAGE_CODE from the site settings.

This change has to be documented.

comment:2 by Jason Kotenko, 13 years ago

Owner: changed from nobody to Jason Kotenko
Status: newassigned

comment:3 by Jason Kotenko, 13 years ago

Cc: kotenko@… added
Needs documentation: unset

Adding SVN diff that includes the patch included above and a patch for the docs, mentioning that now the language attribute can be set, and otherwise defaults to the project-wide setting for LANGUAGE_CODE.

by Jason Kotenko, 13 years ago

Attachment: django_13896.diff added

SVN Diff

comment:4 by Jannis Leidel, 13 years ago

Needs tests: set

by Jason Kotenko, 13 years ago

Attachment: django_13896_2.diff added

SVN Diff

comment:5 by Jason Kotenko, 13 years ago

Needs tests: unset

New diff entered, includes Fix, Docs, and Regression Test. Use the second patch, as the first is wrong. Thanks.

comment:6 by Chris Morgan, 13 years ago

It would be very nice if this could get put into Django 1.3. I've had to hack this into shape myself to get it working for the new Inkscape website which can make news feeds for any supported language, using request.LANGUAGE_CODE rather than settings.LANGUAGE_CODE (seems to me that that is going to be a common request; I think it would be good if Feed stored the Request - but that's another ticket).

See http://bazaar.launchpad.net/~inkscape-webadmin/inkscape-web/inkscape-web/revision/62 for how I ended up wedging it in (1.2.5): and I know it won't work even back in 1.2.3 due to a couple of changes in the Django code, without providing another couple of methods. Not very maintainable :-(

comment:7 by Graham King, 13 years ago

Severity: Normal
Type: New feature

comment:8 by patchhammer, 13 years ago

Easy pickings: unset
Patch needs improvement: set

django_13896_2.diff fails to apply cleanly on to trunk

by Jason Kotenko, 13 years ago

Attachment: django_13896_20110506.diff added

Latest SVN Diff

comment:9 by Jason Kotenko, 13 years ago

Looks like bitrot got the best of the last one. New diff uploaded, new test passes under "settings=test_sqlite".

comment:10 by Jason Kotenko, 13 years ago

Patch needs improvement: unset

comment:11 by Julien Phalip, 13 years ago

Patch needs improvement: set
UI/UX: unset

The patch looks pretty good but there is one slight inconsistency. The doc says:

You  can set the language for a feed by specifying an attribute :attr:`language`,  using the ***same format*** as the project-wide setting :setting:`LANGUAGE_CODE`.

... yet the code is:

language = self.__get_dynamic_attr('language', obj, settings.LANGUAGE_CODE.decode()),

So the LANGUAGE_CODE setting is decoded whereas the language API attribute isn't. Ideally the behaviour should be normalised and made consistent.

comment:12 by Aymeric Augustin, 12 years ago

#7039 was closed as a duplicate.

comment:13 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: assignedclosed

Closing as a duplicate of fixed #29352.

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