In issue #3107818 the isMultilingualSitemap() method was added to SitemapGeneratorBase.php with a strict requirement of LanguageNegotiationUrl::METHOD_ID being enabled. See: https://git.drupalcode.org/project/simple_sitemap/-/commit/75017cd102811...
We use an alternate method provided by another contributed module, but it is a child class of "LanguageNegotiationUrl." The result is all alternate URLs are removed before the final sitemap is generated.
Proposed solution is to use the language negotiation service to load the primary negotiation method for the language type 'content' (LanguageInterface::TYPE_CONTENT) and then see if that is an instance of the "LanguageNegotiationUrl" class. Patch to follow shortly.
This documentation was very helpful in developing the approach: https://api.drupal.org/api/drupal/core%21modules%21language%21src%21Lang...
I think it's worth calling out here that there may be other negotiation methods that could use the URL without inheriting from the LanguageNegotiationUrl class that this solution would miss. An alternative would be to simply provide a configuration value that would allow a user to simply select whether or not they want a multilingual sitemap, which could be more inclusive.
Comment | File | Size | Author |
---|---|---|---|
#13 | language-negotiation-check-3154570-13.patch | 1.42 KB | ben.hamelin |
| |||
#10 | Detection_and_selection.png | 313.15 KB | abhisekmazumdar |
#5 | language-negotiation-check-3154570-5.patch | 2.6 KB | ben.hamelin |
|
Comments
Comment #2
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedComment #4
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedAdd an anonymous user login to SimplesitemapTestBase.php setup() method so there is a valid user available when the language negotiation service calls are made. Should resolve previous failures but also want to be sure this approach is ok for the existing testing suite.
Comment #5
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedComment #6
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedI tried some approaches to resolve the failing tests but not having luck. Would love some feedback on this and some guidance on resolving these test issues. I thought adding the drupalLogin() calls would work but I am missing something.
Comment #7
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedThis does not work for me as I have "Customize Content language detection to differ from Interface text language detection settings" unchecked under
admin/config/regional/language/detection
.I don't really grasp what LanguageInterface::TYPE_URL does. If it does what I think it does, this should be a working solution:
Otherwise this might be necessary:
Both are working for me. Sorry for not creating patches, but I am quite busy right now. Could you please review/test these two approaches and provide feedback?
Comment #8
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedAny progress on this?
Comment #9
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commentedSorry, taking a while to get back to this. Hoping to have a test patch ready later this week. Thank you!
Comment #10
abhisekmazumdarMarking this as major. One of the live site we are working on doesn't has URL detection enabled. So its not creating for the links with the lang-code.
Comment #11
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commented@abhisekmazumdar Please correct me if I am wrong, but a multilingual sitemap is only practical/functional if it can take you to a specific translation/language. If URL detection is fully disabled, the links in the sitemap will be same for each language. What is the point of having repeating links for each language?
Comment #12
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedComment #13
ben.hamelin CreditAttribution: ben.hamelin at Oomph, Inc. commented@gbyte - Here is a patch based on your comment from #7. Tried this locally, it worked fine for me.
Comment #14
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedComment #16
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedThanks for testing.
Comment #18
PieterDCAs far as I understand, this issue hasn't been solved because it still requires the default URL language detection to be enabled.
I don't consider reopening this issue, because I consider #3228584: Multilingual sitemap test fails for some language negotiation plugins to be a follow-up issue.