Ticket #13896: django_13896_20110506.diff

File django_13896_20110506.diff, 3.6 KB (added by jasonkotenko, 4 years ago)

Latest SVN Diff

  • docs/ref/contrib/syndication.txt

     
    268268--------
    269269
    270270Feeds created by the syndication framework automatically include the
    271 appropriate ``<language>`` tag (RSS 2.0) or ``xml:lang`` attribute (Atom). This
    272 comes directly from your :setting:`LANGUAGE_CODE` setting.
     271appropriate ``<language>`` tag (RSS 2.0) or ``xml:lang`` attribute (Atom). You
     272can set the language for a feed by specifying an attribute :attr:`language`,
     273using the same format as the project-wide setting :setting:`LANGUAGE_CODE`. If 
     274you don't specify a language, it comes directly from your 
     275:setting:`LANGUAGE_CODE` setting.
    273276
    274277URLs
    275278----
  • 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(
    109109                current_site.domain,
    110110                self.__get_dynamic_attr('feed_url', obj) or request.path,
  • tests/regressiontests/syndication/tests.py

     
    77from django.test import TestCase
    88from django.utils import tzinfo
    99from django.utils.feedgenerator import rfc2822_date, rfc3339_date
     10from django.conf import settings
    1011
    1112from models import Entry
    1213
     
    226227        updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText
    227228        self.assertEqual(updated[-6:], '+00:42')
    228229
     230    def test_language_code(self):
     231        """
     232        Test that language code is set via dynamic parameter.
     233        """
     234        response = self.client.get('/syndication/language/')
     235        feed = minidom.parseString(response.content).firstChild
     236        self.assertEqual(feed.getElementsByTagName('language')[0].firstChild.wholeText, 'tl')
     237        #Make sure that it's not because Tagalog is set in settings already
     238        self.assertNotEqual(settings.LANGUAGE_CODE.decode(), 'tl')
     239
    229240    def test_feed_url(self):
    230241        """
    231242        Test that the feed_url can be overridden.
  • tests/regressiontests/syndication/urls.py

     
    1313    (r'^syndication/feedurl/$', feeds.TestFeedUrlFeed()),
    1414    (r'^syndication/articles/$', feeds.ArticlesFeed()),
    1515    (r'^syndication/template/$', feeds.TemplateFeed()),
     16    (r'^syndication/language/$', feeds.LanguageFeed()),
    1617)
  • tests/regressiontests/syndication/feeds.py

     
    9191        # settings.TIME_ZONE.
    9292        return item.date.replace(tzinfo=tzinfo.FixedOffset(42))
    9393
     94class LanguageFeed(TestRss2Feed):
     95    language = 'tl'
    9496
    9597class TestFeedUrlFeed(TestAtomFeed):
    9698    feed_url = 'http://example.com/customfeedurl/'
Back to Top