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
104 104 subtitle = self.__get_dynamic_attr('subtitle', obj), 105 105 link = link, 106 106 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()), 108 108 feed_url = add_domain(current_site.domain, 109 109 self.__get_dynamic_attr('feed_url', obj) or request.path), 110 110 author_name = self.__get_dynamic_attr('author_name', obj),
Attachments (3)
Change History (16)
comment:1 by , 14 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 14 years ago
Cc: | 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.
comment:4 by , 14 years ago
Needs tests: | set |
---|
comment:5 by , 14 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 , 14 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 , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:8 by , 14 years ago
Easy pickings: | unset |
---|---|
Patch needs improvement: | set |
django_13896_2.diff fails to apply cleanly on to trunk
comment:9 by , 14 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 , 14 years ago
Patch needs improvement: | unset |
---|
comment:11 by , 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:13 by , 5 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
Closing as a duplicate of fixed #29352.
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.