diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
index 8d779ca..35fb159 100644
a
|
b
|
class Sitemap(object):
|
126 | 126 | 'changefreq': self.__get('changefreq', item), |
127 | 127 | 'priority': str(priority if priority is not None else ''), |
128 | 128 | } |
| 129 | # possibly different parameter name here, cause some people prefer using |
| 130 | # different method of entering them (http header, html page) |
| 131 | if getattr(self, 'i18n', False): |
| 132 | links = [] |
| 133 | current_lang_code = translation.get_language() |
| 134 | for lang_code, lang_name in settings.LANGUAGES: |
| 135 | translation.activate(lang_code) |
| 136 | href = "%s://%s%s" % (protocol, domain, self.__get('location', item)) |
| 137 | links.append({ |
| 138 | "hreflang": lang_code, |
| 139 | "href": href |
| 140 | }) |
| 141 | translation.activate(current_lang_code) |
| 142 | url_info["xhtml_links"] = links |
129 | 143 | urls.append(url_info) |
130 | 144 | if all_items_lastmod and latest_lastmod: |
131 | 145 | self.latest_lastmod = latest_lastmod |
diff --git a/django/contrib/sitemaps/templates/sitemap.xml b/django/contrib/sitemaps/templates/sitemap.xml
index 30ca3c0..0cb85fe 100644
a
|
b
|
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> |
| 2 | <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml"> |
3 | 3 | {% spaceless %} |
4 | 4 | {% for url in urlset %} |
5 | 5 | <url> |
… |
… |
|
7 | 7 | {% if url.lastmod %}<lastmod>{{ url.lastmod|date:"Y-m-d" }}</lastmod>{% endif %} |
8 | 8 | {% if url.changefreq %}<changefreq>{{ url.changefreq }}</changefreq>{% endif %} |
9 | 9 | {% if url.priority %}<priority>{{ url.priority }}</priority>{% endif %} |
| 10 | {% if url.xhtml_links %} |
| 11 | {% for link in url.xhtml_links %} |
| 12 | <xhtml:link rel="alternate" hreflang="{{ link.hreflang }}" href="{{ link.href }}" /> |
| 13 | {% endfor %} |
| 14 | {% endif %} |
10 | 15 | </url> |
11 | 16 | {% endfor %} |
12 | 17 | {% endspaceless %} |