prestaconcept / PrestaSitemapBundle

A symfony bundle that provides tools to build a rich application sitemap. The main goals are : simple, no databases, various namespace (eg. google image), respect constraints etc.
MIT License
355 stars 102 forks source link

How to include translated routes in dump file ? #300

Closed PicassoHouessou closed 8 months ago

PicassoHouessou commented 2 years ago

My links look like: https://127.0.0.1:8000/en/contact https://127.0.0.1:8000/fr/contact https://127.0.0.1:8000/de/contact

presta_sitemap:
    resource: "@PrestaSitemapBundle/config/routing.yml"
    route_annotation_listener: true
    defaults:
        priority: 1
        changefreq: hourly
        lastmod: now
    alternate:
        enabled: true
        default_locale: "fr"
        locales: ["fr", "en", "de"]
        i18n: symfony

When I run php bin/console presta:sitemaps:dump I don't see in the dump file, the translated route. In the dump file we have only link with my default locale How to get the links with all locales?

yann-eugone commented 2 years ago

Hi @PicassoHouessou

For the bundle to be able to create routing alternate, you have to follow one of the supported convention. In your case, you have to follow symfony localized routes method : https://symfony.com/doc/current/routing.html#localized-routes-i18n.

If you are not following this convention, you can create a listener in your project that will add routing alternates. Please have a look to the one listener that is using this config in the bundle : https://github.com/prestaconcept/PrestaSitemapBundle/blob/3.x/src/EventListener/StaticRoutesAlternateEventListener.php

yann-eugone commented 8 months ago

Question answered, closing