Opened 3 years ago

Closed 2 years ago

Last modified 19 months ago

#33662 closed New feature (fixed)

Choose which items are displayed per language in Sitemap

Reported by: Roxane Owned by: Roxane
Component: contrib.sitemaps Version: 4.0
Severity: Normal Keywords: sitemap
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The current implementation of Sitemap is : if we use i18n, then we display a cartesian product between some items and some languages.

There is no way to use the provided i18n automation if we want to display some items depending on the language (for instance non-translated blog articles).

I precise in my case, urls are translated, so given a language the url may not exist or raise an error.

Change History (11)

comment:1 by Carlton Gibson, 3 years ago

Triage Stage: UnreviewedAccepted

OK, sounds reasonable to at least look at.

Would you care to take on a patch? In either case could you perhaps expand the description to include a minimal reproduce setup so that someone picking it up had a few breadcrumbs to follow? Thanks!

comment:2 by PhönixGeist, 2 years ago

I would like to tackle this new feature, it sounds interesting. As Carlton Gibson said, could you expand please the description, so I can fully understand the idea of the new feature?.

For instance, on which scenario the URLs get translated? (Not sure, but this maybe sounds more like an error than a future).
It does sound as a new feature, being able to display some items depending on the language, by this do you mean like for example, only translate a menu or only translate what is inside a <div> or something similar?

Please expand your idea.

Last edited 2 years ago by PhönixGeist (previous) (diff)

comment:3 by Tim Graham, 2 years ago

Component: Uncategorizedcontrib.sitemaps
Summary: Choose witch items are to be display per language in SitemapChoose which items are displayed per language in Sitemap

comment:4 by Roxane, 2 years ago

Has patch: set
Owner: changed from nobody to Roxane
Status: newassigned

Sorry for the delay, I did not at all see any of your comments sooner !

I have in my project a model Article which could be summed up in four fields (url_en, url_fr, content_en and content_fr). Some of these article are only written in one language. With no content, the page is empty. Even if it exists, I don't want this empty page to be in my sitemap.

My idea was to add a method in Sitemap to return a boolean indicating whether the item should be displayed in the sitemap given a language.
I made a first draft for a patch (https://github.com/django/django/compare/main...roxanebellot:django:ticket_33662). I wait for a green light on the feature before submitting it as a PR.

comment:5 by Carlton Gibson, 2 years ago

Has patch: unset

@roxanebellot Please open a PR and add it here when you've done so. Thanks.

comment:6 by Roxane, 2 years ago

Has patch: set
Version 0, edited 2 years ago by Roxane (next)

comment:7 by Mariusz Felisiak, 2 years ago

Patch needs improvement: set

comment:8 by Mariusz Felisiak, 2 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In 289e9a7:

Fixed #33662 -- Allowed Sitemap to customize languages for each item.

comment:10 by GitHub <noreply@…>, 19 months ago

In 5c456a8:

Refs #33662 -- Corrected Sitemap.get_languages_for_item() signature in docs.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 19 months ago

In 88f23b6b:

[4.2.x] Refs #33662 -- Corrected Sitemap.get_languages_for_item() signature in docs.

Backport of 5c456a879300e5f51010d3f6aa7449302413efed from main

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