Skip to content

Localized routing prefixes not working as expected #48056

Closed as not planned
Closed as not planned
@AdmiralSG

Description

@AdmiralSG

Symfony version(s) affected

6.0, 6.1

Description

I have localized routing on my application, and it is not working as I expected since I updated symfony version, from 6.0 to 6.1.
Before the update I could see my url correctly like https://myroute/en/page or https://myroute/es/pagina. After the update it is hiding the language prefix, but it is not correct.

Am I missing something?

Thank you very much.

How to reproduce

The services.yaml is configured like this:

parameters: 
        app.supported_locales: ['en', 'es', 'pt'].

One example of route that was working and now does not:

#[Route(
            path: [
                'es' => '/registro/{land?}',
                'en' => '/signup/{land?}',
                'pt' => '/registarme/{land?}'
            ],
            name: 'registro',
            requirements: [
                '_locale' => 'es|en|pt',
            ],
    )]

This is showing https://myroute/registro while it should show https://myroute/es/registro like before updating the symfony version.

Edit: the file annotations.file I have is like this:

controllers:
    resource: ../../src/Controller/
    type: annotation
    prefix:
        es: '/es'
        en: '/en' 
        pt: '/pt'

home_sin_locale:
    path: /
    controller: App\Controller\SeccionPublicaController::indexNoLocale
    
kernel:
    resource: ../../src/Kernel.php
    type: annotation

I am not sure if this is relevant right now, maybe because I am using attributes (or not), but this file is in the project and before going 6.1 version this was working.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions