Patch gets the language from the $sitemap settings, and passes it a long to url(). This means that when cron is run we still grab the correct language, rather than the default language.

Comments

Status: Needs review » Needs work

The last submitted patch, xml-set-language-xsl.patch, failed testing.

dave reid’s picture

Sitemaps do not always have a language context defined.

amitaibu’s picture

Status: Needs work » Needs review
StatusFileSize
new1.65 KB

>Sitemaps do not always have a language context defined.

Indeed. re-rolled patch.

kristen pol’s picture

Status: Needs review » Reviewed & tested by the community

I applied the patch to 7.x-2.0-rc1 and it works great. I have sitemaps in 3 languages and all the URLs look good.

Thanks!
Kristen

kevinwo’s picture

After applying the patch, I still encounter the same problem. Default language: zh-hant; Second language: en. Both my sitemap.xml and en/sitemap.xml display the same en links.

vasike’s picture

i can confirm both the issue and the solution (patch #3).

marcoka’s picture

question about that patch

ORIGINAL

  /**
   * Add the XML stylesheet to the XML page.
   */
  public function writeXSL() {
    $this->writePi('xml-stylesheet', 'type="text/xsl" href="' . url('sitemap.xsl') . '"');
    $this->writeRaw(PHP_EOL);
  }

PATCHED:

  /**
   * Add the XML stylesheet to the XML page.
   */
  public function writeXSL() {
    $options = array();
    if (!empty($sitemap->context['language'])) {
       $languages = language_list();
       $options = array('options' => array('language' => $languages[$sitemap->context['language']]));
    }
    $this->writePi('xml-stylesheet', 'type="text/xsl" href="' . url('sitemap.xsl', $options) . '"');
    $this->writeRaw(PHP_EOL);
  }

if (!empty($sitemap->context['language'])) ... there is no $sitemap variable available in this context, so its undefined here.

i think you wanted to use $this?
DEBUG: http://www.root.artwaves.de/screensnapr/1337105612-NAddqS.jpg

by the way, it does not work here. added a sitemap in de and en translated the body of a node using entity translation to german and en, sitemap for de does not show up the node/alias, sitemap in en does.

SITEMAP EN

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal_i18n/en/sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://192.168.1.238/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal_i18n/en</loc><changefreq>daily</changefreq><priority>1.0</priority></url>
<url><loc>http://192.168.1.238/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal_i18n/en/content/et-page</loc><lastmod>2012-05-15T18:10Z</lastmod><changefreq>hourly</changefreq></url>
</urlset>

SITEMAP DE

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal_i18n/en/sitemap.xsl"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url><loc>http://192.168.1.238/WORKSPACE_DRUPAL/TESTPROJEKTE/drupal_i18n/de</loc><changefreq>daily</changefreq><priority>1.0</priority></url>
</urlset>

noizo’s picture

noizo’s picture

StatusFileSize
new146.72 KB

SORRY, WRONG PLACE!
DELETE

unkn0wn’s picture

I tried to patch 7-2.x-dev and -rc1 with #3 with no success: i have multiple languages as subdomains, english (www.) is ok (content+taxonomy), but in german (de.) sitemap.xml i see only taxonomy urls and no one content url. Content translated via Entity Translation, i also use Domain Access + Domain XML Sitemap, maybe here is problem?

marcoka’s picture

as you use entity translation you may have a problem. AFAIK, entity translation uses one node and only translates fields, so i think atm there is no support for that. i18n adds a new node for every language.

unkn0wn’s picture

Here is really no support for entity translation: i revert to content translation, and everything is ok.

Anonymous’s picture

Priority: Normal » Critical
Status: Reviewed & tested by the community » Needs work

The url() API requires $options['language'] to be an object. The language_list() API returns an associative array of language parameters in array data and not a language object. The language_default() API returns an object for the default if no argument is given or returns the value of the object parameter if an argument is given. The argument should be a value matching a language object parameter.

Anonymous’s picture

Issue tags: +Release blocker
Anonymous’s picture

The language_list() API returns an associative array

Actually, I'm wrong, I'm reviewing this further.

kspal’s picture

Facing this same bug to reference nodes via the "XML sitemap node" module (I use Entity Translation), I found a temporary hack: the module "XML Sitemap Menu" is not suffering from this bug and will add your translated nodes referenced by menus into the right xml sitemaps.

This hack works of course if most of your content nodes are also accessible via menus (and you may get doublons in the xml sitemaps as well, some referenced by "XML Sitemap menu" and some by "Xml Sitemap node").

Just my 2 cents, if it can help...

mgifford’s picture

Issue tags: +i18n

tagging for i18n.

Patch from #3 still applies nicely to the git repo.

hefterbrumi’s picture

Are there any news on entity translation and xml sitemap working together? I think its quite an important problem.

muschpusch’s picture

StatusFileSize
new1.7 KB

Since #7 is right i rerolled the patch using the $this... The bad news: it's still not working..

@earnie: since i don't know the xmlsitemap module very well do you have any idea where we should start debugging?

muschpusch’s picture

StatusFileSize
new2.46 KB

Ok one step further :) hook_node_update does return the wrong language code: the original node language and not the "actual" node language. This works now well as long as you don't rebuild your sitemap. In the batch generation there seems to be something wrong...

mbauer’s picture

The patch above did move the english nodes into the sitemap but seemed to ignore some languageneutral nodes, so at the end there are missing a lot of links in the sitemap if you have a site where translated and langugaeneutral nodes exist.

I found a module that solved the problem for me!
node_translation_sitemap

regards

muschpusch’s picture

Status: Needs work » Fixed

ok that module just works great :) Closing this issue

marcoka’s picture

Status: Fixed » Needs work

i would not close this because actually xmlsitemap should include this. Maybe the module could be merged to submodule. Opinions?

batigol’s picture

+ for a merge

kristiaanvandeneynde’s picture

Any update on whether the module in #21 works and might be integrated?

guedressel’s picture

Issue summary: View changes

node_translation_sitemap solves the problem for me.

mgifford’s picture

Bit annoying that you need to add on https://drupal.org/project/node_translation_sitemap and that this isn't just done in xmlsitemap.

#20 is a pretty short patch. Would be much nicer to just get this fixed.

finex’s picture

The patch #20 doesn't care about translation published status, or am I wrong?

michphip’s picture

for me neither patch #20 nor the module node_translation_sitemap makes a differences. Both taxonomy terms and product displays wich are translated via entity translations are not appearing in other langauges (except english, the original)

pwiniacki’s picture

@michphip, same here.

colan’s picture

Status: Needs work » Closed (duplicate)

Although this issue is older, there's more work done in #1481798: Add support for Entity Translation & Title modules. Please correct me if I'm missing something, if this isn't actually a duplicate.

colan’s picture

Status: Closed (duplicate) » Needs work
StatusFileSize
new2.72 KB

Sorry, it's actually different. Here's a re-roll for the latest dev. Doesn't work for me, but it's a place to start.

colan’s picture

Status: Needs work » Closed (duplicate)

After more research, it looks like this is in fact solved by the other ticket. Sorry about the confusion. Steps:

  1. Enable the XML Sitemap Internationalization submodule.
  2. Apply the patch from #25 in the other ticket.
  3. Delete the default sitemap.
  4. Add a new sitemap for each of your languages.