schmittjoh / JMSI18nRoutingBundle

Allows you to internationalize your routing
http://jmsyst.com/bundles/JMSI18nRoutingBundle
358 stars 159 forks source link

Incompatibility with Symfony2.4 #115

Closed jamarisi closed 10 years ago

jamarisi commented 10 years ago

Hello, yesterday I updated one of my projects to Symfony2.4 and I'm having problems with the i18n since then. First, my language switcher generates only routes for the current language. It ignores the _locale param and if I'm currently using the es locale, it generates all the links with the same locale.

<ul class="pull-right nav navbar-nav">
    <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
            {{ app.request.get('_locale')|upper }}
            <b class="caret"></b>
        </a>
        <ul class="dropdown-menu">
            {% for locale in ['es', 'en', 'pt'] %}
            <li>
                <a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({ '_locale': locale })) }}">{{ locale|upper }}</a>
            </li>
            {% endfor %}
        </ul>
    </li>
</ul>

It was working perfectly with Symfony2.3.

Second, I'm having problems with the security configuration. In my security.yml I have something like

security:
    providers:
        fos_userbundle:
            id: fos_user.user_provider.username

    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    firewalls:
        main:
            pattern: ^/
            form_login:
                provider: fos_userbundle
                csrf_provider: form.csrf_provider
                login_path: fos_user_security_login
                check_path: fos_user_security_check
            logout:
                path:   fos_user_security_logout

But now the login_path, check_path and path in logout are no longer recognized. There are no exceptions when the file is parsed, but the listeners are not invoked when the form is submitted. It works when I add the localized paths, like esRGfos_user_security_login, but I cannot hard code the localized path for every locale. Like the first problem, it was working fine with Symfony2.3.

The bundle configuration is:

jms_i18n_routing:
    default_locale: es
    locales: [es, en, pt]
    strategy: prefix

Any ideas that I can try to fix these issues?

Thank you in advance.

dariuszz123 commented 10 years ago

+1 I have same issue in symfony 2.4. Route in request is "ltRGuser_login_check", but it should be "user_login_check"

kbond commented 10 years ago

I'm also having this issue.

kbond commented 10 years ago

From what I can see Route:match($url) is no longer used... Route::matchRequest(Request $request) is used as of 2.4.

tadcka commented 10 years ago

+1

pculka commented 10 years ago

Just a wild guess here: login and login_check shouldn't really be translated, max I'd pass maybe the locale as a get param to get a redirect to the original translation after logincheck Meaning one should prefix the route names with to stop them being translated?