SonataPageBundle icon indicating copy to clipboard operation
SonataPageBundle copied to clipboard

Add support for i18n routing

Open haivala opened this issue 3 years ago • 11 comments

Feature Request

I have dynamic pages and I have defined them like this: https://symfony.com/doc/current/routing.html#localized-routes-i18n and I use https://docs.sonata-project.org/projects/SonataPageBundle/en/3.x/reference/multisite/#host-by-locale-strategy

when I run the update-core-routes command those dynamic pages are updated to all of my sites so I end up with many duplicate pages as one site should be used only in one locale.

Other thing that localized routes breaks is the current dynamic page retrieval from the CmsManagerSelector.

haivala avatar Oct 04 '21 11:10 haivala

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Apr 02 '22 12:04 github-actions[bot]

This is clearly a bug should not be closed

haivala avatar Apr 09 '22 13:04 haivala

This one does not seem easily solvable TBH.

When a route is i18n, internally symfony generates N routes, one for each locale. And the routeCollection exposes all of them, the update-route-routes command picks them all and tries to generate one page for each one. Up to this point we can discuss if we want that behavior or not, but it "works".

(There is a problem with the update-core-routes that does not take into account if the site have the locale used by that route)

And then on the render side, when you visit a route with i18n, it does not work at all, you have a routeName: something_something, but the page has: something_something.es and it does not find it, because the request think there is only one route.

And even if we fix those 2 problems, I don't know if we really should be generating one page per language, I guess yes? because here we don't have any i18n concepts.

wdyt @VincentLanglet ?

jordisala1991 avatar Aug 15 '22 08:08 jordisala1991

I think all is said.

It's not a bug, it's a very complicated feature request to implement. So if nobody wants to work on it we can close this as "not planned".

VincentLanglet avatar Aug 15 '22 09:08 VincentLanglet

In my case the only real problem this raises is that I cannot give the user of the page admin easy way to change the page SEO attributes as the page cannot be found in the front controller even if I run the update core routes and manually delete the wrong language ones from the site. Of course block addition would be nice to have too.

Other way to solve this could be that as we define route without i18n we could somehow decide in which site the route belongs?

haivala avatar Aug 17 '22 09:08 haivala

extra parameter perhaps? sonata_page_site_id=1?

haivala avatar Aug 17 '22 09:08 haivala

This would be useful as I have also project that has 2 sites with different domains and one admin to control them and now I have to delete the routes manually from the other one after update-core-routes.

haivala avatar Aug 17 '22 10:08 haivala

I changed the subject to be more descriptive

jordisala1991 avatar Sep 12 '22 07:09 jordisala1991

Should I do another issue about the dynamic page assignment to a site?

haivala avatar Sep 12 '22 09:09 haivala

Dynamic pages are just normal pages, they have a $site assigned to them, I don't think there is something wrong with that. Just try dynamic pages without i18n, if you see any issue, yes, open an issue. (What we won't do is patching something that is not implemented AKA i18n routing).

jordisala1991 avatar Sep 12 '22 09:09 jordisala1991

Dynamic pages are just normal pages, they have a $site assigned to them, I don't think there is something wrong with that. Just try dynamic pages without i18n, if you see any issue, yes, open an issue. (What we won't do is patching something that is not implemented AKA i18n routing).

Done here: https://github.com/sonata-project/SonataPageBundle/issues/1610

haivala avatar Oct 12 '22 16:10 haivala